LocalGuidance
A library that generates velocity references to follow a path.
robot_utils::PidEigen Class Reference

#include <PidEigen.hpp>

Public Types

typedef Eigen::MatrixXd MatrixXd
 

Public Member Functions

 PidEigen (const MatrixXd &pGains, const MatrixXd &iGains, const MatrixXd &dGains, const MatrixXd &iMax, const MatrixXd &iMin, const MatrixXd &cmdMax, const MatrixXd &cmdMin)
 
virtual ~PidEigen ()
 
void init (const MatrixXd &pGains, const MatrixXd &iGains, const MatrixXd &dGains, const MatrixXd &iMax, const MatrixXd &iMin, const MatrixXd &cmdMax, const MatrixXd &cmdMin)
 
void setPGains (const MatrixXd &pGains)
 
void setIGains (const MatrixXd &iGains)
 
void setDGains (const MatrixXd &dGains)
 
void setIMax (const MatrixXd &iMax)
 
void setIMin (const MatrixXd &iMin)
 
void setCmdMax (const MatrixXd &cmdMax)
 
void setCmdMin (const MatrixXd &cmdMin)
 
MatrixXd getPGains () const
 
MatrixXd getIGains () const
 
MatrixXd getDGains () const
 
MatrixXd getIMax () const
 
MatrixXd getIMin () const
 
MatrixXd getCmdMax () const
 
MatrixXd getCmdMin () const
 
MatrixXd getCmd () const
 
template<typename Derived >
void update (const Eigen::MatrixBase< Derived > &error, Eigen::MatrixBase< Derived > &command, double dt)
 
void getErrors (MatrixXd &pError, MatrixXd &iError, MatrixXd &dError) const
 
void reset ()
 

Private Attributes

MatrixXd pErrLast_
 
MatrixXd pErr_
 
MatrixXd iErr_
 
MatrixXd dErr_
 
MatrixXd pGains_
 
MatrixXd iGains_
 
MatrixXd dGains_
 
MatrixXd iMax_
 
MatrixXd iMin_
 
MatrixXd cmdMax_
 
MatrixXd cmdMin_
 
MatrixXd cmd_
 

Detailed Description

Proportional-integral-derivative class for use with eigen types. The controller acts element-wise.

Member Typedef Documentation

typedef Eigen::MatrixXd robot_utils::PidEigen::MatrixXd

Constructor & Destructor Documentation

robot_utils::PidEigen::PidEigen ( const MatrixXd pGains,
const MatrixXd iGains,
const MatrixXd dGains,
const MatrixXd iMax,
const MatrixXd iMin,
const MatrixXd cmdMax,
const MatrixXd cmdMin 
)

Constructor. For arguments, see the init method.

virtual robot_utils::PidEigen::~PidEigen ( )
inlinevirtual

Member Function Documentation

MatrixXd robot_utils::PidEigen::getCmd ( ) const
inline
MatrixXd robot_utils::PidEigen::getCmdMax ( ) const
inline
MatrixXd robot_utils::PidEigen::getCmdMin ( ) const
inline
MatrixXd robot_utils::PidEigen::getDGains ( ) const
inline
void robot_utils::PidEigen::getErrors ( MatrixXd pError,
MatrixXd iError,
MatrixXd dError 
) const

Retreive the current state of the controller.

Parameters
[out]pErrorcurrent proporional error
[out]iErrorcurrent integrator value
[out]pErrorcurrent error derivative
MatrixXd robot_utils::PidEigen::getIGains ( ) const
inline
MatrixXd robot_utils::PidEigen::getIMax ( ) const
inline
MatrixXd robot_utils::PidEigen::getIMin ( ) const
inline
MatrixXd robot_utils::PidEigen::getPGains ( ) const
inline
void robot_utils::PidEigen::init ( const MatrixXd pGains,
const MatrixXd iGains,
const MatrixXd dGains,
const MatrixXd iMax,
const MatrixXd iMin,
const MatrixXd cmdMax,
const MatrixXd cmdMin 
)

Initializes the controller. All parameters need to have the same dimension, otherwise an error is thrown. For zero integral action, the respective element in iGains should be set zero.

Parameters
[in]pGainsproportional controller gains
[in]iGainsintegrator controller gains
[in]dGainsderivative controller gains
[in]iMaxmaximum values the integrators may attain
[in]iMinmaximum values the integrators may attain (must be less than iMax)
[in]cmdMaxmaximum output values of the controller
[in]cmdMinminimum output values of the controller (must be less than cmdMax)
void robot_utils::PidEigen::reset ( )

Resets the PID controller. All errors get set to zero (including integrator state). Note that this may cause a jump in the control action.

void robot_utils::PidEigen::setCmdMax ( const MatrixXd cmdMax)
void robot_utils::PidEigen::setCmdMin ( const MatrixXd cmdMin)
void robot_utils::PidEigen::setDGains ( const MatrixXd dGains)
void robot_utils::PidEigen::setIGains ( const MatrixXd iGains)
void robot_utils::PidEigen::setIMax ( const MatrixXd iMax)
void robot_utils::PidEigen::setIMin ( const MatrixXd iMin)
void robot_utils::PidEigen::setPGains ( const MatrixXd pGains)
template<typename Derived >
void robot_utils::PidEigen::update ( const Eigen::MatrixBase< Derived > &  error,
Eigen::MatrixBase< Derived > &  command,
double  dt 
)
inline

Updates the PID controller, should be called each time step. All parameters need to have the same dimension, otherwise an error is thrown.

Parameters
[in]errorcurrent error = (actual value - desired value) as input to the controller
[out]commandto be applied to the system
[in]dtcontrol update step (time elapsed from last update call) [s]

Member Data Documentation

MatrixXd robot_utils::PidEigen::cmd_
private
MatrixXd robot_utils::PidEigen::cmdMax_
private
MatrixXd robot_utils::PidEigen::cmdMin_
private
MatrixXd robot_utils::PidEigen::dErr_
private
MatrixXd robot_utils::PidEigen::dGains_
private
MatrixXd robot_utils::PidEigen::iErr_
private
MatrixXd robot_utils::PidEigen::iGains_
private
MatrixXd robot_utils::PidEigen::iMax_
private
MatrixXd robot_utils::PidEigen::iMin_
private
MatrixXd robot_utils::PidEigen::pErr_
private
MatrixXd robot_utils::PidEigen::pErrLast_
private
MatrixXd robot_utils::PidEigen::pGains_
private

The documentation for this class was generated from the following file: