Template Class ConstraintModelResidualTpl
Defined in File residual.hpp
Inheritance Relationships
Base Type
public crocoddyl::ConstraintModelAbstractTpl< _Scalar >(Template Class ConstraintModelAbstractTpl)
Class Documentation
-
template<typename _Scalar>
class ConstraintModelResidualTpl : public crocoddyl::ConstraintModelAbstractTpl<_Scalar> Residual-based constraint.
This constraint function uses a residual model to define equality / inequality constraint as
\[ \mathbf{\underline{r}} \leq \mathbf{r}(\mathbf{x}, \mathbf{u}) \leq \mathbf{\bar{r}} \]where \(\mathbf{r}(\cdot)\) describes the residual function, and \(\mathbf{\underline{r}}\), \(\mathbf{\bar{r}}\) are the lower and upper bounds, respectively. We can define element-wise equality constraints by defining the same value for both: lower and upper values. Additionally, if we do not define the bounds, then it is assumed that \(\mathbf{\underline{r}}=\mathbf{\bar{r}}=\mathbf{0}\).The main computations are carring out in
calcandcalcDiffroutines.calccomputes the constraint residual andcalcDiffcomputes the Jacobians of the constraint function. Concretely speaking,calcDiffbuilds 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 run firstcalc().See also
ConstraintModelAbstractTpl,calc(),calcDiff(),createData()Public Types
-
typedef MathBaseTpl<Scalar> MathBase
-
typedef ConstraintModelAbstractTpl<Scalar> Base
-
typedef ConstraintDataResidualTpl<Scalar> Data
-
typedef ConstraintDataAbstractTpl<Scalar> ConstraintDataAbstract
-
typedef ResidualModelAbstractTpl<Scalar> ResidualModelAbstract
-
typedef DataCollectorAbstractTpl<Scalar> DataCollectorAbstract
Public Functions
Initialize the residual constraint model as an inequality constraint.
- Parameters:
state – [in] State of the multibody system
residual – [in] Residual model
lower – [in] Lower bound (dimension of the residual vector)
upper – [in] Upper bound (dimension of the residual vector)
T_act – [in] False if we want to deactivate the residual at the terminal node (default true)
Initialize the residual constraint model as an equality constraint.
- Parameters:
state – [in] State of the multibody system
residual – [in] Residual model
T_act – [in] False if we want to deactivate the residual at the terminal node (default true)
-
virtual ~ConstraintModelResidualTpl() = default
Compute the residual constraint.
- Parameters:
data – [in] Residual constraint data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
u – [in] Control input \(\mathbf{u}\in\mathbb{R}^{nu}\)
Compute the residual constraint based on state only.
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] Residual constraint data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
Compute the derivatives of the residual constraint.
- Parameters:
data – [in] Residual constraint data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
u – [in] Control input \(\mathbf{u}\in\mathbb{R}^{nu}\)
Compute the derivatives of the residual constraint with respect to the state only.
It updates 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] Residual constraint data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
-
virtual std::shared_ptr<ConstraintDataAbstract> createData(DataCollectorAbstract *const data) override
Create the residual constraint data.
-
template<typename NewScalar>
ConstraintModelResidualTpl<NewScalar> cast() const Cast the residual constraint model to a different scalar type.
It is useful for operations requiring different precision or scalar types.
- Template Parameters:
NewScalar – The new scalar type to cast to.
- Returns:
ConstraintModelResidualTpl<NewScalar> A constraint model with the new scalar type.
-
virtual void print(std::ostream &os) const override
Print relevant information of the cost-residual model.
- Parameters:
os – [out] Output stream object
Public Members
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
Protected Attributes
-
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<ResidualModelAbstract> residual_
Residual model.
-
std::shared_ptr<StateAbstract> state_
State description.
-
bool T_constraint_
Label that indicates if the constraint is imposed in terminal nodes as well
-
ConstraintType type_
Type of constraint: inequality=0, equality=1, both=2.
-
typedef MathBaseTpl<Scalar> MathBase