crocoddyl  1.3.0
Contact RObot COntrol by Differential DYnamic programming Library (Crocoddyl)
ActionModelNumDiffTpl< _Scalar > Class Template Reference

This class computes the numerical differentiation of an ActionModel. More...

#include <crocoddyl/core/numdiff/action.hpp>

Inheritance diagram for ActionModelNumDiffTpl< _Scalar >:
Collaboration diagram for ActionModelNumDiffTpl< _Scalar >:

Public Types

typedef ActionDataAbstractTpl< Scalar > ActionDataAbstract
 
typedef ActionModelAbstractTpl< Scalar > Base
 
typedef ActionDataNumDiffTpl< Scalar > Data
 
typedef MathBaseTpl< Scalar > MathBase
 
typedef MathBaseTpl< Scalar >::MatrixXs MatrixXs
 
typedef MathBaseTpl< Scalar >::VectorXs VectorXs
 
- Public Types inherited from ActionModelAbstractTpl< _Scalar >
typedef ActionDataAbstractTpl< Scalar > ActionDataAbstract
 
typedef MathBaseTpl< Scalar > MathBase
 
typedef StateAbstractTpl< Scalar > StateAbstract
 
typedef MathBase::VectorXs VectorXs
 

Public Member Functions

 ActionModelNumDiffTpl (boost::shared_ptr< Base > model)
 Construct a new ActionModelNumDiff object. More...
 
virtual ~ActionModelNumDiffTpl ()
 Destroy the ActionModelNumDiff object.
 
virtual void calc (const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
 
virtual void calcDiff (const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
 
virtual boost::shared_ptr< ActionDataAbstractcreateData ()
 Create a Data object from the given model. More...
 
const Scalar & get_disturbance () const
 Get the disturbance_ object. More...
 
const boost::shared_ptr< Base > & get_model () const
 Get the model_ object. More...
 
bool get_with_gauss_approx ()
 Identify if the Gauss approximation is going to be used or not. More...
 
void set_disturbance (const Scalar &disturbance)
 Set the disturbance_ object. More...
 
- Public Member Functions inherited from ActionModelAbstractTpl< _Scalar >
 ActionModelAbstractTpl (boost::shared_ptr< StateAbstract > state, const std::size_t &nu, const std::size_t &nr=0)
 
void calc (const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 
void calcDiff (const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 
bool const & get_has_control_limits () const
 
const std::size_t & get_nr () const
 
const std::size_t & get_nu () const
 
const boost::shared_ptr< StateAbstract > & get_state () const
 
const VectorXs & get_u_lb () const
 
const VectorXs & get_u_ub () const
 
void quasiStatic (const boost::shared_ptr< ActionDataAbstract > &data, Eigen::Ref< VectorXs > u, const Eigen::Ref< const VectorXs > &x, const std::size_t &maxiter=100, const Scalar &tol=1e-9)
 
VectorXs quasiStatic_x (const boost::shared_ptr< ActionDataAbstract > &data, const VectorXs &x, const std::size_t &maxiter=100, const Scalar &tol=1e-9)
 
void set_u_lb (const VectorXs &u_lb)
 
void set_u_ub (const VectorXs &u_ub)
 

Public Attributes

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
 
- Public Attributes inherited from ActionModelAbstractTpl< _Scalar >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
 

Additional Inherited Members

- Protected Member Functions inherited from ActionModelAbstractTpl< _Scalar >
void update_has_control_limits ()
 
- Protected Attributes inherited from ActionModelAbstractTpl< _Scalar >
bool has_control_limits_
 Indicates whether any of the control limits is finite.
 
std::size_t nr_
 Dimension of the cost residual.
 
std::size_t nu_
 Control dimension.
 
boost::shared_ptr< StateAbstractstate_
 Model of the state.
 
VectorXs u_lb_
 Lower control limits.
 
VectorXs u_ub_
 Upper control limits.
 
VectorXs unone_
 Neutral state.
 

Detailed Description

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

This class computes the numerical differentiation of an ActionModel.

It computes the same quantity as a normal model would do but using numerical differentiation. The subtility is in the computation of the Hessian of the cost. Let us consider that the ActionModel owns a cost residual. This means that the cost is the square of a residual \( l(x,u) = .5 r(x,u)**2 \), with \( r(x,u) \) being the residual vector. Therefore the derivatives of the cost \( l \) can be expressed in function of the derivatives of the residuals (Jacobians), denoted by \( R_x \) and \( R_u \). Which would be:

\begin{eqnarray*} L_x &=& R_x^T r \\ L_u &=& R_u^T r \\ L_{xx} &=& R_x^T R_x + R_{xx} r \end{eqnarray*}

with \( R_{xx} \) the derivatives of the Jacobian (i.e. not a matrix, but a dim-3 tensor). The Gauss approximation consists in neglecting these. So \( L_{xx} \sim R_x^T R_x \). Similarly for \( L_{xu} \sim R_x^T R_u \) and \( L_{uu} \sim R_u^T R_u \). The above set of equations becomes:

\begin{eqnarray*} L_x &=& R_x^T r \\ L_u &=& R_u^T r \\ L_{xx} &\sim& R_x^T R_x \\ L_{xu} &\sim& R_x^T R_u \\ L_{uu} &\sim& R_u^T R_u \end{eqnarray*}

In the case that the cost does not have a residual we set the Hessian to \( 0 \), i.e. \( L_{xx} = L_{xu} = L_{uu} = 0 \).

Definition at line 120 of file fwd.hpp.

Constructor & Destructor Documentation

◆ ActionModelNumDiffTpl()

ActionModelNumDiffTpl ( boost::shared_ptr< Base model)
explicit

Construct a new ActionModelNumDiff object.

Parameters
model

Member Function Documentation

◆ calc()

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

◆ calcDiff()

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

◆ createData()

virtual boost::shared_ptr<ActionDataAbstract> createData ( )
virtual

Create a Data object from the given model.

Returns
boost::shared_ptr<ActionDataAbstract>

Reimplemented from ActionModelAbstractTpl< _Scalar >.

◆ get_disturbance()

const Scalar& get_disturbance ( ) const

Get the disturbance_ object.

Returns
const Scalar&

◆ get_model()

const boost::shared_ptr<Base>& get_model ( ) const

Get the model_ object.

Returns
Base&

◆ get_with_gauss_approx()

bool get_with_gauss_approx ( )

Identify if the Gauss approximation is going to be used or not.

Returns
true
false

◆ set_disturbance()

void set_disturbance ( const Scalar &  disturbance)

Set the disturbance_ object.

Parameters
disturbanceis the value used to find the numerical derivative

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