Main MRPT website > C++ reference for MRPT 1.9.9
CObservationSkeleton.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "obs-precomp.h" // Precompiled headers
11 
13 #include <mrpt/utils/CStream.h>
14 
15 using namespace mrpt::obs;
16 using namespace mrpt::utils;
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 /*---------------------------------------------------------------
28  Implements the writing to a CStream capability of CSerializable objects
29  ---------------------------------------------------------------*/
30 void CObservationSkeleton::writeToStream(CStream& out, int* version) const
31 {
32  if (version)
33  *version = 2;
34  else
35  {
36  WRITE_JOINT(head)
37  WRITE_JOINT(neck)
38  WRITE_JOINT(torso)
39 
40  WRITE_JOINT(left_shoulder)
41  WRITE_JOINT(left_elbow)
42  WRITE_JOINT(left_hand)
43  WRITE_JOINT(left_hip)
44  WRITE_JOINT(left_knee)
45  WRITE_JOINT(left_foot)
46 
47  WRITE_JOINT(right_shoulder)
48  WRITE_JOINT(right_elbow)
49  WRITE_JOINT(right_hand)
50  WRITE_JOINT(right_hip)
51  WRITE_JOINT(right_knee)
52  WRITE_JOINT(right_foot)
53 
54  out << sensorLabel << timestamp << sensorPose;
55  }
56 }
57 
58 /*---------------------------------------------------------------
59  Implements the reading from a CStream capability of CSerializable objects
60  ---------------------------------------------------------------*/
62 {
63  switch (version)
64  {
65  case 0:
66  case 1:
67  case 2:
68  {
69  READ_JOINT(head)
70  READ_JOINT(neck)
71  READ_JOINT(torso)
72 
73  READ_JOINT(left_shoulder)
74  READ_JOINT(left_elbow)
75  READ_JOINT(left_hand)
76  READ_JOINT(left_hip)
77  READ_JOINT(left_knee)
78  READ_JOINT(left_foot)
79 
80  READ_JOINT(right_shoulder)
81  READ_JOINT(right_elbow)
82  READ_JOINT(right_hand)
83  READ_JOINT(right_hip)
84  READ_JOINT(right_knee)
85  READ_JOINT(right_foot)
86 
87  in >> sensorLabel;
88  in >> timestamp;
89  if (version >= 2)
90  {
91  in >> sensorPose;
92  }
93  }
94  break;
95  default:
97  };
98 }
99 
101 {
102  using namespace std;
103  ;
105 
106  o << "Sensor pose on the robot: " << sensorPose << endl;
107 
108  // ----------------------------------------------------------------------
109  // CObservationSkeleton
110  // ----------------------------------------------------------------------
111  o << endl << "Joint Positions (x, y, z) [mm] -- confidence" << endl;
112 
113 #define PRINT_JOINT(_J) \
114  cout << "\t" << #_J << ":\t(" << this->_J.x << ", " << this->_J.y << ", " \
115  << this->_J.z << ") -- " << this->_J.conf << endl;
116 
117  PRINT_JOINT(head)
118  PRINT_JOINT(neck)
119  PRINT_JOINT(torso)
120 
121  PRINT_JOINT(left_shoulder)
122  PRINT_JOINT(left_elbow)
123  PRINT_JOINT(left_hand)
124  PRINT_JOINT(left_hip)
125  PRINT_JOINT(left_knee)
126  PRINT_JOINT(left_foot)
127 
128  PRINT_JOINT(right_shoulder)
129  PRINT_JOINT(right_elbow)
130  PRINT_JOINT(right_hand)
131  PRINT_JOINT(right_hip)
132  PRINT_JOINT(right_knee)
133  PRINT_JOINT(right_foot)
134 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
This class stores a skeleton as tracked by OPENNI2 & NITE2 libraries from PrimeSense sensors...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
#define READ_JOINT(_J)
STL namespace.
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 base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
This namespace contains representation of robot actions and observations.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:41
GLuint in
Definition: glext.h:7274
#define PRINT_JOINT(_J)
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
#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: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019