MRPT  1.9.9
CObservationOdometry.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-2018, 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 
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  hasEncodersInfo(false),
27  encoderLeftTicks(0),
28  encoderRightTicks(0),
29  hasVelocities(false),
30  velocityLocal(.0, .0, .0)
31 {
32 }
33 
36 {
37  // The data
38  out << odometry << sensorLabel << timestamp
39  // Added in V1:
40  << hasEncodersInfo;
41  if (hasEncodersInfo) out << encoderLeftTicks << encoderRightTicks;
42  out << hasVelocities;
43  if (hasVelocities) out << velocityLocal;
44 }
45 
48 {
50  switch (version)
51  {
52  case 0:
53  case 1:
54  case 2:
55  {
56  in >> odometry >> sensorLabel >> timestamp;
57 
58  if (version >= 1)
59  {
60  in >> hasEncodersInfo;
61  if (hasEncodersInfo || version < 2)
62  in >> encoderLeftTicks >> encoderRightTicks;
63 
64  in >> hasVelocities;
65  if (version < 2)
66  {
67  float vx, w;
68  in >> vx >> w;
69  velocityLocal.vx = vx;
70  velocityLocal.vy = .0;
71  velocityLocal.omega = w;
72  }
73  else
74  { // v2
75  if (hasVelocities) in >> velocityLocal;
76  }
77  }
78  else
79  {
80  hasEncodersInfo = false;
81  encoderLeftTicks = encoderRightTicks = 0;
82  hasVelocities = false;
83  }
84  }
85  break;
86  default:
88  };
89 }
90 
91 void CObservationOdometry::getDescriptionAsText(std::ostream& o) const
92 {
94 
95  o << std::endl << "Odometry reading: " << odometry << std::endl;
96 
97  // Additional data:
98  if (hasEncodersInfo)
99  {
100  o << format(
101  " Encoder info: deltaL=%i deltaR=%i\n", encoderLeftTicks,
102  encoderRightTicks);
103  }
104  else
105  o << "Encoder info: Not available!\n";
106 
107  if (hasVelocities)
108  {
109  o << format("Velocity info: %s\n", velocityLocal.asString().c_str());
110  }
111  else
112  o << "Velocity info: Not available!\n";
113 }
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)
This must be inserted in 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:4178
unsigned char uint8_t
Definition: rptypes.h:41
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
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:52
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:7274
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020