Template Class CostModelResidualTpl
Defined in File residual.hpp
Inheritance Relationships
Base Type
public crocoddyl::CostModelAbstractTpl< _Scalar >(Template Class CostModelAbstractTpl)
Class Documentation
-
template<typename _Scalar>
class CostModelResidualTpl : public crocoddyl::CostModelAbstractTpl<_Scalar> Residual-based cost.
This cost function uses a residual model to compute the cost, i.e.,
\[ cost = a(\mathbf{r}(\mathbf{x}, \mathbf{u})), \]where \(\mathbf{r}(\cdot)\) and \(a(\cdot)\) define the residual and activation functions, respectively.Note that we only compute the Jacobians of the residual function. Therefore, this cost model computes its Hessians through a Gauss-Newton approximation, e.g., \(\mathbf{l_{xu}} = \mathbf{R_x}^T \mathbf{A_{rr}} \mathbf{R_u} \), where \(\mathbf{R_x}\) and \(\mathbf{R_u}\) are the Jacobians of the residual function, and \(\mathbf{A_{rr}}\) is the Hessian of the activation model.
As described in
CostModelAbstractTpl(), the cost value and its derivatives are calculated bycalcandcalcDiff, respectively.See also
Public Types
-
typedef MathBaseTpl<Scalar> MathBase
-
typedef CostModelAbstractTpl<Scalar> Base
-
typedef CostDataResidualTpl<Scalar> Data
-
typedef CostDataAbstractTpl<Scalar> CostDataAbstract
-
typedef ResidualModelAbstractTpl<Scalar> ResidualModelAbstract
-
typedef ActivationModelAbstractTpl<Scalar> ActivationModelAbstract
-
typedef DataCollectorAbstractTpl<Scalar> DataCollectorAbstract
Public Functions
Initialize the residual cost model.
- Parameters:
state – [in] State of the multibody system
activation – [in] Activation model
residual – [in] Residual model
Initialize the residual cost model.
We use
ActivationModelQuadTplas a default activation model (i.e. \(a=\frac{1}{2}\|\mathbf{r}\|^2\)).- Parameters:
state – [in] State of the multibody system
residual – [in] Residual model
-
virtual ~CostModelResidualTpl() = default
Compute the residual cost.
- Parameters:
data – [in] Residual cost data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
u – [in] Control input \(\mathbf{u}\in\mathbb{R}^{nu}\)
Compute the residual cost based on state only.
It updates the total cost based on the state only. This function is used in the terminal nodes of an optimal control problem.
- Parameters:
data – [in] Residual cost data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
Compute the derivatives of the residual cost.
- Parameters:
data – [in] Residual cost 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 cost with respect to the state only.
It updates the Jacobian and Hessian of the cost function based on the state only. This function is used in the terminal nodes of an optimal control problem.
- Parameters:
data – [in] Residual cost data
x – [in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)
-
virtual std::shared_ptr<CostDataAbstract> createData(DataCollectorAbstract *const data) override
Create the residual cost data.
-
template<typename NewScalar>
CostModelResidualTpl<NewScalar> cast() const Cast the residual cost 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:
CostModelResidualTpl<NewScalar> A cost 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::shared_ptr<ActivationModelAbstract> activation_
Activation model.
-
std::size_t nu_
Control dimension.
-
std::shared_ptr<ResidualModelAbstract> residual_
Residual model.
-
std::shared_ptr<StateAbstract> state_
State description.
-
typedef MathBaseTpl<Scalar> MathBase