Main MRPT website > C++ reference for MRPT 1.5.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-2014, 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  ---------------------------------------------------------------*/
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
55  << timestamp
56  << sensorPose;
57  }
58 }
59 
60 /*---------------------------------------------------------------
61  Implements the reading from a CStream capability of CSerializable objects
62  ---------------------------------------------------------------*/
64 {
65  switch(version)
66  {
67  case 0:
68  case 1:
69  case 2:
70  {
71  READ_JOINT(head)
72  READ_JOINT(neck)
73  READ_JOINT(torso)
74 
75  READ_JOINT(left_shoulder)
76  READ_JOINT(left_elbow)
77  READ_JOINT(left_hand)
78  READ_JOINT(left_hip)
79  READ_JOINT(left_knee)
80  READ_JOINT(left_foot)
81 
82  READ_JOINT(right_shoulder)
83  READ_JOINT(right_elbow)
84  READ_JOINT(right_hand)
85  READ_JOINT(right_hip)
86  READ_JOINT(right_knee)
87  READ_JOINT(right_foot)
88 
89  in >> sensorLabel;
90  in >> timestamp;
91  if (version >= 2){
92  in >> sensorPose;
93  }
94  } break;
95  default:
97 
98  };
99 }
100 
102 {
103  using namespace std;;
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) cout << "\t" << #_J << ":\t(" << this->_J.x << ", " << this->_J.y << ", " << this->_J.z << ") -- " << this->_J.conf << endl;
114 
115  PRINT_JOINT(head)
116  PRINT_JOINT(neck)
117  PRINT_JOINT(torso)
118 
119  PRINT_JOINT(left_shoulder)
120  PRINT_JOINT(left_elbow)
121  PRINT_JOINT(left_hand)
122  PRINT_JOINT(left_hip)
123  PRINT_JOINT(left_knee)
124  PRINT_JOINT(left_foot)
125 
126  PRINT_JOINT(right_shoulder)
127  PRINT_JOINT(right_elbow)
128  PRINT_JOINT(right_hand)
129  PRINT_JOINT(right_hip)
130  PRINT_JOINT(right_knee)
131  PRINT_JOINT(right_foot)
132 
133 }
void getDescriptionAsText(std::ostream &o) const MRPT_OVERRIDE
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
This class stores a skeleton as tracked by OPENNI2 & NITE2 libraries from PrimeSense sensors...
#define READ_JOINT(_J)
STL namespace.
IMPLEMENTS_SERIALIZABLE(CLogFileRecord_FullEval, CHolonomicLogFileRecord, mrpt::nav) IMPLEMENTS_SERIALIZABLE(CHolonomicFullEval
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
This namespace contains representation of robot actions and observations.
int version
Definition: mrpt_jpeglib.h:898
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
Declares a class that represents any robot&#39;s observation.
GLuint in
Definition: glext.h:6301
#define PRINT_JOINT(_J)
#define WRITE_JOINT(_J)
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
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.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020