Abstract class for residual models. More...
#include <crocoddyl/core/residual-base.hpp>
Public Types | |
typedef DataCollectorAbstractTpl< Scalar > | DataCollectorAbstract |
typedef MathBaseTpl< Scalar > | MathBase |
typedef MathBase::MatrixXs | MatrixXs |
typedef ResidualDataAbstractTpl< Scalar > | ResidualDataAbstract |
typedef StateAbstractTpl< Scalar > | StateAbstract |
typedef MathBase::VectorXs | VectorXs |
Public Member Functions | |
ResidualModelAbstractTpl (boost::shared_ptr< StateAbstract > state, const std::size_t nr, const std::size_t nu, const bool q_dependent=true, const bool v_dependent=true, const bool u_dependent=true) | |
Initialize the residual model. More... | |
ResidualModelAbstractTpl (boost::shared_ptr< StateAbstract > state, const std::size_t nr, const bool q_dependent=true, const bool v_dependent=true, const bool u_dependent=true) | |
virtual void | calc (const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u) |
Compute the residual vector. More... | |
void | calc (const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x) |
virtual void | calcDiff (const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u) |
Compute the Jacobian of the residual vector. More... | |
void | calcDiff (const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x) |
virtual boost::shared_ptr< ResidualDataAbstract > | createData (DataCollectorAbstract *const data) |
Create the residual data. More... | |
std::size_t | get_nr () const |
Return the dimension of the residual vector. | |
std::size_t | get_nu () const |
Return the dimension of the control input. | |
bool | get_q_dependent () const |
Return true if the residual function depends on q. | |
const boost::shared_ptr< StateAbstract > & | get_state () const |
Return the state. | |
bool | get_u_dependent () const |
Return true if the residual function depends on u. | |
bool | get_v_dependent () const |
Return true if the residual function depends on v. | |
virtual void | print (std::ostream &os) const |
Print relevant information of the residual model. More... | |
Public Attributes | |
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar | Scalar |
Protected Attributes | |
std::size_t | nr_ |
Residual vector dimension. | |
std::size_t | nu_ |
Control dimension. | |
bool | q_dependent_ |
Label that indicates if the residual function depends on q. | |
boost::shared_ptr< StateAbstract > | state_ |
State description. | |
bool | u_dependent_ |
Label that indicates if the residual function depends on u. | |
VectorXs | unone_ |
No control vector. | |
bool | v_dependent_ |
Label that indicates if the residual function depends on v. | |
Friends | |
template<class Scalar > | |
std::ostream & | operator<< (std::ostream &os, const ResidualModelAbstractTpl< Scalar > &model) |
Print information on the residual model. | |
Abstract class for residual models.
In Crocoddyl, a residual model defines a vector function \(\mathbf{r}(\mathbf{x}, \mathbf{u})\mathbb{R}^{nr}\) where nr
describes its dimension in the Euclidean space. This function depends on the state point \(\mathbf{x}\in\mathcal{X}\), which lies in the state manifold described with a nq
-tuple, its velocity \(\dot{\mathbf{x}}\in T_{\mathbf{x}}\mathcal{X}\) that belongs to the tangent space with nv
dimension, and the control input \(\mathbf{u}\in\mathbb{R}^{nu}\). The residual function can used across cost and constraint models.
The main computations are carring out in calc
and calcDiff
routines. calc
computes the residual vector and calcDiff
computes the Jacobians of the residual function. Additionally, it is important remark that calcDiff()
computes the Jacobians using the latest stored values by calc()
. Thus, we need to run first calc()
.
StateAbstractTpl
, calc()
, calcDiff()
, createData()
ResidualModelAbstractTpl | ( | boost::shared_ptr< StateAbstract > | state, |
const std::size_t | nr, | ||
const std::size_t | nu, | ||
const bool | q_dependent = true , |
||
const bool | v_dependent = true , |
||
const bool | u_dependent = true |
||
) |
Initialize the residual model.
[in] | state | State of the system |
[in] | nr | Dimension of residual vector |
[in] | nu | Dimension of control vector |
[in] | q_dependent | Define if the residual function depends on q (default true) |
[in] | v_dependent | Define if the residual function depends on v (default true) |
[in] | u_dependent | Define if the residual function depends on u (default true) |
ResidualModelAbstractTpl | ( | boost::shared_ptr< StateAbstract > | state, |
const std::size_t | nr, | ||
const bool | q_dependent = true , |
||
const bool | v_dependent = true , |
||
const bool | u_dependent = true |
||
) |
Initialize the residual model.
The default nu
value is obtained from StateAbstractTpl::get_nv()
.
[in] | state | State of the system |
[in] | nr | Dimension of residual vector |
[in] | q_dependent | Define if the residual function depends on q (default true) |
[in] | v_dependent | Define if the residual function depends on v (default true) |
[in] | u_dependent | Define if the residual function depends on u (default true) |
|
virtual |
Compute the residual vector.
[in] | data | Residual data |
[in] | x | State point \(\mathbf{x}\in\mathbb{R}^{ndx}\) |
[in] | u | Control input \(\mathbf{u}\in\mathbb{R}^{nu}\) |
Reimplemented in ResidualModelContactCoPPositionTpl< _Scalar >, ResidualModelContactForceTpl< _Scalar >, ResidualModelContactWrenchConeTpl< _Scalar >, ResidualModelContactFrictionConeTpl< _Scalar >, ResidualModelFrameVelocityTpl< _Scalar >, ResidualModelFramePlacementTpl< _Scalar >, ResidualModelFrameTranslationTpl< _Scalar >, ResidualModelFrameRotationTpl< _Scalar >, ResidualModelControlTpl< _Scalar >, ResidualModelCentroidalMomentumTpl< _Scalar >, ResidualModelContactControlGravTpl< _Scalar >, ResidualModelCoMPositionTpl< _Scalar >, ResidualModelControlGravTpl< _Scalar >, and ResidualModelImpulseCoMTpl< _Scalar >.
|
virtual |
Compute the Jacobian of the residual vector.
It computes the Jacobian the residual function. It assumes that calc()
has been run first.
[in] | data | Residual data |
[in] | x | State point \(\mathbf{x}\in\mathbb{R}^{ndx}\) |
[in] | u | Control input \(\mathbf{u}\in\mathbb{R}^{nu}\) |
Reimplemented in ResidualModelContactCoPPositionTpl< _Scalar >, ResidualModelContactForceTpl< _Scalar >, ResidualModelContactWrenchConeTpl< _Scalar >, ResidualModelContactFrictionConeTpl< _Scalar >, ResidualModelFrameVelocityTpl< _Scalar >, ResidualModelFramePlacementTpl< _Scalar >, ResidualModelFrameTranslationTpl< _Scalar >, ResidualModelFrameRotationTpl< _Scalar >, ResidualModelControlTpl< _Scalar >, ResidualModelCentroidalMomentumTpl< _Scalar >, ResidualModelContactControlGravTpl< _Scalar >, ResidualModelCoMPositionTpl< _Scalar >, ResidualModelControlGravTpl< _Scalar >, and ResidualModelImpulseCoMTpl< _Scalar >.
|
virtual |
Create the residual data.
The default data contains objects to store the values of the residual vector and their Jacobians. However, it is possible to specialized this function if we need to create additional data, for instance, to avoid dynamic memory allocation.
data | Data collector |
Reimplemented in ResidualModelContactCoPPositionTpl< _Scalar >, ResidualModelContactForceTpl< _Scalar >, ResidualModelContactWrenchConeTpl< _Scalar >, ResidualModelContactFrictionConeTpl< _Scalar >, ResidualModelFrameVelocityTpl< _Scalar >, ResidualModelFramePlacementTpl< _Scalar >, ResidualModelFrameTranslationTpl< _Scalar >, ResidualModelFrameRotationTpl< _Scalar >, ResidualModelControlTpl< _Scalar >, ResidualModelCentroidalMomentumTpl< _Scalar >, ResidualModelContactControlGravTpl< _Scalar >, ResidualModelCoMPositionTpl< _Scalar >, ResidualModelControlGravTpl< _Scalar >, ResidualModelImpulseCoMTpl< _Scalar >, and ResidualModelNumDiffTpl< _Scalar >.
void calc | ( | const boost::shared_ptr< ResidualDataAbstract > & | data, |
const Eigen::Ref< const VectorXs > & | x | ||
) |
Compute the residual vector.
[in] | data | Residual data |
[in] | x | State point |
void calcDiff | ( | const boost::shared_ptr< ResidualDataAbstract > & | data, |
const Eigen::Ref< const VectorXs > & | x | ||
) |
Compute the Jacobian of the residual vector.
[in] | data | Residual data |
[in] | x | State point |
|
virtual |
Print relevant information of the residual model.
[out] | os | Output stream object |
Reimplemented in ResidualModelContactCoPPositionTpl< _Scalar >, ResidualModelContactForceTpl< _Scalar >, ResidualModelContactWrenchConeTpl< _Scalar >, ResidualModelContactFrictionConeTpl< _Scalar >, ResidualModelFrameVelocityTpl< _Scalar >, ResidualModelStateTpl< _Scalar >, ResidualModelFramePlacementTpl< _Scalar >, ResidualModelFrameTranslationTpl< _Scalar >, ResidualModelFrameRotationTpl< _Scalar >, ResidualModelControlTpl< _Scalar >, ResidualModelCentroidalMomentumTpl< _Scalar >, ResidualModelCoMPositionTpl< _Scalar >, ResidualModelContactControlGravTpl< _Scalar >, ResidualModelControlGravTpl< _Scalar >, and ResidualModelImpulseCoMTpl< _Scalar >.