Crocoddyl
 
Loading...
Searching...
No Matches
ConstraintModelNumDiffTpl< _Scalar > Class Template Reference

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

#include <constraint.hpp>

Inheritance diagram for ConstraintModelNumDiffTpl< _Scalar >:
ConstraintModelAbstractTpl< _Scalar >

Public Types

typedef ConstraintModelAbstractTpl< Scalar > Base
 
typedef ConstraintDataAbstractTpl< Scalar > ConstraintDataAbstract
 
typedef ConstraintDataNumDiffTpl< Scalar > Data
 
typedef DataCollectorAbstractTpl< Scalar > DataCollectorAbstract
 
typedef MathBaseTpl< Scalar > MathBase
 
typedef boost::function< void(const VectorXs &, const VectorXs &)> ReevaluationFunction
 
typedef MathBaseTpl< Scalar >::VectorXs VectorXs
 
- Public Types inherited from ConstraintModelAbstractTpl< _Scalar >
typedef ConstraintDataAbstractTpl< Scalar > ConstraintDataAbstract
 
typedef DataCollectorAbstractTpl< Scalar > DataCollectorAbstract
 
typedef MathBaseTpl< Scalar > MathBase
 
typedef ResidualModelAbstractTpl< Scalar > ResidualModelAbstract
 
typedef StateAbstractTpl< Scalar > StateAbstract
 
typedef MathBase::VectorXs VectorXs
 

Public Member Functions

 ConstraintModelNumDiffTpl (const std::shared_ptr< Base > &model)
 Initialize the numdiff constraint model.
 
virtual ~ConstraintModelNumDiffTpl ()
 Initialize the numdiff constraint model.
 
