MRPT  1.9.9
CObservationSkeleton.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "obs-precomp.h" // Precompiled headers
11 
14 #include <iostream>
15 
16 using namespace mrpt::obs;
17 using namespace mrpt::poses;
18 using namespace std;
19 
20 // This must be added to any CSerializable class implementation file.
22 
23 // Helpful macros for reading and writing joints to a stream
24 #define WRITE_JOINT(_J) out << (_J).x << (_J).y << (_J).z << (_J).conf;
25 #define READ_JOINT(_J) in >> (_J).x >> (_J).y >> (_J).z >> (_J).conf;
26 
27 uint8_t CObservationSkeleton::serializeGetVersion() const { return 2; }
29 {
30  WRITE_JOINT(head)
31  WRITE_JOINT(neck)
32  WRITE_JOINT(torso)
33 
34  WRITE_JOINT(left_shoulder)
35  WRITE_JOINT(left_elbow)
36  WRITE_JOINT(left_hand)
37  WRITE_JOINT(left_hip)
38  WRITE_JOINT(left_knee)
39  WRITE_JOINT(left_foot)
40 
41  WRITE_JOINT(right_shoulder)
42  WRITE_JOINT(right_elbow)
43  WRITE_JOINT(right_hand)
44  WRITE_JOINT(right_hip)
45  WRITE_JOINT(right_knee)
46  WRITE_JOINT(right_foot)
47 
48  out << sensorLabel << timestamp << sensorPose;
49 }
50 
52  mrpt::serialization::CArchive& in, uint8_t version)
53 {
54  switch (version)
55  {
56  case 0:
57  case 1:
58  case 2:
59  {
60  READ_JOINT(head)
61  READ_JOINT(neck)
62  READ_JOINT(torso)
63 
64  READ_JOINT(left_shoulder)
65  READ_JOINT(left_elbow)
66  READ_JOINT(left_hand)
67  READ_JOINT(left_hip)
68  READ_JOINT(left_knee)
69  READ_JOINT(left_foot)
70 
71  READ_JOINT(right_shoulder)
72  READ_JOINT(right_elbow)
73  READ_JOINT(right_hand)
74  READ_JOINT(right_hip)
75  READ_JOINT(right_knee)
76  READ_JOINT(right_foot)
77 
78  in >> sensorLabel;
79  in >> timestamp;
80  if (version >= 2)
81  {
82  in >> sensorPose;
83  }
84  }
85  break;
86  default:
88  };
89 }
90 
91 void CObservationSkeleton::getDescriptionAsText(std::ostream& o) const
92 {
93  using namespace std;
95 
96  o << "Sensor pose on the robot: " << sensorPose << endl;
97 
98  // ----------------------------------------------------------------------
99  // CObservationSkeleton
100  // ----------------------------------------------------------------------
101  o << endl << "Joint Positions (x, y, z) [mm] -- confidence" << endl;
102 
103 #define PRINT_JOINT(_J) \
104  cout << "\t" << #_J << ":\t(" << this->_J.x << ", " << this->_J.y << ", " \
105  << this->_J.z << ") -- " << this->_J.conf << endl;
106 
107  PRINT_JOINT(head)
108  PRINT_JOINT(neck)
109  PRINT_JOINT(torso)
110 
111  PRINT_JOINT(left_shoulder)
112  PRINT_JOINT(left_elbow)
113  PRINT_JOINT(left_hand)
114  PRINT_JOINT(left_hip)
115  PRINT_JOINT(left_knee)
116  PRINT_JOINT(left_foot)
117 
118  PRINT_JOINT(right_shoulder)
119  PRINT_JOINT(right_elbow)
120  PRINT_JOINT(right_hand)
121  PRINT_JOINT(right_hip)
122  PRINT_JOINT(right_knee)
123  PRINT_JOINT(right_foot)
124 }
This class stores a skeleton as tracked by OPENNI2 & NITE2 libraries from PrimeSense sensors...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
#define READ_JOINT(_J)
STL namespace.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
void getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
This namespace contains representation of robot actions and observations.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:54
mrpt::vision::TStereoCalibResults out
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:43
#define PRINT_JOINT(_J)
#define WRITE_JOINT(_J)
virtual void getDescriptionAsText(std::ostream &o) const
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7e629e01a Sat Dec 14 00:05:55 2019 +0100 at sáb dic 14 00:15:10 CET 2019