MRPT  1.9.9
CObservationBatteryState.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 using namespace mrpt::math;
19 
20 // This must be added to any CSerializable class implementation file.
22 
23 /** Constructor
24  */
26  : voltageOtherBatteries(), voltageOtherBatteriesValid()
27 {
28 }
29 
30 uint8_t CObservationBatteryState::serializeGetVersion() const { return 2; }
33 {
34  // The data
35  out << voltageMainRobotBattery << voltageMainRobotComputer
36  << voltageMainRobotBatteryIsValid << voltageMainRobotComputerIsValid
37  << voltageOtherBatteries << voltageOtherBatteriesValid << sensorLabel
38  << timestamp;
39 }
40 
42  mrpt::serialization::CArchive& in, uint8_t version)
43 {
44  switch (version)
45  {
46  case 0:
47  case 1:
48  case 2:
49  {
50  in >> voltageMainRobotBattery >> voltageMainRobotComputer >>
51  voltageMainRobotBatteryIsValid >>
52  voltageMainRobotComputerIsValid >> voltageOtherBatteries >>
53  voltageOtherBatteriesValid;
54  if (version >= 1)
55  in >> sensorLabel;
56  else
57  sensorLabel = "";
58 
59  if (version >= 2)
60  in >> timestamp;
61  else
62  timestamp = INVALID_TIMESTAMP;
63  }
64  break;
65  default:
67  };
68 }
69 
70 // See base class docs
72 {
73  out_sensorPose = CPose3D(0, 0, 0);
74 }
75 
76 // See base class docs
78 {
79  MRPT_UNUSED_PARAM(newSensorPose);
80 }
81 
83 {
85 
86  o << format(
87  "Measured VoltageMainRobotBattery: %.02fV isValid= %s \n",
88  voltageMainRobotBattery,
89  (voltageMainRobotBatteryIsValid == true) ? "True" : "False");
90 
91  o << format(
92  "Measured VoltageMainRobotComputer: %.02fV isValid= %s \n",
93  voltageMainRobotComputer,
94  (voltageMainRobotComputerIsValid == true) ? "True" : "False");
95 
96  o << "VoltageOtherBatteries: \n";
97  for (CVectorDouble::Index i = 0; i < voltageOtherBatteries.size(); i++)
98  {
99  o << format(
100  "Index: %d --> %.02fV isValid= %s \n", int(i),
101  voltageOtherBatteries[i],
102  (voltageOtherBatteriesValid[i] == true) ? "True" : "False");
103  }
104 }
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
This represents a measurement of the batteries on the robot.
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.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
This base provides a set of functions for maths stuff.
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) override
A general method to change the sensor pose on the robot.
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.
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
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
mrpt::vision::TStereoCalibResults out
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:43
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
Definition: datetime.h:43
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: 7e629e01a Sat Dec 14 00:05:55 2019 +0100 at sáb dic 14 00:15:10 CET 2019