Crocoddyl
ConstraintModelManagerTpl< _Scalar > Class Template Reference

Manage the individual constraint models. More...

#include <constraint-manager.hpp>

Public Types

typedef ConstraintDataAbstractTpl< Scalar > ConstraintDataAbstract
 
typedef std::map< std::string, boost::shared_ptr< ConstraintDataAbstract > > ConstraintDataContainer
 
typedef ConstraintDataManagerTpl< Scalar > ConstraintDataManager
 
typedef ConstraintItemTpl< Scalar > ConstraintItem
 
typedef ConstraintModelAbstractTpl< Scalar > ConstraintModelAbstract
 
typedef std::map< std::string, boost::shared_ptr< ConstraintItem > > ConstraintModelContainer
 
typedef DataCollectorAbstractTpl< Scalar > DataCollectorAbstract
 
typedef MathBaseTpl< Scalar > MathBase
 
typedef MathBase::MatrixXs MatrixXs
 
typedef StateAbstractTpl< Scalar > StateAbstract
 
typedef MathBase::VectorXs VectorXs
 

Public Member Functions

 ConstraintModelManagerTpl (boost::shared_ptr< StateAbstract > state)
 Initialize the constraint-manager model. More...
 
 ConstraintModelManagerTpl (boost::shared_ptr< StateAbstract > state, const std::size_t nu)
 Initialize the constraint-manager model. More...
 
void addConstraint (const std::string &name, boost::shared_ptr< ConstraintModelAbstract > constraint, const bool active=true)
 Add a constraint item. More...
 
void calc (const boost::shared_ptr< ConstraintDataManager > &data, const Eigen::Ref< const VectorXs > &x)
 Compute the total constraint value for nodes that depends only on the state. More...
 
void calc (const boost::shared_ptr< ConstraintDataManager > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
 Compute the total constraint value. More...
 
void calcDiff (const boost::shared_ptr< ConstraintDataManager > &data, const Eigen::Ref< const VectorXs > &x)
 Compute the Jacobian of the total constraint with respect to the state only. More...
 
void calcDiff (const boost::shared_ptr< ConstraintDataManager > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
 Compute the Jacobian of the total constraint. More...
 
void changeConstraintStatus (const std::string &name, bool active)
 Change the constraint status. More...
 
boost::shared_ptr< ConstraintDataManagercreateData (DataCollectorAbstract *const data)
 Create the constraint data. More...
 
const std::set< std::string > & get_active_set () const
 Return the names of the set of active constraints.
 
const ConstraintModelContainer & get_constraints () const
 Return the stack of constraint models.
 
const std::set< std::string > & get_inactive_set () const
 Return the names of the set of inactive constraints.
 
const VectorXs & get_lb () const
 Return the state lower bound.
 
std::size_t get_ng () const
 Return the number of active inequality constraints.
 
std::size_t get_nh () const
 Return the number of active equality constraints.
 
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_ub () const
 Return the state upper bound.
 
bool getConstraintStatus (const std::string &name) const
 Return the status of a given constraint name. More...
 
void removeConstraint (const std::string &name)
 Remove a constraint item. More...
 

Public Attributes

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
 

Friends

template<class Scalar >
std::ostream & operator<< (std::ostream &os, const ConstraintModelManagerTpl< Scalar > &model)
 Print information on the stack of constraints.
 

Detailed Description

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

Manage the individual constraint models.

This class serves to manage a set of added constraint models. The constraint functions might active or inactive, with this approach we avoid dynamic allocation of memory. Each constraint model is added through addConstraint, where its status can be defined.

The main computations are carring out in calc and calcDiff routines. calc computes the constraint residuals and calcDiff computes the Jacobians of the constraint functions. Concretely speaking, calcDiff builds a linear approximation of the total constraint function (both inequality and equality) with the form: \(\mathbf{g_u}\in\mathbb{R}^{ng\times nu}\), \(\mathbf{h_x}\in\mathbb{R}^{nh\times ndx}\) \(\mathbf{h_u}\in\mathbb{R}^{nh\times nu}\).

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

Definition at line 68 of file constraint-manager.hpp.

Constructor & Destructor Documentation

◆ ConstraintModelManagerTpl() [1/2]

ConstraintModelManagerTpl ( boost::shared_ptr< StateAbstract state,
const std::size_t  nu 
)

Initialize the constraint-manager model.

Parameters
[in]stateState of the multibody system
[in]nuDimension of control vector

◆ ConstraintModelManagerTpl() [2/2]

ConstraintModelManagerTpl ( boost::shared_ptr< StateAbstract state)
explicit

Initialize the constraint-manager model.

The default nu value is obtained from StateAbstractTpl::get_nv().

Parameters
[in]stateState of the multibody system

Member Function Documentation

◆ addConstraint()

void addConstraint ( const std::string &  name,
boost::shared_ptr< ConstraintModelAbstract constraint,
const bool  active = true 
)

Add a constraint item.

Parameters
[in]nameConstraint name
[in]constraintConstraint model
[in]weightConstraint weight
[in]activeTrue if the constraint is activated (default true)

◆ removeConstraint()

void removeConstraint ( const std::string &  name)

Remove a constraint item.

Parameters
[in]nameConstraint name

◆ changeConstraintStatus()

void changeConstraintStatus ( const std::string &  name,
bool  active 
)

Change the constraint status.

Parameters
[in]nameConstraint name
[in]activeConstraint status (true for active and false for inactive)

◆ calc() [1/2]

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

Compute the total 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]

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

Compute the total constraint value for nodes that depends only on the state.

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

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

◆ calcDiff() [1/2]

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

Compute the Jacobian of the total constraint.

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]

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

Compute the Jacobian of the total constraint with respect to the state only.

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

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

◆ createData()

boost::shared_ptr<ConstraintDataManager> createData ( DataCollectorAbstract *const  data)

Create the constraint data.

The default data contains objects to store the values of the constraint and their derivatives (i.e. Jacobians). 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

◆ getConstraintStatus()

bool getConstraintStatus ( const std::string &  name) const

Return the status of a given constraint name.

Parameters
[in]nameConstraint name

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