Crocoddyl
ResidualModelAbstractTpl< _Scalar > Class Template Reference

Abstract class for residual models. More...

#include <residual-base.hpp>

Inheritance diagram for ResidualModelAbstractTpl< _Scalar >:
DifferentialActionModelContactInvDynamicsTpl< _Scalar >::ResidualModelActuation DifferentialActionModelContactInvDynamicsTpl< _Scalar >::ResidualModelContact DifferentialActionModelFreeInvDynamicsTpl< _Scalar >::ResidualModelActuation ResidualModelCentroidalMomentumTpl< _Scalar > ResidualModelCoMPositionTpl< _Scalar > ResidualModelContactCoPPositionTpl< _Scalar > ResidualModelContactControlGravTpl< _Scalar > ResidualModelContactForceTpl< _Scalar > ResidualModelContactFrictionConeTpl< _Scalar > ResidualModelContactWrenchConeTpl< _Scalar > ResidualModelControlGravTpl< _Scalar > ResidualModelControlTpl< _Scalar > ResidualModelFramePlacementTpl< _Scalar > ResidualModelFrameRotationTpl< _Scalar > ResidualModelFrameTranslationTpl< _Scalar > ResidualModelFrameVelocityTpl< _Scalar > ResidualModelImpulseCoMTpl< _Scalar > ResidualModelJointAccelerationTpl< _Scalar > ResidualModelJointEffortTpl< _Scalar > ResidualModelNumDiffTpl< _Scalar > ResidualModelStateTpl< _Scalar >

Public Types

typedef ActivationDataAbstractTpl< Scalar > ActivationDataAbstract
 
typedef CostDataAbstractTpl< Scalar > CostDataAbstract
 
typedef DataCollectorAbstractTpl< Scalar > DataCollectorAbstract
 
typedef MathBase::DiagonalMatrixXs DiagonalMatrixXs
 
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 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 std::size_t nu, const bool q_dependent=true, const bool v_dependent=true, const bool u_dependent=true)
 Initialize the residual model. More...
 
virtual void calc (const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 Compute the residual vector for nodes that depends only on the state. More...
 
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...
 
virtual void calcCostDiff (const boost::shared_ptr< CostDataAbstract > &cdata, const boost::shared_ptr< ResidualDataAbstract > &rdata, const boost::shared_ptr< ActivationDataAbstract > &adata, const bool update_u=true)
 Compute the derivative of the cost function. More...
 
virtual void calcDiff (const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 Compute the Jacobian of the residual functions with respect to the state only. More...
 
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...
 
virtual boost::shared_ptr< ResidualDataAbstractcreateData (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_
 
boost::shared_ptr< StateAbstractstate_
 State description.
 
bool u_dependent_
 
VectorXs unone_
 No control vector.
 
bool v_dependent_
 

Friends

template<class Scalar >
std::ostream & operator<< (std::ostream &os, const ResidualModelAbstractTpl< Scalar > &model)
 Print information on the residual model.
 

Detailed Description

template<typename _Scalar>
class crocoddyl::ResidualModelAbstractTpl< _Scalar >

Abstract class for residual models.

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 to note that calcDiff() computes the Jacobians using the latest stored values by calc(). Thus, we need to first run calc().

See also
StateAbstractTpl, calc(), calcDiff(), createData()

Definition at line 44 of file residual-base.hpp.

Constructor & Destructor Documentation

◆ ResidualModelAbstractTpl() [1/2]

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.

Parameters
[in]stateState of the system
[in]nrDimension of residual vector
[in]nuDimension of control vector
[in]q_dependentDefine if the residual function depends on q (default true)
[in]v_dependentDefine if the residual function depends on v (default true)
[in]u_dependentDefine if the residual function depends on u (default true)

◆ ResidualModelAbstractTpl() [2/2]

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().

Parameters
[in]stateState of the system
[in]nrDimension of residual vector
[in]q_dependentDefine if the residual function depends on q (default true)
[in]v_dependentDefine if the residual function depends on v (default true)
[in]u_dependentDefine if the residual function depends on u (default true)

Member Function Documentation

◆ calc() [1/2]

◆ calc() [2/2]

virtual void calc ( const boost::shared_ptr< ResidualDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x 
)
virtual

◆ calcDiff() [1/2]

◆ calcDiff() [2/2]

virtual void calcDiff ( const boost::shared_ptr< ResidualDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x 
)
virtual

Compute the Jacobian of the residual functions with respect to the state only.

It updates the Jacobian of the residual function based on the state only. This function is used in the terminal nodes of an optimal control problem.

Parameters
[in]dataResidual data
[in]xState point \(\mathbf{x}\in\mathbb{R}^{ndx}\)

Reimplemented in ResidualModelControlGravTpl< _Scalar >, ResidualModelContactWrenchConeTpl< _Scalar >, ResidualModelContactFrictionConeTpl< _Scalar >, ResidualModelContactForceTpl< _Scalar >, ResidualModelContactCoPPositionTpl< _Scalar >, ResidualModelContactControlGravTpl< _Scalar >, ResidualModelJointEffortTpl< _Scalar >, DifferentialActionModelFreeInvDynamicsTpl< _Scalar >::ResidualModelActuation, DifferentialActionModelContactInvDynamicsTpl< _Scalar >::ResidualModelContact, and DifferentialActionModelContactInvDynamicsTpl< _Scalar >::ResidualModelActuation.

◆ createData()

◆ calcCostDiff()

virtual void calcCostDiff ( const boost::shared_ptr< CostDataAbstract > &  cdata,
const boost::shared_ptr< ResidualDataAbstract > &  rdata,
const boost::shared_ptr< ActivationDataAbstract > &  adata,
const bool  update_u = true 
)
virtual

Compute the derivative of the cost function.

This function assumes that the derivatives of the activation and residual are computed via calcDiff functions.

Parameters
cdataCost data
rdataResidual data
adataActivation data
update_uUpdate the derivative of the cost function w.r.t. to the control if True.

Reimplemented in ResidualModelStateTpl< _Scalar >, and ResidualModelControlTpl< _Scalar >.

◆ print()

Member Data Documentation

◆ q_dependent_

bool q_dependent_
protected

Label that indicates if the residual function depends on q

Definition at line 229 of file residual-base.hpp.

◆ v_dependent_

bool v_dependent_
protected

Label that indicates if the residual function depends on v

Definition at line 231 of file residual-base.hpp.

◆ u_dependent_

bool u_dependent_
protected

Label that indicates if the residual function depends on u

Definition at line 233 of file residual-base.hpp.


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