19 #include <dynamic-graph/all-commands.h>
20 #include <dynamic-graph/factory.h>
22 #include <sot/core/debug.hh>
23 #include <sot/core/stop-watch.hh>
27 namespace talos_balance {
28 namespace dg = ::dynamicgraph;
30 using namespace dg::command;
32 #define INPUT_SIGNALS \
33 m_phaseSIN << m_rightRollCoupledSIN << m_rightRollDecoupledSIN \
34 << m_rightPitchCoupledSIN << m_rightPitchDecoupledSIN \
35 << m_leftRollCoupledSIN << m_leftRollDecoupledSIN \
36 << m_leftPitchCoupledSIN << m_leftPitchDecoupledSIN
38 #define OUTPUT_SIGNALS \
39 m_selecLeftSOUT << m_selecRightSOUT << m_rightRollSOUT << m_rightPitchSOUT \
40 << m_leftRollSOUT << m_leftPitchSOUT
54 CONSTRUCT_SIGNAL_IN(phase, int),
63 CONSTRUCT_SIGNAL_OUT(selecLeft, Flags, m_phaseSIN),
64 CONSTRUCT_SIGNAL_OUT(selecRight, Flags, m_phaseSIN),
67 m_phaseSIN << m_rightRollCoupledSIN << m_rightRollDecoupledSIN),
70 m_phaseSIN << m_rightPitchCoupledSIN << m_rightPitchDecoupledSIN),
73 m_phaseSIN << m_leftRollCoupledSIN << m_leftRollDecoupledSIN),
76 m_phaseSIN << m_leftPitchCoupledSIN << m_leftPitchDecoupledSIN),
79 m_initSucceeded(false) {
84 docCommandVoid1(
"Initialize the entity.",
85 "Number of joints")));
98 if (!m_initSucceeded) {
99 SEND_WARNING_STREAM_MSG(
"Cannot compute selecLeft before initialization!");
103 const int& phase = m_phaseSIN(iter);
105 s = phase >= 0 ? m_ones : m_zeros;
111 if (!m_initSucceeded) {
112 SEND_WARNING_STREAM_MSG(
"Cannot compute selecRight before initialization!");
116 const int& phase = m_phaseSIN(iter);
118 s = phase <= 0 ? m_ones : m_zeros;
124 if (!m_initSucceeded) {
125 SEND_WARNING_STREAM_MSG(
"Cannot compute leftRoll before initialization!");
128 if (s.size() != 1) s.resize(1);
130 const int& phase = m_phaseSIN(iter);
131 const dg::Vector& leftRollCoupled = m_leftRollCoupledSIN(iter);
132 const dg::Vector& leftRollDecoupled = m_leftRollDecoupledSIN(iter);
135 s = leftRollDecoupled;
145 if (!m_initSucceeded) {
146 SEND_WARNING_STREAM_MSG(
"Cannot compute leftPitch before initialization!");
149 if (s.size() != 1) s.resize(1);
151 const int& phase = m_phaseSIN(iter);
152 const dg::Vector& leftPitchCoupled = m_leftPitchCoupledSIN(iter);
153 const dg::Vector& leftPitchDecoupled = m_leftPitchDecoupledSIN(iter);
156 s = leftPitchDecoupled;
158 s = leftPitchCoupled;
166 if (!m_initSucceeded) {
167 SEND_WARNING_STREAM_MSG(
"Cannot compute rightRoll before initialization!");
170 if (s.size() != 1) s.resize(1);
172 const int& phase = m_phaseSIN(iter);
173 const dg::Vector& rightRollCoupled = m_rightRollCoupledSIN(iter);
174 const dg::Vector& rightRollDecoupled = m_rightRollDecoupledSIN(iter);
177 s = rightRollDecoupled;
179 s = rightRollCoupled;
187 if (!m_initSucceeded) {
188 SEND_WARNING_STREAM_MSG(
"Cannot compute rightPitch before initialization!");
191 if (s.size() != 1) s.resize(1);
193 const int& phase = m_phaseSIN(iter);
194 const dg::Vector& rightPitchCoupled = m_rightPitchCoupledSIN(iter);
195 const dg::Vector& rightPitchDecoupled = m_rightPitchDecoupledSIN(iter);
198 s = rightPitchDecoupled;
200 s = rightPitchCoupled;
214 os <<
"AnkleJointSelector " << getName();
216 getProfiler().report_all(3, os);
217 }
catch (ExceptionSignal e) {