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_DUMMYWALKINGPATTERNGENERATOR_DCM_COMPUTATION \
35 "DummyWalkingPatternGenerator: dcm computation "
37 #define INPUT_SIGNALS \
38 m_omegaSIN << m_rhoSIN << m_phaseSIN << m_footLeftSIN << m_footRightSIN \
39 << m_waistSIN << m_comSIN << m_vcomSIN << m_acomSIN << m_zmpSIN \
40 << m_referenceFrameSIN
42 #define INNER_SIGNALS m_rfSINNER
44 #define OUTPUT_SIGNALS \
45 m_comDesSOUT << m_vcomDesSOUT << m_acomDesSOUT << m_dcmDesSOUT \
46 << m_zmpDesSOUT << m_footLeftDesSOUT << m_footRightDesSOUT \
47 << m_waistDesSOUT << m_omegaDesSOUT << m_rhoDesSOUT \
56 "DummyWalkingPatternGenerator");
62 const std::string&
name)
64 CONSTRUCT_SIGNAL_IN(
omega, double),
65 CONSTRUCT_SIGNAL_IN(rho, double),
66 CONSTRUCT_SIGNAL_IN(phase, int),
67 CONSTRUCT_SIGNAL_IN(footLeft, MatrixHomogeneous),
68 CONSTRUCT_SIGNAL_IN(footRight, MatrixHomogeneous),
69 CONSTRUCT_SIGNAL_IN(waist, MatrixHomogeneous),
74 CONSTRUCT_SIGNAL_IN(referenceFrame, MatrixHomogeneous),
75 CONSTRUCT_SIGNAL_INNER(
rf, MatrixHomogeneous, m_referenceFrameSIN),
77 m_comSIN << m_rfSINNER),
79 m_vcomSIN << m_rfSINNER),
81 m_acomSIN << m_rfSINNER),
83 m_omegaSIN << m_comDesSOUT << m_vcomDesSOUT),
85 m_omegaSIN << m_comDesSOUT << m_acomDesSOUT
86 << m_rfSINNER << m_zmpSIN),
87 CONSTRUCT_SIGNAL_OUT(footLeftDes, MatrixHomogeneous,
88 m_footLeftSIN << m_rfSINNER),
89 CONSTRUCT_SIGNAL_OUT(footRightDes, MatrixHomogeneous,
90 m_footRightSIN << m_rfSINNER),
91 CONSTRUCT_SIGNAL_OUT(waistDes, MatrixHomogeneous,
92 m_waistSIN << m_rfSINNER),
93 CONSTRUCT_SIGNAL_OUT(omegaDes, double, m_omegaSIN),
94 CONSTRUCT_SIGNAL_OUT(rhoDes, double, m_rhoSIN),
95 CONSTRUCT_SIGNAL_OUT(phaseDes, int, m_phaseSIN),
96 m_initSucceeded(false) {
102 docCommandVoid0(
"Initialize the entity.")));
107 return m.linear().transpose() * (v - m.translation());
111 MatrixHomogeneous m2) {
112 MatrixHomogeneous res;
113 res.linear() = m1.linear().transpose() * m2.linear();
115 m1.linear().transpose() * (m2.translation() - m1.translation());
126 if (!m_initSucceeded) {
127 SEND_WARNING_STREAM_MSG(
"Cannot compute signal rf before initialization!");
131 s = m_referenceFrameSIN.isPlugged() ? m_referenceFrameSIN(iter)
132 : MatrixHomogeneous::Identity();
138 if (!m_initSucceeded) {
139 SEND_WARNING_STREAM_MSG(
140 "Cannot compute signal comDes before initialization!");
143 if (s.size() != 3) s.resize(3);
145 const Vector& com = m_comSIN(iter);
146 const MatrixHomogeneous& referenceFrame = m_rfSINNER(iter);
148 assert(com.size() == 3 &&
"Unexpected size of signal com");
150 s = actInv(referenceFrame, com);
156 if (!m_initSucceeded) {
157 SEND_WARNING_STREAM_MSG(
158 "Cannot compute signal vcomDes before initialization!");
161 if (s.size() != 3) s.resize(3);
163 const Vector& vcom = m_vcomSIN(iter);
164 const MatrixHomogeneous& referenceFrame = m_rfSINNER(iter);
166 assert(vcom.size() == 3 &&
"Unexpected size of signal vcom");
168 s = referenceFrame.linear().transpose() * vcom;
174 if (!m_initSucceeded) {
175 SEND_WARNING_STREAM_MSG(
176 "Cannot compute signal acomDes before initialization!");
179 if (s.size() != 3) s.resize(3);
181 const Vector& acom = m_acomSIN(iter);
182 const MatrixHomogeneous& referenceFrame = m_rfSINNER(iter);
184 assert(acom.size() == 3 &&
"Unexpected size of signal acom");
186 s = referenceFrame.linear().transpose() * acom;
192 if (!m_initSucceeded) {
193 SEND_WARNING_STREAM_MSG(
194 "Cannot compute signal dcmDes before initialization!");
197 if (s.size() != 3) s.resize(3);
199 const double&
omega = m_omegaSIN(iter);
201 const Vector& vcomDes = m_vcomDesSOUT(iter);
209 if (!m_initSucceeded) {
210 SEND_WARNING_STREAM_MSG(
211 "Cannot compute signal zmpDes before initialization!");
214 if (s.size() != 3) s.resize(3);
218 if (m_zmpSIN.isPlugged()) {
219 const Vector& zmp = m_zmpSIN(iter);
220 const MatrixHomogeneous& referenceFrame = m_rfSINNER(iter);
224 zmpDes[2] = zmp.size() > 2 ? zmp[2] : 0.;
228 const double&
omega = m_omegaSIN(iter);
230 const Vector& acomDes = m_acomDesSOUT(iter);
242 if (!m_initSucceeded) {
243 SEND_WARNING_STREAM_MSG(
244 "Cannot compute signal footLeftDes before initialization!");
248 MatrixHomogeneous footLeft = m_footLeftSIN(iter);
250 const MatrixHomogeneous& referenceFrame = m_rfSINNER(iter);
252 s = actInv(referenceFrame, footLeft);
258 if (!m_initSucceeded) {
259 SEND_WARNING_STREAM_MSG(
260 "Cannot compute signal footRightDes before initialization!");
264 MatrixHomogeneous footRight = m_footRightSIN(iter);
266 const MatrixHomogeneous& referenceFrame = m_rfSINNER(iter);
268 s = actInv(referenceFrame, footRight);
274 if (!m_initSucceeded) {
275 SEND_WARNING_STREAM_MSG(
276 "Cannot compute signal waistDes before initialization!");
280 const MatrixHomogeneous& waist = m_waistSIN(iter);
281 const MatrixHomogeneous& referenceFrame = m_rfSINNER(iter);
283 s = actInv(referenceFrame, waist);
289 if (!m_initSucceeded) {
290 SEND_WARNING_STREAM_MSG(
291 "Cannot compute signal omegaDes before initialization!");
295 s = m_omegaSIN(iter);
300 if (!m_initSucceeded) {
301 SEND_WARNING_STREAM_MSG(
302 "Cannot compute signal rhoDes before initialization!");
311 if (!m_initSucceeded) {
312 SEND_WARNING_STREAM_MSG(
313 "Cannot compute signal phaseDes before initialization!");
317 s = m_phaseSIN(iter);
328 os <<
"DummyWalkingPatternGenerator " << getName();
330 getProfiler().report_all(3, os);
331 }
catch (ExceptionSignal e) {