Template Class ResidualModelControlGravTpl

Inheritance Relationships

Base Type

Class Documentation

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

Control gravity residual.

This residual function is defined as \(\mathbf{r}=\mathbf{u}-\mathbf{g}(\mathbf{q})\), where \(\mathbf{u}\in~\mathbb{R}^{nu}\) is the current control input, \(\mathbf{g}(\mathbf{q})\) is the gravity torque corresponding to the current configuration, \(\mathbf{q}\in~\mathbb{R}^{nq}\) the current position joints input. Note that the dimension of the residual vector is obtained from StateAbstractTpl::get_nv().

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

Public Types

typedef MathBaseTpl<Scalar> MathBase
typedef ResidualModelAbstractTpl<Scalar> Base
typedef ResidualDataControlGravTpl<Scalar> Data
typedef ResidualDataAbstractTpl<Scalar> ResidualDataAbstract
typedef StateMultibodyTpl<Scalar> StateMultibody
typedef DataCollectorAbstractTpl<Scalar> DataCollectorAbstract
typedef MathBase::VectorXs VectorXs
typedef MathBase::MatrixXs MatrixXs

Public Functions

ResidualModelControlGravTpl(std::shared_ptr<StateMultibody> state, const std::size_t nu)

Initialize the control gravity residual model.

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

  • nu[in] Dimension of control vector

ResidualModelControlGravTpl(std::shared_ptr<StateMultibody> state)

Initialize the control gravity residual model.

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

Parameters:

state[in] State of the multibody system

virtual ~ResidualModelControlGravTpl() = 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 control gravity residual.

Parameters:
  • data[in] Control residual data

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

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

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

Compute the residual vector for nodes that depends only on the state.

It updates the residual vector based on the state only. This function is used in the terminal nodes of an optimal control problem.

Parameters:
  • data[in] Residual data

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

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 control gravity residual.

Parameters:
  • data[in] Control 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) override
virtual std::shared_ptr<ResidualDataAbstract> createData(DataCollectorAbstract *const data) override

Create the residual data.

The default data contains objects to store the values of the residual vector and their Jacobians. However, it is possible to specialize this function if we need to create additional data, for instance, to avoid dynamic memory allocation.

Parameters:

data – Data collector

Returns:

the residual data

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

Cast the control-gravity 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:

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

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

Print relevant information of the control-grav residual.

Parameters:

os[out] Output stream object

Public Members

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar

Protected Attributes

std::size_t nu_

Control dimension.

std::shared_ptr<StateAbstract> state_

State description.

bool v_dependent_

Label that indicates if the residual function depends on v