Template Class DifferentialActionModelLQRTpl

Inheritance Relationships

Base Type

Class Documentation

template<typename _Scalar>
class DifferentialActionModelLQRTpl : public crocoddyl::DifferentialActionModelAbstractTpl<_Scalar>

Linear-quadratic regulator (LQR) differential action model.

A linear-quadratic regulator (LQR) action has a transition model of the form

\[ \begin{equation} \mathbf{\dot{v}} = \mathbf{A_q q + A_v v + B u + f}. \end{equation} \]
Its cost function is quadratic of the form:
\[\begin{split} \begin{equation} \ell(\mathbf{x},\mathbf{u}) = \begin{bmatrix}1 \\ \mathbf{x} \\ \mathbf{u}\end{bmatrix}^T \begin{bmatrix}0 & \mathbf{q}^T & \mathbf{r}^T \\ \mathbf{q} & \mathbf{Q} & \mathbf{N}^T \\ \mathbf{r} & \mathbf{N} & \mathbf{R}\end{bmatrix} \begin{bmatrix}1 \\ \mathbf{x} \\ \mathbf{u}\end{bmatrix} \end{equation} \end{split}\]
and the linear equality and inequality constraints has the form:
\[\begin{split} \begin{aligned} \mathbf{g(x,u)} = \mathbf{G}\begin{bmatrix} \mathbf{x} \\ \mathbf{u} \end{bmatrix} [x,u] + \mathbf{g} \leq \mathbf{0} &\mathbf{h(x,u)} = \mathbf{H}\begin{bmatrix} \mathbf{x} \\ \mathbf{u} \end{bmatrix} [x,u] + \mathbf{h} \end{aligned} \end{split}\]

Public Types

typedef MathBaseTpl<Scalar> MathBase
typedef DifferentialActionModelAbstractTpl<Scalar> Base
typedef DifferentialActionDataLQRTpl<Scalar> Data
typedef StateVectorTpl<Scalar> StateVector
typedef DifferentialActionDataAbstractTpl<Scalar> DifferentialActionDataAbstract
typedef MathBase::VectorXs VectorXs
typedef MathBase::MatrixXs MatrixXs

Public Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW CROCODDYL_DERIVED_CAST (DifferentialActionModelBase, DifferentialActionModelLQRTpl) typedef _Scalar Scalar
DifferentialActionModelLQRTpl(const MatrixXs &Aq, const MatrixXs &Av, const MatrixXs &B, const MatrixXs &Q, const MatrixXs &R, const MatrixXs &N)

Initialize the LQR action model.

Parameters:
  • Aq[in] Position matrix

  • Av[in] Velocity matrix

  • B[in] Input matrix

  • Q[in] State weight matrix

  • R[in] Input weight matrix

  • N[in] State-input weight matrix

DifferentialActionModelLQRTpl(const MatrixXs &Aq, const MatrixXs &Av, const MatrixXs &B, const MatrixXs &Q, const MatrixXs &R, const MatrixXs &N, const VectorXs &f, const VectorXs &q, const VectorXs &r)

Initialize the LQR action model.

Parameters:
  • Aq[in] Position matrix

  • Av[in] Velocity matrix

  • B[in] Input matrix

  • Q[in] State weight matrix

  • R[in] Input weight matrix

  • N[in] State-input weight matrix

  • f[in] Dynamics drift

  • q[in] State weight vector

  • r[in] Input weight vector

DifferentialActionModelLQRTpl(const MatrixXs &Aq, const MatrixXs &Av, const MatrixXs &B, const MatrixXs &Q, const MatrixXs &R, const MatrixXs &N, const MatrixXs &G, const MatrixXs &H, const VectorXs &f, const VectorXs &q, const VectorXs &r, const VectorXs &g, const VectorXs &h)

Initialize the LQR action model.

Parameters:
  • Aq[in] Position matrix

  • Av[in] Velocity matrix

  • B[in] Input matrix

  • Q[in] State weight matrix

  • R[in] Input weight matrix

  • N[in] State-input weight matrix

  • G[in] State-input inequality constraint matrix

  • H[in] State-input equality constraint matrix

  • f[in] Dynamics drift

  • q[in] State weight vector

  • r[in] Input weight vector

  • g[in] State-input inequality constraint bias

  • h[in] State-input equality constraint bias

DifferentialActionModelLQRTpl(const std::size_t nq, const std::size_t nu, const bool drift_free = true)

Initialize the LQR action model.

Parameters:
  • nq[in] Dimension of position vector

  • nu[in] Dimension of control vector

  • drif_free[in] Enable / disable the bias term of the linear dynamics (default true)

DifferentialActionModelLQRTpl(const DifferentialActionModelLQRTpl &copy)

Copy constructor.

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

Compute the system acceleration and cost value.

Parameters:
  • data[in] Differential action 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<DifferentialActionDataAbstract> &data, const Eigen::Ref<const VectorXs> &x) override

Compute the total cost value for nodes that depends only on the state.

It updates the total cost and the system acceleration is not updated as the control input is undefined. This function is used in the terminal nodes of an optimal control problem.

Parameters:
  • data[in] Differential action data

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

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

Compute the derivatives of the dynamics and cost functions.

It computes the partial derivatives of the dynamical system and the cost function. It assumes that calc() has been run first. This function builds a quadratic approximation of the time-continuous action model (i.e. dynamical system and cost function).

