MRPT  1.9.9
CObservationOdometry.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 <mrpt/system/os.h>
15 
16 using namespace mrpt::obs;
17 using namespace mrpt::poses;
18 
19 // This must be added to any CSerializable class implementation file.
21 
22 /** Constructor
23  */
25  : odometry(),
26 
27  velocityLocal(.0, .0, .0)
28 {
29 }
30 
33 {
34  // The data
35  out << odometry << sensorLabel
36  << timestamp
37  // Added in V1:
38  << hasEncodersInfo;
39  if (hasEncodersInfo) out << encoderLeftTicks << encoderRightTicks;
40  out << hasVelocities;
41  if (hasVelocities) out << velocityLocal;
42 }
43 
46 {
48  switch (version)
49  {
50  case 0:
51  case 1:
52  case 2:
53  {
54  in >> odometry >> sensorLabel >> timestamp;
55 
56  if (version >= 1)
57  {
58  in >> hasEncodersInfo;
59  if (hasEncodersInfo || version < 2)
60  in >> encoderLeftTicks >> encoderRightTicks;
61 
62  in >> hasVelocities;
63  if (version < 2)
64  {
65  float vx, w;
66  in >> vx >> w;
67  velocityLocal.vx = vx;
68  velocityLocal.vy = .0;
69  velocityLocal.omega = w;
70  }
71  else
72  { // v2
73  if (hasVelocities) in >> velocityLocal;
74  }
75  }
76  else
77  {
78  hasEncodersInfo = false;
79  encoderLeftTicks = encoderRightTicks = 0;
80  hasVelocities = false;
81  }
82  }
83  break;
84  default:
86  };
87 }
88 
89 void CObservationOdometry::getDescriptionAsText(std::ostream& o) const
90 {
92 
93  o << std::endl << "Odometry reading: " << odometry << std::endl;
94 
95  // Additional data:
96  if (hasEncodersInfo)
97  {
98  o << format(
99  " Encoder info: deltaL=%i deltaR=%i\n", encoderLeftTicks,
100  encoderRightTicks);
101  }
102  else
103  o << "Encoder info: Not available!\n";
104 
105  if (hasVelocities)
106  {
107  o << format("Velocity info: %s\n", velocityLocal.asString().c_str());
108  }
109  else
110  o << "Velocity info: Not available!\n";
111 }
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4199
unsigned char uint8_t
Definition: rptypes.h:44
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
This namespace contains representation of robot actions and observations.
void getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
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:53
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:43
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
GLuint in
Definition: glext.h:7391
An observation of the current (cumulative) odometry for a wheeled robot.
virtual void getDescriptionAsText(std::ostream &o) const
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019