virtual void calc (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 
virtual void calc (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
 Compute the constraint value.
 
virtual void calcDiff (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 
virtual void calcDiff (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
 Compute the Jacobian of the constraint.
 
virtual std::shared_ptr< ConstraintDataAbstractcreateData (DataCollectorAbstract *const data)
 Create the constraint data.
 
const Scalar get_disturbance () const
 Return the disturbance constant used by the numerical differentiation routine.
 
const std::shared_ptr< Base > & get_model () const
 Return the original constraint 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.
 
- Public Member Functions inherited from ConstraintModelAbstractTpl< _Scalar >
 ConstraintModelAbstractTpl (std::shared_ptr< StateAbstract > state, const std::size_t ng, const std::size_t nh, const bool T_const=true)
 
 ConstraintModelAbstractTpl (std::shared_ptr< StateAbstract > state, const std::size_t nu, const std::size_t ng, const std::size_t nh, const bool T_const=true)
 the constraint model
 
 ConstraintModelAbstractTpl (std::shared_ptr< StateAbstract > state, std::shared_ptr< ResidualModelAbstract > residual, const std::size_t ng, const std::size_t nh)
 Initialize the constraint model.
 
virtual void calc (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 Compute the constraint value for nodes that depends only on the state.
 
virtual void calc (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0
 Compute the constraint value.
 
virtual void calcDiff (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x)
 Compute the Jacobian of the constraint with respect to the state only.
 
virtual void calcDiff (const std::shared_ptr< ConstraintDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0
 Compute the Jacobian of the constraint.
 
const VectorXs & get_lb () const
 Return the lower bound of the constraint.
 
std::size_t get_ng () const
 Return the number of inequality constraints.
 
std::size_t get_nh () const
 Return the number of equality constraints.
 
std::size_t get_nu () const
 Return the dimension of the control input.
 
const std::shared_ptr< ResidualModelAbstract > & get_residual () const
 Return the residual model.
 
const std::shared_ptr< StateAbstract > & get_state () const
 Return the state.
 
bool get_T_constraint () const
 Return true if the constraint is imposed in terminal nodes as well.
 
ConstraintType get_type () const
 Return the type of constraint.
 
const VectorXs & get_ub () const
 Return the upper bound of the constraint.
 
virtual void print (std::ostream &os) const
 Print relevant information of the constraint model.
 
void remove_bounds ()
 Remove the bounds of the constraint.
 
void update_bounds (const VectorXs &lower, const VectorXs &upper)
 Update the lower and upper bounds the upper bound of constraint.
 

Public Attributes

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

Protected Attributes

std::size_t nu_
 Control dimension.
 
std::shared_ptr< StateAbstractstate_
 State description.
 
VectorXs unone_
 No control vector.
 
- Protected Attributes inherited from ConstraintModelAbstractTpl< _Scalar >
VectorXs lb_
 Lower bound of the constraint.
 
std::size_t ng_
 Number of inequality constraints.
 
std::size_t nh_
 Number of equality constraints.
 
std::size_t nu_
 Control dimension.
 
std::shared_ptr< ResidualModelAbstractresidual_
 Residual model.
 
std::shared_ptr< StateAbstractstate_
 State description.
 
bool T_constraint_
 
ConstraintType type_
 Type of constraint: inequality=0, equality=1, both=2.
 
VectorXs ub_
 Upper bound of the constraint.
 
VectorXs unone_
 No control vector.
 

Detailed Description

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

This class computes the numerical differentiation of a constraint model.

It computes the Jacobian of the constraint model via numerical differentiation, i.e., \(\mathbf{g_x}\), \(\mathbf{g_u}\) and \(\mathbf{h_x}\), \(\mathbf{h_u}\), which denote the Jacobians of the inequality and equality constraints, respectively.

See also
ConstraintModelAbstractTpl(), calcDiff()

Definition at line 30 of file constraint.hpp.

Member Typedef Documentation

◆ ConstraintDataAbstract

template<typename _Scalar >
typedef ConstraintDataAbstractTpl<Scalar> ConstraintDataAbstract

Definition at line 35 of file constraint.hpp.

◆ Base

template<typename _Scalar >
typedef ConstraintModelAbstractTpl<Scalar> Base

Definition at line 36 of file constraint.hpp.

◆ Data

template<typename _Scalar >
typedef ConstraintDataNumDiffTpl<Scalar> Data

Definition at line 37 of file constraint.hpp.

◆ DataCollectorAbstract

template<typename _Scalar >
typedef DataCollectorAbstractTpl<Scalar> DataCollectorAbstract

Definition at line 38 of file constraint.hpp.

◆ MathBase

template<typename _Scalar >
typedef MathBaseTpl<Scalar> MathBase

Definition at line 39 of file constraint.hpp.

◆ VectorXs

template<typename _Scalar >
typedef MathBaseTpl<Scalar>::VectorXs VectorXs

Definition at line 40 of file constraint.hpp.

◆ ReevaluationFunction

template<typename _Scalar >
typedef boost::function<void(const VectorXs&, const VectorXs&)> ReevaluationFunction

Definition at line 42 of file constraint.hpp.

Constructor & Destructor Documentation

◆ ConstraintModelNumDiffTpl()

template<typename _Scalar >
ConstraintModelNumDiffTpl ( const std::shared_ptr< Base > &  model)
explicit

Initialize the numdiff constraint model.

Parameters
model

Member Function Documentation

◆ calc() [1/2]

template<typename _Scalar >
virtual void calc ( const std::shared_ptr< ConstraintDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x,
const Eigen::Ref< const VectorXs > &  u 
)
virtual

Compute the constraint value.

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

◆ calc() [2/2]

template<typename _Scalar >
virtual void calc ( const std::shared_ptr< ConstraintDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x 
)
virtual

◆ calcDiff() [1/2]

template<typename _Scalar >
virtual void calcDiff ( const std::shared_ptr< ConstraintDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x,
const Eigen::Ref< const VectorXs > &  u 
)
virtual

Compute the Jacobian of the constraint.

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

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

◆ calcDiff() [2/2]

template<typename _Scalar >
virtual void calcDiff ( const std::shared_ptr< ConstraintDataAbstract > &  data,
const Eigen::Ref< const VectorXs > &  x 
)
virtual

◆ createData()

template<typename _Scalar >
virtual std::shared_ptr< ConstraintDataAbstract > createData ( DataCollectorAbstract *const  data)
virtual

Create the constraint data.

The default data contains objects to store the values of the constraint, residual vector and their first derivatives. However, it is possible to specialize this function is we need to create additional data, for instance, to avoid dynamic memory allocation.

Parameters
dataData collector
Returns
the constraint data

Reimplemented from ConstraintModelAbstractTpl< _Scalar >.

◆ set_reevals()

template<typename _Scalar >
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.

Member Data Documentation

◆ Scalar

template<typename _Scalar >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar

Definition at line 34 of file constraint.hpp.

◆ nu_

template<typename _Scalar >
std::size_t nu_
protected

Control dimension.

Definition at line 254 of file constraint-base.hpp.

◆ state_

template<typename _Scalar >
std::shared_ptr<StateAbstract> state_
protected

State description.

Definition at line 248 of file constraint-base.hpp.

◆ unone_

template<typename _Scalar >
VectorXs unone_
protected

No control vector.

Definition at line 259 of file constraint-base.hpp.


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