Template Class ConstraintModelAbstractTpl
Defined in File constraint-base.hpp
Inheritance Relationships
Base Type
public crocoddyl::ConstraintModelBase(Class ConstraintModelBase)
Derived Types
public crocoddyl::ConstraintModelNumDiffTpl< _Scalar >(Template Class ConstraintModelNumDiffTpl)public crocoddyl::ConstraintModelResidualTpl< _Scalar >(Template Class ConstraintModelResidualTpl)
Class Documentation
-
template<typename _Scalar>
class ConstraintModelAbstractTpl : public crocoddyl::ConstraintModelBase Abstract class for constraint models.
A constraint model defines both: inequality \(\mathbf{g}(\mathbf{x}, \mathbf{u})\in\mathbb{R}^{ng}\) and equality \(\mathbf{h}(\mathbf{x}, \mathbf{u})\in\mathbb{R}^{nh}\) constraints. The constraint function depends on the state point \(\mathbf{x}\in\mathcal{X}\), which lies in the state manifold described with a
nx-tuple, its velocity \(\dot{\mathbf{x}}\in T_{\mathbf{x}}\mathcal{X}\) that belongs to the tangent space withndxdimension, and the control input \(\mathbf{u}\in\mathbb{R}^{nu}\).The main computations are carried out in
calc()andcalcDiff()routines.calc()computes the constraint residual andcalcDiff()computes the Jacobians of the constraint function. Concretely speaking,calcDiff()builds a linear approximation of the constraint function with the form: \(\mathbf{g_x}\in\mathbb{R}^{ng\times ndx}\), \(\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}\). Additionally, it is important to note thatcalcDiff()computes the derivatives using the latest stored values bycalc(). Thus, we need to first runcalc().See also
Subclassed by crocoddyl::ConstraintModelNumDiffTpl< _Scalar >, crocoddyl::ConstraintModelResidualTpl< _Scalar >
Public Types
-
typedef MathBaseTpl<Scalar> MathBase
-
typedef ConstraintDataAbstractTpl<Scalar> ConstraintDataAbstract
-
typedef StateAbstractTpl<Scalar> StateAbstract
-
typedef ResidualModelAbstractTpl<Scalar> ResidualModelAbstract
-
typedef DataCollectorAbstractTpl<Scalar> DataCollectorAbstract
Public Functions
Initialize the constraint model.
- Parameters:
state – [in] State of the multibody system
residual – [in] Residual model
ng – [in] Number of inequality constraints
nh – [in] Number of equality constraints
the constraint model
- Parameters:
state – [in] State of the multibody system
nu – [in] Dimension of control vector
ng – [in] Number of inequality constraints
nh – [in] Number of equality constraints
T_const – [in] True if this is a constraint in both running and terminal nodes. False if it is a constraint on running nodes only (default true)
The default
nuvalue is obtained fromStateAbstractTpl::get_nv().- Parameters:
state – [in] State of the multibody system
ng – [in] Number of inequality constraints
nh – [in] Number of equality constraints
T_const – [in] True if this is a constraint in both running and terminal nodes. False if it is a constraint on running nodes only (default true)
-
virtual ~ConstraintModelAbstractTpl() = default
Compute the constraint value.
- Parameters:
data – [in] Constraint data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
u – [in] Control input \(\mathbf{u}\in\mathbb{R}^{nu}\)
Compute the 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:
data – [in] Constraint data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
Compute the Jacobian of the constraint.
It computes the Jacobian of the constraint function. It assumes that
calc()has been run first.- Parameters:
data – [in] Constraint data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
u – [in] Control input \(\mathbf{u}\in\mathbb{R}^{nu}\)
Compute the Jacobian of the 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:
data – [in] Constraint data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
-
virtual std::shared_ptr<ConstraintDataAbstract> createData(DataCollectorAbstract *const data)
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:
data – Data collector
- Returns:
the constraint data
-
void update_bounds(const VectorXs &lower, const VectorXs &upper)
Update the lower and upper bounds the upper bound of constraint.
-
void remove_bounds()
Remove the bounds of the constraint.
-
const std::shared_ptr<StateAbstract> &get_state() const
Return the state.
-
const std::shared_ptr<ResidualModelAbstract> &get_residual() const
Return the residual model.
-
ConstraintType get_type() const
Return the type of constraint.
-
std::size_t get_nu() const
Return the dimension of the control input.
-
std::size_t get_ng() const
Return the number of inequality constraints.
-
std::size_t get_nh() const
Return the number of equality constraints.
-
bool get_T_constraint() const
Return true if the constraint is imposed in terminal nodes as well.
-
virtual void print(std::ostream &os) const
Print relevant information of the constraint model.
- Parameters:
os – [out] Output stream object
Public Members
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
Protected Functions
-
inline ConstraintModelAbstractTpl()
Protected Attributes
-
std::shared_ptr<StateAbstract> state_
State description.
-
std::shared_ptr<ResidualModelAbstract> residual_
Residual model.
-
ConstraintType type_
Type of constraint: inequality=0, equality=1, both=2.
-
std::size_t nu_
Control dimension.
-
std::size_t ng_
Number of inequality constraints.
-
std::size_t nh_
Number of equality constraints.
-
bool T_constraint_
Label that indicates if the constraint is imposed in terminal nodes as well
Friends
-
template<class Scalar>
friend std::ostream &operator<<(std::ostream &os, const CostModelAbstractTpl<Scalar> &model) Print information on the constraint model.
-
typedef MathBaseTpl<Scalar> MathBase