Main MRPT website > C++ reference for MRPT 1.9.9
CObservationBatteryState.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 
12 #include <mrpt/utils/CStream.h>
14 #include <mrpt/system/os.h>
15 
16 using namespace mrpt::obs;
17 using namespace mrpt::utils;
18 using namespace mrpt::poses;
19 using namespace mrpt::math;
20 
21 // This must be added to any CSerializable class implementation file.
23 
24 /** Constructor
25  */
27  : voltageMainRobotBattery(0),
28  voltageMainRobotComputer(0),
29  voltageMainRobotBatteryIsValid(false),
30  voltageMainRobotComputerIsValid(false),
31  voltageOtherBatteries(),
32  voltageOtherBatteriesValid()
33 {
34 }
35 
36 /*---------------------------------------------------------------
37  Implements the writing to a CStream capability of CSerializable objects
38  ---------------------------------------------------------------*/
40  mrpt::utils::CStream& out, int* version) const
41 {
42  MRPT_UNUSED_PARAM(out);
43  if (version)
44  *version = 2;
45  else
46  {
47  // The data
48  out << voltageMainRobotBattery << voltageMainRobotComputer
49  << voltageMainRobotBatteryIsValid << voltageMainRobotComputerIsValid
50  << voltageOtherBatteries << voltageOtherBatteriesValid
51  << sensorLabel << timestamp;
52  }
53 }
54 
55 /*---------------------------------------------------------------
56  Implements the reading from a CStream capability of CSerializable objects
57  ---------------------------------------------------------------*/
59  mrpt::utils::CStream& in, int version)
60 {
62  switch (version)
63  {
64  case 0:
65  case 1:
66  case 2:
67  {
68  in >> voltageMainRobotBattery >> voltageMainRobotComputer >>
69  voltageMainRobotBatteryIsValid >>
70  voltageMainRobotComputerIsValid >> voltageOtherBatteries >>
71  voltageOtherBatteriesValid;
72  if (version >= 1)
73  in >> sensorLabel;
74  else
75  sensorLabel = "";
76 
77  if (version >= 2)
78  in >> timestamp;
79  else
80  timestamp = INVALID_TIMESTAMP;
81  }
82  break;
83  default:
85  };
86 }
87 
88 // See base class docs
90 {
91  out_sensorPose = CPose3D(0, 0, 0);
92 }
93 
94 // See base class docs
96 {
97  MRPT_UNUSED_PARAM(newSensorPose);
98 }
99 
101 {
103 
104  o << format(
105  "Measured VoltageMainRobotBattery: %.02fV isValid= %s \n",
106  voltageMainRobotBattery,
107  (voltageMainRobotBatteryIsValid == true) ? "True" : "False");
108 
109  o << format(
110  "Measured VoltageMainRobotComputer: %.02fV isValid= %s \n",
111  voltageMainRobotComputer,
112  (voltageMainRobotComputerIsValid == true) ? "True" : "False");
113 
114  o << "VoltageOtherBatteries: \n";
115  for (CVectorDouble::Index i = 0; i < voltageOtherBatteries.size(); i++)
116  {
117  o << format(
118  "Index: %d --> %.02fV isValid= %s \n", int(i),
119  voltageOtherBatteries[i],
120  (voltageOtherBatteriesValid[i] == true) ? "True" : "False");
121  }
122 }
This represents a measurement of the batteries on the robot.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) override
A general method to change the sensor pose on the robot.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
void getSensorPose(mrpt::poses::CPose3D &out_sensorPose) const override
A general method to retrieve the sensor pose on the robot.
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 namespace contains representation of robot actions and observations.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:19
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
Definition: datetime.h:16
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:41
GLuint in
Definition: glext.h:7274
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...
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
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.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019