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_SIMPLEREFERENCEFRAME_DCM_COMPUTATION \
35 "SimpleReferenceFrame: dcm computation "
37 #define INPUT_SIGNALS m_footLeftSIN << m_footRightSIN << m_resetSIN
39 #define OUTPUT_SIGNALS m_referenceFrameSOUT
47 "SimpleReferenceFrame");
54 CONSTRUCT_SIGNAL_IN(footLeft, MatrixHomogeneous),
55 CONSTRUCT_SIGNAL_IN(footRight, MatrixHomogeneous),
56 CONSTRUCT_SIGNAL_IN(reset, bool),
57 CONSTRUCT_SIGNAL_OUT(referenceFrame, MatrixHomogeneous,
58 m_footLeftSIN << m_footRightSIN << m_resetSIN),
60 m_initSucceeded(false) {
66 docCommandVoid1(
"Initialize the entity.",
74 if (isNameInRobotUtil(localName)) {
77 SEND_ERROR_STREAM_MSG(
78 "You should have a robotUtil pointer initialized before");
81 }
catch (
const std::exception& e) {
82 SEND_ERROR_STREAM_MSG(
"Init failed: Could load URDF :" +
97 if (!m_initSucceeded) {
98 SEND_WARNING_STREAM_MSG(
99 "Cannot compute signal referenceFrame before initialization!");
103 const MatrixHomogeneous& footLeft = m_footLeftSIN(iter);
104 const MatrixHomogeneous& footRight = m_footRightSIN(iter);
105 const bool reset = m_resetSIN.isPlugged() ? m_resetSIN(iter) :
false;
107 if (reset || m_first) {
108 Eigen::Vector3d centerTranslation =
109 (footLeft.translation() + footRight.translation()) / 2 +
111 centerTranslation[2] = 0;
113 m_referenceFrame.linear() = footRight.linear();
114 m_referenceFrame.translation() = centerTranslation;
118 s = m_referenceFrame;
130 os <<
"SimpleReferenceFrame " << getName();
132 getProfiler().report_all(3, os);
133 }
catch (ExceptionSignal e) {