crocoddyl  1.8.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, bool with_gauss_approx=false)
 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)
 Compute the next state and cost value. More...
 
virtual void calcDiff (const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
 Compute the derivatives of the dynamics and cost functions. More...
 
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)
 Initialize the action model. More...
 
virtual void calc (const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0
 Compute the next state and cost value. More...
 
void calc (const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 
virtual void calcDiff (const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0
 Compute the derivatives of the dynamics and cost functions. More...
 
void calcDiff (const boost::shared_ptr< ActionDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 
virtual bool checkData (const boost::shared_ptr< ActionDataAbstract > &data)
 Checks that a specific data belongs to this model.
 
bool get_has_control_limits () const
 Indicates if there are defined control limits.
 
std::size_t get_nr () const
 Return the dimension of the cost-residual vector.
 
std::size_t get_nu () const
 Return the dimension of the control input.
 
const boost::shared_ptr< StateAbstract > & get_state () const
 Return the state.
 
const VectorXs & get_u_lb () const
 Return the control lower bound.
 
const VectorXs & get_u_ub () const
 Return the control upper bound.
 
virtual void print (std::ostream &os) const
 Print relevant information of the action model. More...
 
virtual 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=Scalar(1e-9))
 Computes the quasic static commands. More...
 
VectorXs quasiStatic_x (const boost::shared_ptr< ActionDataAbstract > &data, const VectorXs &x, const std::size_t maxiter=100, const Scalar tol=Scalar(1e-9))
 
void set_u_lb (const VectorXs &u_lb)
 Modify the control lower bounds.
 
void set_u_ub (const VectorXs &u_ub)
 Modify the control upper bounds.
 

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 ()
 Update the status of the control limits (i.e. if there are defined 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 177 of file fwd.hpp.

Constructor & Destructor Documentation

◆ ActionModelNumDiffTpl()

ActionModelNumDiffTpl ( boost::shared_ptr< Base model,
bool  with_gauss_approx = false 
)
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

Compute the next state and cost value.

Parameters
[in]dataAction data
[in]xState point
[in]uControl input

◆ calcDiff()

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

Compute the derivatives of the dynamics and cost functions.

It computes the partial derivatives of the dynamical system and the cost function. It assumes that calc() has been run first. This function builds a linear-quadratic approximation of the action model (i.e. dynamical system and cost function).

Parameters
[in]dataAction data
[in]xState point
[in]uControl input

◆ 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_model()

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

Get the model_ object.

Returns
Base&

◆ get_disturbance()

const Scalar get_disturbance ( ) const

Get the disturbance_ object.

Returns
Scalar

◆ set_disturbance()

void set_disturbance ( const Scalar  disturbance)

Set the disturbance_ object.

Parameters
disturbanceis the value used to find the numerical derivative

◆ get_with_gauss_approx()

bool get_with_gauss_approx ( )

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

Returns
true
false

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