48 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR =
double>
49 class AutoDiffLinearizer :
public LinearSystem<STATE_DIM, CONTROL_DIM, SCALAR>
52 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
56 typedef CppAD::AD<SCALAR> ADScalar;
57 typedef ControlledSystem<STATE_DIM, CONTROL_DIM, ADScalar> system_t;
58 typedef DynamicsLinearizerAD<STATE_DIM, CONTROL_DIM, ADScalar, ADScalar>
64 typedef typename Base::state_control_matrix_t state_control_matrix_t;
70 AutoDiffLinearizer(std::shared_ptr<system_t> nonlinearSystem)
71 : Base(nonlinearSystem->getType()),
72 dFdx_(state_matrix_t::Zero()),
73 dFdu_(state_control_matrix_t::Zero()),
74 nonlinearSystem_(nonlinearSystem),
75 linearizer_(std::bind(&system_t::computeControlledDynamics,
76 nonlinearSystem_.get(),
77 std::placeholders::_1,
78 std::placeholders::_2,
79 std::placeholders::_3,
80 std::placeholders::_4))
85 AutoDiffLinearizer(
const AutoDiffLinearizer& arg)
86 : Base(arg.nonlinearSystem_->getType()),
89 nonlinearSystem_(arg.nonlinearSystem_->clone()),
90 linearizer_(std::bind(&system_t::computeControlledDynamics,
91 nonlinearSystem_.get(),
92 std::placeholders::_1,
93 std::placeholders::_2,
94 std::placeholders::_3,
95 std::placeholders::_4))
100 virtual ~AutoDiffLinearizer() {}
102 AutoDiffLinearizer<STATE_DIM, CONTROL_DIM, SCALAR>* clone()
const override 104 return new AutoDiffLinearizer<STATE_DIM, CONTROL_DIM, SCALAR>(*this);
121 virtual const state_matrix_t& getDerivativeState(
const state_vector_t& x,
122 const control_vector_t& u,
125 dFdx_ = linearizer_.getDerivativeState(x, u, t);
144 virtual const state_control_matrix_t& getDerivativeControl(
const state_vector_t& x,
145 const control_vector_t& u,
148 dFdu_ = linearizer_.getDerivativeControl(x, u, t);
154 state_matrix_t dFdx_;
155 state_control_matrix_t dFdu_;
157 std::shared_ptr<system_t> nonlinearSystem_;
159 linearizer_t linearizer_;
interface class for a general linear system or linearized system
Definition: LinearSystem.h:23
Eigen::Matrix< double, nControls, 1 > control_vector_t
CppAD::AD< CppAD::cg::CG< double > > SCALAR
Eigen::Matrix< double, nStates, nStates > state_matrix_t
Eigen::Matrix< double, nStates, 1 > state_vector_t