27 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR,
typename TIME>
28 class DynamicsLinearizerAD :
public internal::DynamicsLinearizerADBase<STATE_DIM, CONTROL_DIM, SCALAR, TIME>
31 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
33 typedef internal::DynamicsLinearizerADBase<STATE_DIM, CONTROL_DIM, SCALAR, TIME> Base;
35 typedef typename Base::OUT_SCALAR OUT_SCALAR;
41 typedef typename Base::state_control_matrix_t state_control_matrix_t;
43 typedef typename Base::dynamics_fct_t dynamics_fct_t;
49 DynamicsLinearizerAD(dynamics_fct_t dyn)
50 : Base(dyn), dynamics_fct_(dyn), dFdx_(state_matrix_t::Zero()), dFdu_(state_control_matrix_t::Zero())
55 DynamicsLinearizerAD(
const DynamicsLinearizerAD& rhs)
56 : Base(rhs.dynamics_fct_), dynamics_fct_(rhs.dynamics_fct_), dFdx_(rhs.dFdx_), dFdu_(rhs.dFdu_)
60 const state_matrix_t& getDerivativeState(
const state_vector_t& x,
const control_vector_t& u,
const TIME t = TIME(0))
66 const state_control_matrix_t& getDerivativeControl(
const state_vector_t& x,
67 const control_vector_t& u,
68 const TIME t = TIME(0))
80 void computeA(
const state_vector_t& x,
const control_vector_t& u)
82 Eigen::Matrix<OUT_SCALAR, Eigen::Dynamic, 1> input(STATE_DIM + CONTROL_DIM);
85 Eigen::Matrix<OUT_SCALAR, Eigen::Dynamic, 1> jac(this->A_entries);
87 this->f_.SparseJacobianForward(input, this->sparsityA_.sparsity(), this->sparsityA_.row(),
88 this->sparsityA_.col(), jac, this->sparsityA_.workJacobian());
90 Eigen::Map<Eigen::Matrix<OUT_SCALAR, STATE_DIM, STATE_DIM>> out(jac.data());
100 void computeB(
const state_vector_t& x,
const control_vector_t& u)
102 Eigen::Matrix<OUT_SCALAR, Eigen::Dynamic, 1> input(STATE_DIM + CONTROL_DIM);
105 Eigen::Matrix<OUT_SCALAR, Eigen::Dynamic, 1> jac(this->B_entries);
107 this->f_.SparseJacobianForward(input, this->sparsityB_.sparsity(), this->sparsityB_.row(),
108 this->sparsityB_.col(), jac, this->sparsityB_.workJacobian());
110 Eigen::Map<Eigen::Matrix<OUT_SCALAR, STATE_DIM, CONTROL_DIM>> out(jac.data());
116 dynamics_fct_t dynamics_fct_;
118 state_matrix_t dFdx_;
119 state_control_matrix_t dFdu_;
Eigen::Matrix< double, nControls, 1 > control_vector_t
Eigen::Matrix< double, nStates, nStates > state_matrix_t
Eigen::Matrix< double, nStates, 1 > state_vector_t