Residual-based cost. More...
#include <crocoddyl/core/costs/residual.hpp>
Public Types | |
typedef ActivationModelAbstractTpl< Scalar > | ActivationModelAbstract |
typedef CostModelAbstractTpl< Scalar > | Base |
typedef CostDataAbstractTpl< Scalar > | CostDataAbstract |
typedef CostDataResidualTpl< Scalar > | Data |
typedef DataCollectorAbstractTpl< Scalar > | DataCollectorAbstract |
typedef MathBaseTpl< Scalar > | MathBase |
typedef MathBase::MatrixXs | MatrixXs |
typedef ResidualModelAbstractTpl< Scalar > | ResidualModelAbstract |
typedef MathBase::VectorXs | VectorXs |
![]() | |
typedef ActivationModelAbstractTpl< Scalar > | ActivationModelAbstract |
typedef ActivationModelQuadTpl< Scalar > | ActivationModelQuad |
typedef CostDataAbstractTpl< Scalar > | CostDataAbstract |
typedef DataCollectorAbstractTpl< Scalar > | DataCollectorAbstract |
typedef MathBaseTpl< Scalar > | MathBase |
typedef MathBase::MatrixXs | MatrixXs |
typedef ResidualModelAbstractTpl< Scalar > | ResidualModelAbstract |
typedef StateAbstractTpl< Scalar > | StateAbstract |
typedef MathBase::VectorXs | VectorXs |
Public Member Functions | |
CostModelResidualTpl (boost::shared_ptr< typename Base::StateAbstract > state, boost::shared_ptr< ActivationModelAbstract > activation, boost::shared_ptr< ResidualModelAbstract > residual) | |
Initialize the residual cost model. More... | |
CostModelResidualTpl (boost::shared_ptr< typename Base::StateAbstract > state, boost::shared_ptr< ResidualModelAbstract > residual) | |
Initialize the residual cost model. More... | |
virtual void | calc (const boost::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x) |
Compute the residual cost based on state only. More... | |
virtual void | calc (const boost::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u) |
Compute the residual cost. More... | |
virtual void | calcDiff (const boost::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x) |
Compute the derivatives of the residual cost with respect to the state only. More... | |
virtual void | calcDiff (const boost::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u) |
Compute the derivatives of the residual cost. More... | |
virtual boost::shared_ptr< CostDataAbstract > | createData (DataCollectorAbstract *const data) |
Create the residual cost data. More... | |
virtual void | print (std::ostream &os) const |
Print relevant information of the cost-residual model. More... | |
![]() | |
CostModelAbstractTpl (boost::shared_ptr< StateAbstract > state, boost::shared_ptr< ActivationModelAbstract > activation) | |
CostModelAbstractTpl (boost::shared_ptr< StateAbstract > state, boost::shared_ptr< ActivationModelAbstract > activation, boost::shared_ptr< ResidualModelAbstract > residual) | |
Initialize the cost model. More... | |
CostModelAbstractTpl (boost::shared_ptr< StateAbstract > state, boost::shared_ptr< ActivationModelAbstract > activation, const std::size_t nu) | |
Initialize the cost model. More... | |
CostModelAbstractTpl (boost::shared_ptr< StateAbstract > state, boost::shared_ptr< ResidualModelAbstract > residual) | |
CostModelAbstractTpl (boost::shared_ptr< StateAbstract > state, const std::size_t nr) | |
CostModelAbstractTpl (boost::shared_ptr< StateAbstract > state, const std::size_t nr, const std::size_t nu) | |
virtual void | calc (const boost::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x) |
Compute the total cost value for nodes that depends only on the state. More... | |
virtual void | calc (const boost::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0 |
Compute the cost value and its residual vector. More... | |
virtual void | calcDiff (const boost::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x) |
Compute the Jacobian and Hessian of the cost functions with respect to the state only. More... | |
virtual void | calcDiff (const boost::shared_ptr< CostDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)=0 |
Compute the Jacobian and Hessian of cost and its residual vector. More... | |
virtual boost::shared_ptr< CostDataAbstract > | createData (DataCollectorAbstract *const data) |
Create the cost data. More... | |
const boost::shared_ptr< ActivationModelAbstract > & | get_activation () const |
Return the activation model. | |
std::size_t | get_nu () const |
Return the dimension of the control input. | |
template<class ReferenceType > | |
ReferenceType | get_reference () |
Return the cost reference. | |
const boost::shared_ptr< ResidualModelAbstract > & | get_residual () const |
Return the residual model. | |
const boost::shared_ptr< StateAbstract > & | get_state () const |
Return the state. | |
virtual void | print (std::ostream &os) const |
Print relevant information of the cost model. More... | |
template<class ReferenceType > | |
void | set_reference (ReferenceType ref) |
Modify the cost reference. | |
Public Attributes | |
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar | Scalar |
![]() | |
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar | Scalar |
Protected Attributes | |
boost::shared_ptr< ActivationModelAbstract > | activation_ |
Activation model. More... | |
std::size_t | nu_ |
Control dimension. More... | |
boost::shared_ptr< ResidualModelAbstract > | residual_ |
Residual model. More... | |
boost::shared_ptr< StateAbstract > | state_ |
State description. More... | |
VectorXs | unone_ |
No control vector. More... | |
![]() | |
boost::shared_ptr< ActivationModelAbstract > | activation_ |
Activation model. More... | |
std::size_t | nu_ |
Control dimension. More... | |
boost::shared_ptr< ResidualModelAbstract > | residual_ |
Residual model. More... | |
boost::shared_ptr< StateAbstract > | state_ |
State description. More... | |
VectorXs | unone_ |
No control vector. More... | |
Additional Inherited Members | |
![]() | |
virtual void | get_referenceImpl (const std::type_info &, void *) |
Return the cost reference. More... | |
virtual void | set_referenceImpl (const std::type_info &, const void *) |
Modify the cost reference. More... | |
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 by calc
and calcDiff
, respectively.
CostModelAbstractTpl
, calc()
, calcDiff()
, createData()
Definition at line 36 of file residual.hpp.
typedef MathBaseTpl<Scalar> MathBase |
Definition at line 41 of file residual.hpp.
typedef CostModelAbstractTpl<Scalar> Base |
Definition at line 42 of file residual.hpp.
typedef CostDataResidualTpl<Scalar> Data |
Definition at line 43 of file residual.hpp.
typedef CostDataAbstractTpl<Scalar> CostDataAbstract |
Definition at line 44 of file residual.hpp.
typedef ResidualModelAbstractTpl<Scalar> ResidualModelAbstract |
Definition at line 45 of file residual.hpp.
typedef ActivationModelAbstractTpl<Scalar> ActivationModelAbstract |
Definition at line 46 of file residual.hpp.
typedef DataCollectorAbstractTpl<Scalar> DataCollectorAbstract |
Definition at line 47 of file residual.hpp.
typedef MathBase::VectorXs VectorXs |
Definition at line 48 of file residual.hpp.
typedef MathBase::MatrixXs MatrixXs |
Definition at line 49 of file residual.hpp.
CostModelResidualTpl | ( | boost::shared_ptr< typename Base::StateAbstract > | state, |
boost::shared_ptr< ActivationModelAbstract > | activation, | ||
boost::shared_ptr< ResidualModelAbstract > | residual | ||
) |
Initialize the residual cost model.
[in] | state | State of the multibody system |
[in] | activation | Activation model |
[in] | residual | Residual model |
CostModelResidualTpl | ( | boost::shared_ptr< typename Base::StateAbstract > | state, |
boost::shared_ptr< ResidualModelAbstract > | residual | ||
) |
Initialize the residual cost model.
We use ActivationModelQuadTpl
as a default activation model (i.e. \(a=\frac{1}{2}\|\mathbf{r}\|^2\)).
[in] | state | State of the multibody system |
[in] | residual | Residual model |
|
virtual |
Compute the residual cost.
[in] | data | Residual cost data |
[in] | x | State point \(\mathbf{x}\in\mathbb{R}^{ndx}\) |
[in] | u | Control input \(\mathbf{u}\in\mathbb{R}^{nu}\) |
Implements CostModelAbstractTpl< _Scalar >.
|
virtual |
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.
[in] | data | Residual cost data |
[in] | x | State point \(\mathbf{x}\in\mathbb{R}^{ndx}\) |
Reimplemented from CostModelAbstractTpl< _Scalar >.
|
virtual |
Compute the derivatives of the residual cost.
[in] | data | Residual cost data |
[in] | x | State point \(\mathbf{x}\in\mathbb{R}^{ndx}\) |
[in] | u | Control input \(\mathbf{u}\in\mathbb{R}^{nu}\) |
Implements CostModelAbstractTpl< _Scalar >.
Reimplemented in CostModelControlTpl< _Scalar >, and CostModelStateTpl< _Scalar >.
|
virtual |
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.
[in] | data | Residual cost data |
[in] | x | State point \(\mathbf{x}\in\mathbb{R}^{ndx}\) |
Reimplemented from CostModelAbstractTpl< _Scalar >.
|
virtual |
Create the residual cost data.
Reimplemented from CostModelAbstractTpl< _Scalar >.
|
virtual |
Print relevant information of the cost-residual model.
[out] | os | Output stream object |
Reimplemented from CostModelAbstractTpl< _Scalar >.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar |
Definition at line 40 of file residual.hpp.
|
protected |
Activation model.
Definition at line 241 of file cost-base.hpp.
|
protected |
Control dimension.
Definition at line 243 of file cost-base.hpp.
|
protected |
Residual model.
Definition at line 242 of file cost-base.hpp.
|
protected |
State description.
Definition at line 240 of file cost-base.hpp.
|
protected |
No control vector.
Definition at line 244 of file cost-base.hpp.