Parameters:
  • data[in] Differential action 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<DifferentialActionDataAbstract> &data, const Eigen::Ref<const VectorXs> &x) override

Compute the derivatives of the cost functions with respect to the state only.

It updates the derivatives of the cost function with respect to the state only. This function is used in the terminal nodes of an optimal control problem.

Parameters:
  • data[in] Differential action data

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

virtual std::shared_ptr<DifferentialActionDataAbstract> createData() override

Create the differential action data.

Returns:

the differential action data

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

Cast the differential-LQR 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:

DifferentialActionModelLQRTpl<NewScalar> A differential-action model with the new scalar type.

virtual bool checkData(const std::shared_ptr<DifferentialActionDataAbstract> &data) override

Checks that a specific data belongs to this model.

const MatrixXs &get_Aq() const

Return the position matrix.

const MatrixXs &get_Av() const

Return the velocity matrix.

const MatrixXs &get_B() const

Return the input matrix.

const VectorXs &get_f() const

Return the dynamics drift.

const MatrixXs &get_Q() const

Return the state weight matrix.

const MatrixXs &get_R() const

Return the input weight matrix.

const MatrixXs &get_N() const

Return the state-input weight matrix.

const MatrixXs &get_G() const

Return the state-input inequality constraint matrix.

const MatrixXs &get_H() const

Return the state-input equality constraint matrix.

const VectorXs &get_q() const

Return the state weight vector.

const VectorXs &get_r() const

Return the input weight vector.

const VectorXs &get_g() const

Return the state-input inequality constraint bias.

const VectorXs &get_h() const

Return the state-input equality constraint bias.

void set_LQR(const MatrixXs &Aq, const MatrixXs &Av, const MatrixXs &B, const MatrixXs &Q, const MatrixXs &R, const MatrixXs &N, const MatrixXs &G, const MatrixXs &H, const VectorXs &f, const VectorXs &q, const VectorXs &r, const VectorXs &g, const VectorXs &h)

Modify the LQR action model.

Parameters:
  • Aq[in] Position matrix

  • Av[in] Velocity matrix

  • B[in] Input matrix

  • Q[in] State weight matrix

  • R[in] Input weight matrix

  • N[in] State-input weight matrix

  • G[in] State-input inequality constraint matrix

  • H[in] State-input equality constraint matrix

  • f[in] Dynamics drift

  • q[in] State weight vector

  • r[in] Input weight vector

  • g[in] State-input inequality constraint bias

  • h[in] State-input equality constraint bias

DEPRECATED ("Use get_Aq", const MatrixXs &get_Fq() const { return get_Aq();}) DEPRECATED("Use get_Av"
inline const MatrixXs &get_Fv() const
DEPRECATED ("Use get_B", const MatrixXs &get_Fu() const { return get_B();}) DEPRECATED("Use get_f"
inline const VectorXs &get_f0() const
DEPRECATED ("Use get_q", const VectorXs &get_lx() const { return get_q();}) DEPRECATED("Use get_r"
inline const VectorXs &get_lu() const
DEPRECATED ("Use get_Q", const MatrixXs &get_Lxx() const { return get_Q();}) DEPRECATED("Use get_N"
inline const MatrixXs &get_Lxu() const
DEPRECATED ("Use get_R", const MatrixXs &get_Luu() const { return get_R();}) DEPRECATED("Use set_LQR"
inline void set_Fq(const MatrixXs &Aq)
DEPRECATED ("Use set_LQR", void set_Fv(const MatrixXs &Av) { set_LQR(Aq_, Av, B_, Q_, R_, N_, G_, H_, f_, q_, r_, g_, h_);}) DEPRECATED("Use set_LQR"
inline void set_Fu(const MatrixXs &B)
DEPRECATED ("Use set_LQR", void set_f0(const VectorXs &f) { set_LQR(Aq_, Av_, B_, Q_, R_, N_, G_, H_, f, q_, r_, g_, h_);}) DEPRECATED("Use set_LQR"
inline void set_lx(const VectorXs &q)
DEPRECATED ("Use set_LQR", void set_lu(const VectorXs &r) { set_LQR(Aq_, Av_, B_, Q_, R_, N_, G_, H_, f_, q_, r, g_, h_);}) DEPRECATED("Use set_LQR"
inline void set_Lxx(const MatrixXs &Q)
DEPRECATED ("Use set_LQR", void set_Lxu(const MatrixXs &N) { set_LQR(Aq_, Av_, B_, Q_, R_, N, G_, H_, f_, q_, r_, g_, h_);}) DEPRECATED("Use set_LQR"
inline void set_Luu(const MatrixXs &R)
virtual void print(std::ostream &os) const override

Print relevant information of the LQR model.

Parameters:

os[out] Output stream object

Public Static Functions

static DifferentialActionModelLQRTpl Random(const std::size_t nq, const std::size_t nu, const std::size_t ng = 0, const std::size_t nh = 0)

Create a random LQR model.

Parameters:
  • nq[in] Position dimension

  • nu[in] Control dimension

  • ng[in] Inequality constraint dimension (default 0)

  • nh[in] Equality constraint dimension (default 0)

Protected Attributes

std::size_t ng_

Number of inequality constraints.

std::size_t nh_

< Equality constraint dimension

std::size_t nu_

< Inequality constraint dimension

std::shared_ptr<StateAbstract> state_

< Control dimension