Main Page · Modules · All Classes · Class Hierarchy
MAMotionSkit.cpp
1 /*
2  * This file is part of the AiBO+ project
3  *
4  * Copyright (C) 2005-2016 Csaba Kertész (csaba.kertesz@gmail.com)
5  *
6  * AiBO+ is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * AiBO+ is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
19  *
20  */
21 
22 #include "MAMotionSkit.hpp"
23 
24 #include "core/MADevice.hpp"
25 #include "core/MAValueGenerators.hpp"
26 #include "MASkitDatabase.hpp"
27 
28 #include <MCContainers.hpp>
29 #include <MCThreadLocalData.hpp>
30 
31 #include <boost/algorithm/string.hpp>
32 #include <boost/math/constants/constants.hpp>
33 
34 namespace
35 {
36 // Joint name list
37 MCThreadLocalData<MC::StringList> JointNames(true);
38 
39 void CheckStaticMtnParserVariables()
40 {
41  if (unlikely(!JointNames.get()))
42  {
43  JointNames.reset(new MC::StringList);
44  }
45 }
46 }
47 
48 MAMotionSkit::MAMotionSkit() : MASkitBase(), SkitDuration(0)
49 {
50 }
51 
52 
53 std::string MAMotionSkit::GetName() const
54 {
55  return Name;
56 }
57 
58 
59 std::string MAMotionSkit::GetSkitName() const
60 {
61  MC::StringList Strs;
62  std::string TempStr;
63 
64  boost::split(Strs, Name, boost::is_any_of("#"));
65  TempStr = Strs[1];
66  boost::split(Strs, TempStr, boost::is_any_of("_"));
67  Strs.erase(Strs.begin());
68  TempStr = boost::algorithm::join(Strs, "_");
69  return TempStr;
70 }
71 
72 
74 {
75  return SkitDuration;
76 }
77 
78 
79 MA::MotionSkitSPtr MAMotionSkit::CloneMirrored() const
80 {
81  MA::MotionSkitSPtr NewMotionSkit(new MAMotionSkit);
82 
83  *NewMotionSkit = *this;
84  // Swap LegLF<->LegRF
85  MCSwapTableColumns<int, MC::IntTable>(NewMotionSkit->Keyframes, 7, 13);
86  MCSwapTableColumns<int, MC::IntTable>(NewMotionSkit->Keyframes, 8, 14);
87  MCSwapTableColumns<int, MC::IntTable>(NewMotionSkit->Keyframes, 9, 15);
88  // Swap LegLH<->LegRH
89  MCSwapTableColumns<int, MC::IntTable>(NewMotionSkit->Keyframes, 10, 16);
90  MCSwapTableColumns<int, MC::IntTable>(NewMotionSkit->Keyframes, 11, 17);
91  MCSwapTableColumns<int, MC::IntTable>(NewMotionSkit->Keyframes, 12, 18);
92  return NewMotionSkit;
93 }
94 
95 
96 void MAMotionSkit::Dump() const
97 {
98  MC_LOG("-- %s motion keyframes --", Name.c_str());
100  {
101  MC_LOG("Starting posture: SIT");
102  }
103  if (IsStartingPostureLie())
104  {
105  MC_LOG("Starting posture: LIE");
106  }
108  {
109  MC_LOG("Starting posture: STAND");
110  }
111  for (unsigned int i = 0; i < Keyframes.size(); ++i)
112  {
113  std::string Message;
114  int NeckTilt1 = 0;
115 
116  Message.append(">> Time: ");
117  Message.append(MCToStr(Keyframes[i][0]));
118  Message.append(" ms | ");
119  for (unsigned int i1 = 1; i1 < Keyframes[i].size(); ++i1)
120  {
121  Message.append((*JointNames)[i1-1]+": ");
122  if ((*JointNames)[i1-1].find("Leg") != std::string::npos)
123  {
124  if ((*JointNames)[i1-1].find("1") != std::string::npos)
125  {
126  MALegPosition Position;
127 
128  // The LegLH1/LegRH1 joint degree values are inverted for convenience.
129  // See also APDevice.cpp
130  if ((*JointNames)[i1-1] == "LegLH1" || (*JointNames)[i1-1] == "LegRH1")
131  {
132  Position.FromJointDegree(-Keyframes[i][i1]);
133  } else {
134  Position.FromJointDegree(Keyframes[i][i1]);
135  }
136  Message.append("FB "+MCToStr(MCToStr((int)Position.ForeBackValue))+',');
137  Message.append("UD "+MCToStr(MCToStr((int)Position.UpDownValue))+',');
138  Message.append("D "+MCToStr(Keyframes[i][i1]));
139  }
140  if ((*JointNames)[i1-1].find("2") != std::string::npos)
141  {
142  MASidelong Sidelong;
143 
144  Sidelong.FromJointDegree(Keyframes[i][i1]);
145  Message.append("SL "+MCToStr(MCToStr((int)Sidelong.Value))+',');
146  Message.append("D "+MCToStr(Keyframes[i][i1]));
147  }
148  if ((*JointNames)[i1-1].find("3") != std::string::npos)
149  {
150  MABentStretched BentStretched;
151 
152  BentStretched.FromJointDegree(Keyframes[i][i1]);
153  Message.append("BS "+MCToStr(MCToStr((int)BentStretched.Value))+',');
154  Message.append("D "+MCToStr(Keyframes[i][i1]));
155  }
156  } else
157  if ((*JointNames)[i1-1].find("Neck") != std::string::npos)
158  {
159  if ((*JointNames)[i1-1].find("NeckTilt1") != std::string::npos)
160  {
161  NeckTilt1 = Keyframes[i][i1];
162  Message.append(MCToStr(Keyframes[i][i1]));
163  } else
164  if ((*JointNames)[i1-1].find("NeckTilt2") != std::string::npos)
165  {
166  MAHeadPosition Position;
167 
168  Position.FromJointDegrees(NeckTilt1, Keyframes[i][i1]);
169  Message.append("FB "+MCToStr(MCToStr((int)Position.ForeBackValue))+',');
170  Message.append("UD "+MCToStr(MCToStr((int)Position.UpDownValue))+',');
171  Message.append("D "+MCToStr(Keyframes[i][i1]));
172  } else
173  if ((*JointNames)[i1-1].find("NeckPan") != std::string::npos)
174  {
175  MALeftRightTurned LeftRightTurned;
176 
177  LeftRightTurned.FromJointDegree(Keyframes[i][i1]);
178  Message.append("LR "+MCToStr(MCToStr((int)LeftRightTurned.Value))+',');
179  Message.append("D "+MCToStr(Keyframes[i][i1]));
180  }
181  } else
182  if ((*JointNames)[i1-1] == "Mouth")
183  {
184  MAMouthOpened MouthOpened;
185 
186  MouthOpened.FromJointDegree(Keyframes[i][i1]);
187  Message.append("OC "+MCToStr(MCToStr((int)MouthOpened.Value))+',');
188  Message.append("D "+MCToStr(Keyframes[i][i1]));
189  } else {
190  Message.append(MCToStr(Keyframes[i][i1]));
191  }
192  if (i1 < Keyframes[i].size()-1)
193  Message.append(" | ");
194  }
195  MC_LOG("%s", Message.c_str());
196  }
197  MC_LOG("Motion duration: %d msec", GetDuration());
198  if (IsFinishingPostureSit())
199  {
200  MC_LOG("Finishing posture: SIT");
201  } else
202  if (IsFinishingPostureLie())
203  {
204  MC_LOG("Finishing posture: LIE");
205  } else
207  {
208  MC_LOG("Finishing posture: STAND");
209  } else {
210  MC_LOG("Finishing posture: N/A");
211  }
212 }
213 
214 
216 {
217  return IsPostureSit(0);
218 }
219 
220 
222 {
223  return IsPostureSit(Keyframes.size()-1);
224 }
225 
226 
228 {
229  return IsPostureLie(0);
230 }
231 
232 
234 {
235  return IsPostureLie(Keyframes.size()-1);
236 }
237 
238 
240 {
241  return IsPostureStand(0);
242 }
243 
244 
246 {
247  return IsPostureStand(Keyframes.size()-1);
248 }
249 
250 
252 {
253  MCBinaryData& BinaryData = const_cast<MCBinaryData&>(binary_data);
254  int OldPosition = BinaryData.GetPosition();
255  std::string TempStr;
256  int TempInt = 0;
257  int BlockSize = 0;
258 
259  BinaryData.SetPosition(0);
260  // Test the file signature
261  if (BinaryData.GetString(4) != "OMTN")
262  {
263  MC_WARNING("Wrong file signature, can't decode motion sequence");
264  BinaryData.SetPosition(OldPosition);
265  return nullptr;
266  }
267  /*
268  * Block 0
269  */
270  // Skip the block number (block 0)
271  BinaryData.GetInt32(true);
272  // Skip the block size (block 0)
273  BinaryData.GetInt32(true);
274  // Skip the number of blocks
275  BinaryData.GetInt32(true);
276  // Skip the major version number
277  BinaryData.GetInt16(true);
278  // Skip the minor version number
279  BinaryData.GetInt16(true);
280  int KeyframeCount = BinaryData.GetInt16(true);
281  int FrameRate = BinaryData.GetInt16(true);
282 
283  // Skip the options
284  BinaryData.GetInt32(true);
285  /*
286  * Block 1
287  */
288  // Skip the block number (block 1)
289  BinaryData.GetInt32(true);
290  // Read the block size (block 1)
291  BlockSize = BinaryData.GetInt32(true);
292  BlockSize -= 8;
293  if (KeyframeCount == 0 || FrameRate == 0 || BinaryData.IsPositionAtEnd())
294  {
295  MC_WARNING("Empty motion data while decoding motion sequence");
296  BinaryData.SetPosition(OldPosition);
297  return nullptr;
298  }
299  // Read the motion (chunk) name
300  TempInt = (int)BinaryData.GetUChar();
301  BlockSize -= 1;
302  TempStr = BinaryData.GetString(TempInt, "_#-:|");
303  BlockSize -= TempInt;
304  if (TempStr.empty() || BinaryData.IsPositionAtEnd())
305  {
306  MC_WARNING("Can't read motion name (chunk) while decoding motion sequence");
307  BinaryData.SetPosition(OldPosition);
308  return nullptr;
309  }
310  MAMotionSkit* MotionSequence = new MAMotionSkit;
311 
312  MotionSequence->Name = MA::SkitNamePrefix+TempStr;
313  // Read the creator
314  TempInt = (int)BinaryData.GetUChar();
315  BlockSize -= 1;
316  TempStr = BinaryData.GetString(TempInt, "_#-:|");
317  BlockSize -= TempInt;
318  if (TempStr.empty() || BinaryData.IsPositionAtEnd())
319  {
320  MC_WARNING("Can't read the creator while decoding motion sequence");
321  delete MotionSequence;
322  BinaryData.SetPosition(OldPosition);
323  return nullptr;
324  }
325  // Read the platform
326  TempInt = (int)BinaryData.GetUChar();
327  BlockSize -= 1;
328  TempStr = BinaryData.GetString(TempInt, "-");
329  BlockSize -= TempInt;
330  if (TempStr != "DRX-1000" || BinaryData.IsPositionAtEnd())
331  {
332  MC_WARNING("Incompatible hardware platform, it is not ERS-7 (DRX-1000 != %s)", TempStr.c_str());
333  delete MotionSequence;
334  BinaryData.SetPosition(OldPosition);
335  return nullptr;
336  }
337  if (BlockSize < 0 || BinaryData.IsPositionAtEnd())
338  {
339  MC_WARNING("Can't decode the block 1 successfully while decoding motion sequence");
340  delete MotionSequence;
341  BinaryData.SetPosition(OldPosition);
342  return nullptr;
343  }
344  if (BlockSize > 0)
345  BinaryData.IncrementPosition(BlockSize);
346  /*
347  * Block 2
348  */
349  // Skip the block number (block 2)
350  BinaryData.GetInt32(true);
351  // Read the block size (block 2)
352  BlockSize = BinaryData.GetInt32(true);
353  BlockSize -= 8;
354  // Read the number of joints
355  int JointCount = BinaryData.GetInt16(true);
356 
357  BlockSize -= 2;
358  CheckStaticMtnParserVariables();
359  bool JointNamesReady = !JointNames->empty();
360 
361  // Read the joint names
362  for (int i = 0; i < JointCount; ++i)
363  {
364  TempInt = (int)BinaryData.GetUChar();
365  BlockSize -= 1;
366  TempStr = BinaryData.GetString(TempInt, ":/-");
367  BlockSize -= TempInt;
368  if (TempStr.empty() || BinaryData.IsPositionAtEnd())
369  {
370  MC_WARNING("Can't decode the joint names while decoding motion sequence");
371  delete MotionSequence;
372  BinaryData.SetPosition(OldPosition);
373  if (!JointNamesReady)
374  {
375  JointNames->clear();
376  }
377  return nullptr;
378  }
379  if (!JointNamesReady)
380  {
381  JointNames->push_back(MADevice::GetMotorDisplayName(TempStr));
382  }
383  }
384  if (BlockSize < 0 || BinaryData.IsPositionAtEnd())
385  {
386  MC_WARNING("Can't decode the block 2 successfully while decoding motion sequence");
387  delete MotionSequence;
388  BinaryData.SetPosition(OldPosition);
389  return nullptr;
390  }
391  if (BlockSize > 0)
392  BinaryData.IncrementPosition(BlockSize);
393  /*
394  * Block 3
395  */
396  // Skip the block number (block 3)
397  BinaryData.GetInt32(true);
398  // Read the block size (block 3)
399  BlockSize = BinaryData.GetInt32(true);
400  BlockSize -= 8;
401  for (int i = 0; i < KeyframeCount; ++i)
402  {
403  MC::IntList KeyframeValues;
404 
405  // Read the time delta
406  TempInt = BinaryData.GetInt32(true);
407  MotionSequence->SkitDuration += TempInt*FrameRate;
408  KeyframeValues.push_back(TempInt*FrameRate);
409  // Skip three dummy words
410  BinaryData.GetInt32(true);
411  BinaryData.GetInt32(true);
412  BinaryData.GetInt32(true);
413  BlockSize -= 16;
414  for (int i1 = 0; i1 < JointCount; ++i1)
415  {
416  float TempFloat = (float)BinaryData.GetInt32(true);
417 
418  BlockSize -= 4;
419  KeyframeValues.push_back((int)roundf(TempFloat*180.0 /
420  (1000000.0*boost::math::constants::pi<float>())));
421  }
422  if (BlockSize < 0 || (BlockSize != 0 && BinaryData.IsPositionAtEnd()))
423  {
424  MC_WARNING("Can't decode the key frame %d while decoding motion sequence", i);
425  delete MotionSequence;
426  BinaryData.SetPosition(OldPosition);
427  return nullptr;
428  }
429  // Skip duplicate frames
430  if (i > 0 && KeyframeValues[0] == 0)
431  {
432 // MC_WARNING("Skip duplicate key frame %d", i);
433  continue;
434  }
435  MotionSequence->Keyframes.push_back(KeyframeValues);
436  }
437  if (BlockSize > 0)
438  BinaryData.IncrementPosition(BlockSize);
439 
440  BinaryData.SetPosition(OldPosition);
441  MC_LOG("Decoded motion sequence: %s", MotionSequence->Name.c_str());
442  return MotionSequence;
443 }
444 
445 
447  MA::LegJointsType joint) const
448 {
449  if (leg == MA::Leg::LF)
450  {
451  if (joint == MA::LegJoint1)
452  return GetGeneratorContainer(7);
453  if (joint == MA::LegJoint2)
454  return GetGeneratorContainer(8);
455  if (joint == MA::LegJoint3)
456  return GetGeneratorContainer(9);
457  }
458  if (leg == MA::Leg::LH)
459  {
460  if (joint == MA::LegJoint1)
461  return GetGeneratorContainer(10, true);
462  if (joint == MA::LegJoint2)
463  return GetGeneratorContainer(11);
464  if (joint == MA::LegJoint3)
465  return GetGeneratorContainer(12);
466  }
467  if (leg == MA::Leg::RF)
468  {
469  if (joint == MA::LegJoint1)
470  return GetGeneratorContainer(13);
471  if (joint == MA::LegJoint2)
472  return GetGeneratorContainer(14);
473  if (joint == MA::LegJoint3)
474  return GetGeneratorContainer(15);
475  }
476  if (leg == MA::Leg::RH)
477  {
478  if (joint == MA::LegJoint1)
479  return GetGeneratorContainer(16, true);
480  if (joint == MA::LegJoint2)
481  return GetGeneratorContainer(17);
482  if (joint == MA::LegJoint3)
483  return GetGeneratorContainer(18);
484  }
485  return nullptr;
486 }
487 
488 
489 MAGeneratorContainer* MAMotionSkit::GetGeneratorContainer(MA::TailJointsType tail_joint) const
490 {
491  if (tail_joint == MA::TailTilt)
492  {
493  return GetGeneratorContainer(19);
494  }
495  return GetGeneratorContainer(20);
496 }
497 
498 
499 MAGeneratorContainer* MAMotionSkit::GetGeneratorContainer(MA::HeadJointsType head_joint) const
500 {
501  if (head_joint == MA::NeckTilt1)
502  return GetGeneratorContainer(1);
503  if (head_joint == MA::NeckPan)
504  return GetGeneratorContainer(2);
505  if (head_joint == MA::NeckTilt2)
506  return GetGeneratorContainer(3);
507  if (head_joint == MA::MouthJoint)
508  return GetGeneratorContainer(4);
509  if (head_joint == MA::EarLeft)
510  {
511  return GetGeneratorContainer(5);
512  }
513  return GetGeneratorContainer(6);
514 }
515 
516 
517 bool MAMotionSkit::IsPostureSit(unsigned int keyframe_index) const
518 {
519  if (keyframe_index > Keyframes.size()-1)
520  {
521  MC_WARNING("Invalid keyframe for sit posture check (%d > %d)", keyframe_index,
522  Keyframes.size()-1);
523  return false;
524  }
525  bool Result = true;
526 
527  // LegLF1
528  Result = Result && Keyframes[keyframe_index][7] == -25;
529  // LegLF2
530  Result = Result && Keyframes[keyframe_index][8] == -4;
531  // LegLF3
532  Result = Result && Keyframes[keyframe_index][9] == 20;
533  // LegLH1
534  Result = Result && Keyframes[keyframe_index][10] == -78;
535  // LegLH2
536  Result = Result && Keyframes[keyframe_index][11] == 20;
537  // LegLH3
538  Result = Result && Keyframes[keyframe_index][12] == 110;
539  // LegRF1
540  Result = Result && Keyframes[keyframe_index][13] == -25;
541  // LegRF2
542  Result = Result && Keyframes[keyframe_index][14] == -4;
543  // LegRF3
544  Result = Result && Keyframes[keyframe_index][15] == 20;
545  // LegRH1
546  Result = Result && Keyframes[keyframe_index][16] == -78;
547  // LegRH2
548  Result = Result && Keyframes[keyframe_index][17] == 20;
549  // LegRH3
550  Result = Result && Keyframes[keyframe_index][18] == 110;
551  return Result;
552 }
553 
554 
555 bool MAMotionSkit::IsPostureLie(unsigned int keyframe_index) const
556 {
557  if (keyframe_index > Keyframes.size()-1)
558  {
559  MC_WARNING("Invalid keyframe for lie posture check (%d > %d)", keyframe_index,
560  Keyframes.size()-1);
561  return false;
562  }
563  bool Result = true;
564 
565  // LegLF1
566  Result = Result && (Keyframes[keyframe_index][7] >= 59 && Keyframes[keyframe_index][7] <= 69);
567  // LegLF2
568  Result = Result && Keyframes[keyframe_index][8] == 0;
569  // LegLF3
570  Result = Result && Keyframes[keyframe_index][9] == 30;
571  // LegLH1
572  Result = Result && (Keyframes[keyframe_index][10] >= -129 && Keyframes[keyframe_index][10] <= -119);
573  // LegLH2
574  Result = Result && Keyframes[keyframe_index][11] == 4;
575  // LegLH3
576  Result = Result && Keyframes[keyframe_index][12] == 122;
577  // LegRF1
578  Result = Result && (Keyframes[keyframe_index][13] >= 59 && Keyframes[keyframe_index][13] <= 69);
579  // LegRF2
580  Result = Result && Keyframes[keyframe_index][14] == 0;
581  // LegRF3
582  Result = Result && Keyframes[keyframe_index][15] == 30;
583  // LegRH1
584  Result = Result && (Keyframes[keyframe_index][16] >= -129 && Keyframes[keyframe_index][16] <= -119);
585  // LegRH2
586  Result = Result && Keyframes[keyframe_index][17] == 4;
587  // LegRH3
588  Result = Result && Keyframes[keyframe_index][18] == 122;
589  return Result;
590 }
591 
592 
593 bool MAMotionSkit::IsPostureStand(unsigned int keyframe_index) const
594 {
595  if (keyframe_index > Keyframes.size()-1)
596  {
597  MC_WARNING("Invalid keyframe for stand posture check (%d > %d)", keyframe_index,
598  Keyframes.size()-1);
599  return false;
600  }
601  bool Result = true;
602 
603  // LegLF1
604  Result = Result && Keyframes[keyframe_index][7] == -5;
605  // LegLF2
606  Result = Result && Keyframes[keyframe_index][8] == 3;
607  // LegLF3
608  Result = Result && Keyframes[keyframe_index][9] == 30;
609  // LegLH1
610  Result = Result && Keyframes[keyframe_index][10] == -5;
611  // LegLH2
612  Result = Result && Keyframes[keyframe_index][11] == 3;
613  // LegLH3
614  Result = Result && Keyframes[keyframe_index][12] == 30;
615  // LegRF1
616  Result = Result && Keyframes[keyframe_index][13] == -5;
617  // LegRF2
618  Result = Result && Keyframes[keyframe_index][14] == 3;
619  // LegRF3
620  Result = Result && Keyframes[keyframe_index][15] == 30;
621  // LegRH1
622  Result = Result && Keyframes[keyframe_index][16] == -5;
623  // LegRH2
624  Result = Result && Keyframes[keyframe_index][17] == 3;
625  // LegRH3
626  Result = Result && Keyframes[keyframe_index][18] == 30;
627  return Result;
628 }
629 
630 
632  bool invert_value) const
633 {
634  if (column_index == 0 || column_index > Keyframes[0].size()-1)
635  {
636  MC_WARNING("Invalid column index to get a generator container (0 < %d <= %d?)",
637  column_index, Keyframes[0].size()-1);
638  return nullptr;
639  }
640  MAGeneratorContainer* Container = nullptr;
641 
642  for (unsigned int i = 1; i < Keyframes.size(); ++i)
643  {
644  MASimpleGenerator* Generator = nullptr;
645 
646  if (unlikely(invert_value))
647  {
648  Generator = new MASimpleGenerator(-(float)Keyframes[i][column_index], Keyframes[i][0]);
649  } else {
650  Generator = new MASimpleGenerator((float)Keyframes[i][column_index], Keyframes[i][0]);
651  }
652  if (i == 1)
653  {
654  Container = new MAGeneratorContainer(*Generator);
655  } else {
656  Container->AddGenerator(*Generator);
657  }
658  }
659  return Container;
660 }
MANum< float > Value
Current value.
Definition: MABodyTypes.hpp:86
int16_t GetInt16(bool reverse_order=false)
Get a 16 bit integer from the current position.
virtual void FromJointDegree(int degree) override
Compute from a joint degree value.
bool IsPostureSit(unsigned int keyframe_index) const
Check if a keyframe posture is sit.
Skit base class.
Definition: MASkitBase.hpp:40
void AddGenerator(MAGeneratorBase &generator, bool in_front=false)
Add a new generator after the last internal generator.
Binary data class.
MANum< float > UpDownValue
Current up-down direction value.
The forward-backward/upward-downward feature of a leg joint.
Definition: MABodyTypes.hpp:92
MANum< float > UpDownValue
Current up-down direction value.
std::string GetName() const
Get the motion name.
virtual void FromJointDegree(int degree) override
Compute from a joint degree value.
Definition: MABodyTypes.cpp:54
bool IsPostureLie(unsigned int keyframe_index) const
Check if a keyframe posture is lie.
bool IsFinishingPostureStand() const
Check if the finishing posture is stand.
virtual void FromJointDegree(int degree) override
Compute from a joint degree value.
unsigned char GetUChar()
Get an unsigned char from the current position.
std::string Name
Motion name.
virtual void FromJointDegree(int degree) override
Compute from a joint degree value.
#define MC_WARNING(...)
Warning macro.
Definition: MCLog.hpp:43
std::string MCToStr(const T value, bool hex_manipulator=false)
Convert an other type to string with std::stringstream.
Definition: MCDefs.hpp:360
static MAMotionSkit * DecodeMtnData(const MCBinaryData &binary_data)
Load motion sequence from binary data.
std::string GetString(unsigned int length, const std::string &additional_chars="")
Get a string from the current position.
MANum< float > ForeBackValue
Current fore-back direction value.
Simple generator class.
bool IsFinishingPostureSit() const
Check if the finishing posture is sit.
void SetPosition(unsigned int position)
Set the cursor position.
bool IsStartingPostureSit() const
Check if the starting posture is sit.
MC::IntTable Keyframes
Keyframes (first column - timestamp, other columns - joint values)
void IncrementPosition(unsigned int position=1)
Increment the cursor position.
MAMotionSkit()
Class constructor.
The left-right turning feature of the head.
void Dump() const
Print the motion skit information.
bool IsStartingPostureStand() const
Check if the starting posture is stand.
The bent-stretched feature of a leg joint.
virtual void FromJointDegree(int degree) override
Compute from a joint degree value.
Generator container class.
MA::MotionSkitSPtr CloneMirrored() const
Clone with mirrored leg joint trajectories between left and right sides.
MAGeneratorContainer * GetGeneratorContainer(MA::Leg::LegTypes leg, MA::LegJointsType joint) const
Get generator container for a leg joint.
The sidelong feature of a leg joint.
Motion sequence (motion skit) class.
bool IsFinishingPostureLie() const
Check if the finishing posture is lie.
int32_t GetInt32(bool reverse_order=false)
Get a 32 bit integer from the current position.
A wrapper class to cover boost::thread_specific_ptr/folly::ThreadLocal API on certain targets...
int GetDuration() const
Get skit duration.
The opened-closed position of the mouth.
#define MC_LOG(...)
Debug macro.
Definition: MCLog.hpp:41
int SkitDuration
Skit duration (in msec)
MANum< float > ForeBackValue
Current fore-back direction value.
int GetPosition() const
Get the current position in the binary data.
The fore-back, up-down position of the head.
bool IsPositionAtEnd() const
Check if the current position is at the end of the binary data.
bool IsPostureStand(unsigned int keyframe_index) const
Check if a keyframe posture is stand.
bool IsStartingPostureLie() const
Check if the starting posture is lie.
std::string GetSkitName() const
Get skit name generated from motion name.