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_DUMMYDCMESTIMATOR_DCM_COMPUTATION \
35 "DummyDcmEstimator: dcm computation "
37 #define INPUT_SIGNALS m_omegaSIN << m_massSIN << m_comSIN << m_momentaSIN
39 #define OUTPUT_SIGNALS m_dcmSOUT
53 CONSTRUCT_SIGNAL_IN(
omega, double),
54 CONSTRUCT_SIGNAL_IN(
mass, double),
58 m_initSucceeded(false) {
64 docCommandVoid0(
"Initialize the entity.")));
68 if (!m_omegaSIN.isPlugged())
69 return SEND_MSG(
"Init failed: signal omega is not plugged", MSG_TYPE_ERROR);
70 if (!m_massSIN.isPlugged())
71 return SEND_MSG(
"Init failed: signal mass is not plugged", MSG_TYPE_ERROR);
72 if (!m_comSIN.isPlugged())
73 return SEND_MSG(
"Init failed: signal com is not plugged", MSG_TYPE_ERROR);
74 if (!m_momentaSIN.isPlugged())
75 return SEND_MSG(
"Init failed: signal momenta is not plugged",
86 if (!m_initSucceeded) {
87 SEND_WARNING_STREAM_MSG(
88 "Cannot compute signal com_dcom before initialization!");
91 if (s.size() != 3) s.resize(3);
95 const double&
omega = m_omegaSIN(iter);
96 const double&
mass = m_massSIN(iter);
97 const Vector& com = m_comSIN(iter);
98 const Vector& momenta = m_momentaSIN(iter);
100 assert(com.size() == 3 &&
"Unexpected size of signal com");
101 assert((momenta.size() == 3 || momenta.size() == 6) &&
102 "Unexpected size of signal momenta");
104 const Eigen::Vector3d dcom = momenta.head<3>() /
mass;
106 const Eigen::Vector3d dcm = com + dcom /
omega;
122 os <<
"DummyDcmEstimator " << getName();
124 getProfiler().report_all(3, os);
125 }
catch (ExceptionSignal e) {