19 #include <dynamic-graph/all-commands.h>
20 #include <dynamic-graph/command-bind.h>
21 #include <dynamic-graph/factory.h>
23 #include <sot/core/debug.hh>
24 #include <sot/core/stop-watch.hh>
28 namespace talos_balance {
29 namespace dg = ::dynamicgraph;
31 using namespace dg::command;
34 #define PROFILE_STATETRANSFORMATION_Q_COMPUTATION \
35 "State transformation q computation "
36 #define PROFILE_STATETRANSFORMATION_V_COMPUTATION \
37 "State transformation v computation "
39 #define INPUT_SIGNALS m_referenceFrameSIN << m_q_inSIN << m_v_inSIN
41 #define OUTPUT_SIGNALS m_qSOUT << m_vSOUT
55 CONSTRUCT_SIGNAL_IN(referenceFrame, MatrixHomogeneous),
59 m_referenceFrameSIN << m_q_inSIN),
61 m_referenceFrameSIN << m_v_inSIN),
62 m_initSucceeded(false) {
68 docCommandVoid0(
"Initialize the entity.")));
79 const size_t sz =
input.size();
80 if ((
size_t)(s.size()) != sz) s.resize(sz);
84 const MatrixHomogeneous& referenceFrame = m_referenceFrameSIN(iter);
87 const Eigen::Vector3d& euler =
input.segment<3>(3);
89 const double roll = euler[0];
90 const double pitch = euler[1];
91 const double yaw = euler[2];
93 Eigen::Quaterniond quat;
94 quat = Eigen::AngleAxisd(yaw, Eigen::Vector3d::UnitZ()) *
95 Eigen::AngleAxisd(pitch, Eigen::Vector3d::UnitY()) *
96 Eigen::AngleAxisd(roll, Eigen::Vector3d::UnitX());
99 M.linear() = quat.toRotationMatrix();
100 M.translation() =
input.head<3>();
103 MatrixHomogeneous res = referenceFrame * M;
106 s.head<3>() = res.translation();
108 s.segment<3>(3) = res.linear().eulerAngles(2, 1, 0).reverse();
110 if (sz > 6) s.tail(sz - 6) =
input.tail(sz - 6);
119 const size_t sz =
input.size();
120 if ((
size_t)(s.size()) != sz) s.resize(sz);
124 const MatrixHomogeneous& referenceFrame = m_referenceFrameSIN(iter);
127 s.head<3>() = referenceFrame.linear() *
input.head<3>();
129 s.segment<3>(3) = referenceFrame.linear() *
input.segment<3>(3);
131 if (sz > 6) s.tail(sz - 6) =
input.tail(sz - 6);
145 os <<
"StateTransformation " << getName();
147 getProfiler().report_all(3, os);
148 }
catch (ExceptionSignal e) {