33 void SystemDynamicsInterface::getLinearA(
const StateVector& x0,
const ControlVector& u0, Eigen::MatrixXd&
A)
const
35 assert(getStateDimension() == x0.size());
36 assert(getInputDimension() == u0.size());
37 assert(
A.rows() == x0.size());
38 assert(
A.cols() == x0.size());
42 auto inc = [&
x](
int idx,
double inc) {
x[idx] += inc; };
43 auto eval = [&,
this](StateVector& values) { dynamics(
x, u0, values); };
44 _linearization_method->computeJacobian2(inc, eval,
A);
47 void SystemDynamicsInterface::getLinearB(
const StateVector& x0,
const ControlVector& u0, Eigen::MatrixXd&
B)
const
49 assert(getStateDimension() == x0.size());
50 assert(getInputDimension() == u0.size());
51 assert(
B.rows() == x0.size());
52 assert(
B.cols() == u0.size());
56 auto inc = [&u](
int idx,
double inc) { u[idx] += inc; };
57 auto eval = [&,
this](StateVector& values) { dynamics(x0, u, values); };
58 _linearization_method->computeJacobian2(inc, eval,
B);
61 void SystemDynamicsInterface::setLinearizationMethod(std::shared_ptr<FiniteDifferencesInterface> lin_method) { _linearization_method = lin_method; }
63 #ifdef MESSAGE_SUPPORT
64 void SystemDynamicsInterface::toMessage(corbo::messages::SystemDynamics& message)
const
66 message.set_deadtime(_deadtime);
67 _linearization_method->toMessage(*message.mutable_linearization_method());
70 void SystemDynamicsInterface::fromMessage(
const corbo::messages::SystemDynamics& message, std::stringstream* issues)
72 if (message.deadtime() >= 0)
74 _deadtime = message.deadtime();
78 if (issues) *issues <<
"Deadtime must be >= 0" << std::endl;
82 _linearization_method->fromMessage(message.linearization_method(), issues);