Template Class ConstraintModelNumDiffTpl

Inheritance Relationships

Base Type

Class Documentation

template<typename _Scalar>
class ConstraintModelNumDiffTpl : public crocoddyl::ConstraintModelAbstractTpl<_Scalar>

This class computes the numerical differentiation of a constraint model.

It computes the Jacobian of the constraint model via numerical differentiation, i.e., \(\mathbf{g_x}\), \(\mathbf{g_u}\) and \(\mathbf{h_x}\), \(\mathbf{h_u}\), which denote the Jacobians of the inequality and equality constraints, respectively.

See also

ConstraintModelAbstractTpl(), calcDiff()

Public Types

typedef ConstraintDataAbstractTpl<Scalar> ConstraintDataAbstract
typedef ConstraintModelAbstractTpl<Scalar> Base
typedef ConstraintDataNumDiffTpl<Scalar> Data
typedef DataCollectorAbstractTpl<Scalar> DataCollectorAbstract
typedef MathBaseTpl<Scalar> MathBase
typedef MathBaseTpl<Scalar>::VectorXs VectorXs
typedef boost::function<void(const VectorXs&, const VectorXs&)> ReevaluationFunction

Public Functions

explicit ConstraintModelNumDiffTpl(const std::shared_ptr<Base> &model)

Initialize the numdiff constraint model.

Parameters:

model

virtual ~ConstraintModelNumDiffTpl() = default

Initialize the numdiff constraint model.

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

Compute the constraint value.

Parameters:
  • data[in] Constraint 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<ConstraintDataAbstract> &data, const Eigen::Ref<const VectorXs> &x) override
virtual void calcDiff(const std::shared_ptr<ConstraintDataAbstract> &data, const Eigen::Ref<const VectorXs> &x, const Eigen::Ref<const VectorXs> &u) override

Compute the Jacobian of the constraint.

It computes the Jacobian of the constraint function. It assumes that calc() has been run first.

Parameters:
  • data[in] Constraint 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<ConstraintDataAbstract> &data, const Eigen::Ref<const VectorXs> &x) override
virtual std::shared_ptr<ConstraintDataAbstract> createData(DataCollectorAbstract *const data) override

Create the constraint data.

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

Parameters:

data – Data collector

Returns:

the constraint data

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

Cast the constraint numdiff 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:

ConstraintModelNumDiffTpl<NewScalar> A constraint model with the new scalar type.

const std::shared_ptr<Base> &get_model() const

Return the original constraint model.

const Scalar get_disturbance() const

Return the disturbance constant used by the numerical differentiation routine.

void set_disturbance(const Scalar disturbance)

Modify the disturbance constant used by the numerical differentiation routine.

void set_reevals(const std::vector<ReevaluationFunction> &reevals)

Register functions that updates the shared data computed for a system rollout The updated data is used to evaluate of the gradient and Hessian.

Parameters:

reevals – are the registered functions.

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.

VectorXs unone_

No control vector.