Template Class ResidualModelContactControlGravTpl

Inheritance Relationships

Base Type

Class Documentation

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

Control gravity residual under contact.

This residual function is defined as \(\mathbf{r}=\mathbf{u}-(\mathbf{g}(\mathbf{q}) - \sum \mathbf{J}_c(\mathbf{q})^{\top} \mathbf{f}_c)\), where \(\mathbf{u}\in~\mathbb{R}^{nu}\) is the current control input, \(\mathbf{J}_c(\mathbf{q})\) is the contact Jacobians, \(\mathbf{f}_c\) contains the contact forces, \(\mathbf{g}(\mathbf{q})\) is the gravity torque corresponding to the current configuration, \(\mathbf{q}\in~\mathbb{R}^{nq}\) is the current position joints input. Note that the dimension of the residual vector is obtained from state->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 ResidualDataContactControlGravTpl<Scalar> Data
typedef ResidualDataAbstractTpl<Scalar> ResidualDataAbstract
typedef StateMultibodyTpl<Scalar> StateMultibody
typedef ActuationModelAbstractTpl<Scalar> ActuationModelAbstract
typedef DataCollectorAbstractTpl<Scalar> DataCollectorAbstract
typedef MathBase::VectorXs VectorXs
typedef MathBase::MatrixXs MatrixXs

Public Functions

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

Initialize the contact control gravity contact residual model.

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

  • nu[in] Dimension of the control vector

explicit ResidualModelContactControlGravTpl(std::shared_ptr<StateMultibody> state)

Initialize the contact control gravity contact residual model.

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

Parameters:

state[in] State of the multibody system

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

Parameters:
  • data[in] Contact control gravity 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 (i.e., it ignores the contact forces). 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 contact control gravity contact residual.

Parameters:
  • data[in] Contact control gravity 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

Compute the Jacobian of the residual functions with respect to the state only.

It updates the Jacobian of the residual function based on the state only (i.e., it ignores the contact forces). 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 std::shared_ptr<ResidualDataAbstract> createData(DataCollectorAbstract *const data) override

Create the contact-control-gravity residual data.

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

Cast the contact-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:

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

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

Print relevant information of the contact-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