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-2020, 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 
31 uint8_t CObservationOdometry::serializeGetVersion() const { return 2; }
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 
45  mrpt::serialization::CArchive& in, uint8_t version)
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.
std::string std::string format(std::string_view fmt, ARGS &&... args)
Definition: format.h:26
#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.
#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:54
mrpt::vision::TStereoCalibResults out
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:43
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: 3a26b90fd Wed Mar 25 20:17:03 2020 +0100 at miƩ mar 25 23:05:41 CET 2020