Crocoddyl
ResidualModelNumDiffTpl< _Scalar > Class Template Reference

This class computes the numerical differentiation of a residual model. More...

#include <residual.hpp>

Inheritance diagram for ResidualModelNumDiffTpl< _Scalar >:
ResidualModelAbstractTpl< _Scalar >

Public Types

typedef ResidualModelAbstractTpl< Scalar > Base
 
typedef ResidualDataNumDiffTpl< Scalar > Data
 
typedef DataCollectorAbstractTpl< Scalar > DataCollectorAbstract
 
typedef MathBaseTpl< Scalar > MathBase
 
typedef MathBaseTpl< Scalar >::MatrixXs MatrixXs
 
typedef boost::function< void(const VectorXs &, const VectorXs &)> ReevaluationFunction
 
typedef ResidualDataAbstractTpl< Scalar > ResidualDataAbstract
 
typedef MathBaseTpl< Scalar >::VectorXs VectorXs
 
- Public Types inherited from ResidualModelAbstractTpl< _Scalar >
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

 ResidualModelNumDiffTpl (const boost::shared_ptr< Base > &model)
 Initialize the numdiff residual model. More...
 
virtual ~ResidualModelNumDiffTpl ()
 Initialize the numdiff residual model.
 
virtual void calc (const boost::shared_ptr< ResidualDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 
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 calcDiff (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...
 
virtual boost::shared_ptr< ResidualDataAbstractcreateData (DataCollectorAbstract *const data)
 Create the residual data. More...
 
const Scalar get_disturbance () const
 Return the disturbance constant used by the numerical differentiation routine.
 
const boost::shared_ptr< Base > & get_model () const
 Return the original residual model.
 
void set_disturbance (const Scalar disturbance)
 Modify the disturbance constant used by the numerical differentiation routine.
 
void set_reevals (const std::vector< ReevaluationFunction > &reevals)
 Register functions that updates the shared data computed for a system rollout The updated data is used to evaluate of the gradient and Hessian. More...
 
- Public Member Functions inherited from ResidualModelAbstractTpl< _Scalar >
 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...
 
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
 
- Public Attributes inherited from ResidualModelAbstractTpl< _Scalar >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
 

Protected Attributes

std::size_t nu_
 Control dimension.
 
boost::shared_ptr< StateAbstractstate_
 State description.
 
VectorXs unone_
 No control vector.
 
- Protected Attributes inherited from ResidualModelAbstractTpl< _Scalar >
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_
 

Detailed Description

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

This class computes the numerical differentiation of a residual model.

It computes the Jacobian of the residual model via numerical differentiation, i.e., \(\mathbf{R_x}\) and \(\mathbf{R_u}\) which denote the Jacobians of the residual function \(\mathbf{r}(\mathbf{x},\mathbf{u})\).

See also
ResidualModelAbstractTpl(), calcDiff()

Definition at line 29 of file residual.hpp.

Constructor & Destructor Documentation

◆ ResidualModelNumDiffTpl()

ResidualModelNumDiffTpl ( const boost::shared_ptr< Base > &  model)
explicit

Initialize the numdiff residual model.

Parameters
modelResidual model that we want to apply the numerical differentiation

Member Function Documentation

◆ calc() [1/2]

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

Compute the residual vector.

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

◆ calc() [2/2]

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

It updates the residual vector 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}\)

◆ calcDiff() [1/2]

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

Compute the Jacobian of the residual vector.

It computes the Jacobian the residual function. It assumes that calc() has been run first.

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

◆ calcDiff() [2/2]

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

◆ createData()

virtual boost::shared_ptr<ResidualDataAbstract> createData ( DataCollectorAbstract *const  data)
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 specialize this function if we need to create additional data, for instance, to avoid dynamic memory allocation.

Parameters
dataData collector
Returns
the residual data

Reimplemented from ResidualModelAbstractTpl< _Scalar >.

◆ set_reevals()

void set_reevals ( const std::vector< ReevaluationFunction > &  reevals)

Register functions that updates the shared data computed for a system rollout The updated data is used to evaluate of the gradient and Hessian.

Parameters
reevalsare the registered functions.

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