27 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR,
typename TIME>
31 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
39 typedef std::function<void(const state_vector_t&, const TIME&, const control_vector_t&, state_vector_t&)>
54 eps_ = sqrt(Eigen::NumTraits<SCALAR>::epsilon());
82 const state_matrix_t&
getDerivativeState(
const state_vector_t& x,
const control_vector_t& u,
const TIME t = TIME(0))
87 for (
size_t i = 0;
i < STATE_DIM;
i++)
94 state_vector_t x_perturbed = x;
95 x_perturbed(
i) = x_ph;
98 state_vector_t res_plus;
107 x_perturbed(
i) = x_mh;
109 state_vector_t res_minus;
112 dFdx_.col(
i) = (res_plus - res_minus) / (dxp + dxm);
138 const control_vector_t& u,
139 const TIME t = TIME(0))
144 for (
size_t i = 0;
i < CONTROL_DIM;
i++)
151 control_vector_t u_perturbed = u;
152 u_perturbed(
i) = u_ph;
155 state_vector_t res_plus;
164 u_perturbed(
i) = u_mh;
166 state_vector_t res_minus;
169 dFdu_.col(
i) = (res_plus - res_minus) / (dup + dum);
DynamicsLinearizerNumDiff(const DynamicsLinearizerNumDiff &rhs)
copy constructor
Definition: DynamicsLinearizerNumDiff.h:58
state_control_matrix_t dFdu_
Jacobian wrt input.
Definition: DynamicsLinearizerNumDiff.h:191
Definition: StateMatrix.h:12
std::function< void(const state_vector_t &, const TIME &, const control_vector_t &, state_vector_t &)> dynamics_fct_t
dynamics function signature
Definition: DynamicsLinearizerNumDiff.h:40
clear all close all load ct GNMSLog0 mat reformat t
DynamicsLinearizerNumDiff(dynamics_fct_t dyn, bool doubleSidedDerivative=true)
default constructor
Definition: DynamicsLinearizerNumDiff.h:49
Definition: ControlVector.h:12
bool doubleSidedDerivative_
flag if double sided numerical differentiation should be used
Definition: DynamicsLinearizerNumDiff.h:184
dynamics_fct_t dynamics_fct_
function handle to system dynamics
Definition: DynamicsLinearizerNumDiff.h:182
CppAD::AD< CppAD::cg::CG< double > > SCALAR
StateMatrix< STATE_DIM, SCALAR > state_matrix_t
state Jacobian type (A)
Definition: DynamicsLinearizerNumDiff.h:36
SCALAR eps_
perturbation for numerical differentiation
Definition: DynamicsLinearizerNumDiff.h:186
StateControlMatrix< STATE_DIM, CONTROL_DIM, SCALAR > state_control_matrix_t
control Jacobian type (B)
Definition: DynamicsLinearizerNumDiff.h:37
const state_control_matrix_t & getDerivativeControl(const state_vector_t &x, const control_vector_t &u, const TIME t=TIME(0))
get the Jacobian with respect to the input
Definition: DynamicsLinearizerNumDiff.h:137
state_matrix_t dFdx_
Jacobian wrt state.
Definition: DynamicsLinearizerNumDiff.h:190
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef StateVector< STATE_DIM, SCALAR > state_vector_t
state vector type
Definition: DynamicsLinearizerNumDiff.h:33
Definition: StateVector.h:12
const state_matrix_t & getDerivativeState(const state_vector_t &x, const control_vector_t &u, const TIME t=TIME(0))
get the Jacobian with respect to the state
Definition: DynamicsLinearizerNumDiff.h:82
ControlVector< CONTROL_DIM, SCALAR > control_vector_t
control vector type
Definition: DynamicsLinearizerNumDiff.h:34
Computes the linearization of a system dynamics function through numerical finite differencing...
Definition: DynamicsLinearizerNumDiff.h:28
bool getDoubleSidedDerivativeFlag() const
Definition: DynamicsLinearizerNumDiff.h:180
Definition: StateControlMatrix.h:12
state_vector_t res_ref_
reference result for numerical differentiation
Definition: DynamicsLinearizerNumDiff.h:193