Template Class ResidualModelStateTpl

Inheritance Relationships

Base Type

Class Documentation

template<typename _Scalar>
class ResidualModelStateTpl : public crocoddyl::ResidualModelAbstractTpl<_Scalar>

State residual.

This residual function defines the state tracking as \(\mathbf{r}=\mathbf{x}\ominus\mathbf{x}^*\), where \(\mathbf{x},\mathbf{x}^*\in~\mathcal{X}\) are the current and reference states, respectively, which belong to the state manifold \(\mathcal{X}\). Note that the dimension of the residual vector is obtained from StateAbstract::get_ndx(). Furthermore, the Jacobians of the residual function are computed analytically.

As described in ResidualModelAbstractTpl(), the residual value and its derivatives are calculated by calc and calcDiff, respectively.

Public Types

typedef MathBaseTpl<Scalar> MathBase
typedef ResidualModelAbstractTpl<Scalar> Base
typedef StateMultibodyTpl<Scalar> StateMultibody
typedef ResidualDataAbstractTpl<Scalar> ResidualDataAbstract
typedef CostDataAbstractTpl<Scalar> CostDataAbstract
typedef ActivationDataAbstractTpl<Scalar> ActivationDataAbstract
typedef DataCollectorAbstractTpl<Scalar> DataCollectorAbstract
typedef MathBase::VectorXs VectorXs
typedef MathBase::MatrixXs MatrixXs

Public Functions

ResidualModelStateTpl(std::shared_ptr<typename Base::StateAbstract> state, const VectorXs &xref, const std::size_t nu)

Initialize the state residual model.

Parameters:
  • state[in] State of the multibody system

  • xref[in] Reference state

  • nu[in] Dimension of the control vector

ResidualModelStateTpl(std::shared_ptr<typename Base::StateAbstract> state, const VectorXs &xref)

Initialize the state residual model.

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

Parameters:
  • state[in] State of the multibody system

  • xref[in] Reference state

ResidualModelStateTpl(std::shared_ptr<typename Base::StateAbstract> state, const std::size_t nu)

Initialize the state residual model.

The default reference state is obtained from StateAbstractTpl::zero().

Parameters:
  • state[in] State of the multibody system

  • nu[in] Dimension of the control vector

ResidualModelStateTpl(std::shared_ptr<typename Base::StateAbstract> state)

Initialize the state residual model.

The default state reference is obtained from StateAbstractTpl::zero(), and nu from StateAbstractTpl::get_nv().

Parameters:
  • state[in] State of the multibody system

  • activation[in] Activation model

virtual ~ResidualModelStateTpl() = default
virtual void calc(const std::shared_ptr<ResidualDataAbstract> &data, const Eigen::Ref<const VectorXs> &x, const Eigen::Ref<const VectorXs> &u) override

Compute the state residual.

Parameters:
  • data[in] State residual data

  • x[in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)

  • u[in] Control input \(\mathbf{u}\in\mathbb{R}^{nu}\)

virtual void calcDiff(const std::shared_ptr<ResidualDataAbstract> &data, const Eigen::Ref<const VectorXs> &x, const Eigen::Ref<const VectorXs> &u) override

Compute the Jacobians of the state residual.

Parameters:
  • data[in] State residual data

  • x[in] State point \(\mathbf{x}\in\mathbb{R}^{ndx}\)

  • u[in] Control input \(\mathbf{u}\in\mathbb{R}^{nu}\)

virtual void calcCostDiff(const std::shared_ptr<CostDataAbstract> &cdata, const std::shared_ptr<ResidualDataAbstract> &rdata, const std::shared_ptr<ActivationDataAbstract> &adata, const bool update_u = true) override

Compute the derivative of the state-cost function and store it in cost data.

This function assumes that the derivatives of the activation and residual are computed via calcDiff functions.

Parameters:
  • cdata – Cost data

  • rdata – Residual data

  • adata – Activation data

  • update_u – Update the derivative of the cost function w.r.t. to the control if True.

template<typename NewScalar>
ResidualModelStateTpl<NewScalar> cast() const

Cast the state residual 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:

ResidualModelStateTpl<NewScalar> A residual model with the new scalar type.

const VectorXs &get_reference() const

Return the reference state.

void set_reference(const VectorXs &reference)

Modify the reference state.

virtual void print(std::ostream &os) const override

Print relevant information of the state residual.

Parameters:

os[out] Output stream object

Public Members

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar

Protected Attributes

std::size_t nr_

Residual vector dimension.

std::size_t nu_

Control dimension.

std::shared_ptr<StateAbstract> state_

State description.

bool u_dependent_

Label that indicates if the residual function depends on u