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-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 using namespace mrpt::math;
19 
20 // This must be added to any CSerializable class implementation file.
22 
23 /** Constructor
24  */
26  : voltageMainRobotBattery(0),
27  voltageMainRobotComputer(0),
28  voltageMainRobotBatteryIsValid(false),
29  voltageMainRobotComputerIsValid(false),
30  voltageOtherBatteries(),
31  voltageOtherBatteriesValid()
32 {
33 }
34 
38 {
39  // The data
40  out << voltageMainRobotBattery << voltageMainRobotComputer
41  << voltageMainRobotBatteryIsValid << voltageMainRobotComputerIsValid
42  << voltageOtherBatteries << voltageOtherBatteriesValid << sensorLabel
43  << timestamp;
44 }
45 
48 {
49  switch (version)
50  {
51  case 0:
52  case 1:
53  case 2:
54  {
55  in >> voltageMainRobotBattery >> voltageMainRobotComputer >>
56  voltageMainRobotBatteryIsValid >>
57  voltageMainRobotComputerIsValid >> voltageOtherBatteries >>
58  voltageOtherBatteriesValid;
59  if (version >= 1)
60  in >> sensorLabel;
61  else
62  sensorLabel = "";
63 
64  if (version >= 2)
65  in >> timestamp;
66  else
67  timestamp = INVALID_TIMESTAMP;
68  }
69  break;
70  default:
72  };
73 }
74 
75 // See base class docs
77 {
78  out_sensorPose = CPose3D(0, 0, 0);
79 }
80 
81 // See base class docs
83 {
84  MRPT_UNUSED_PARAM(newSensorPose);
85 }
86 
88 {
90 
91  o << format(
92  "Measured VoltageMainRobotBattery: %.02fV isValid= %s \n",
93  voltageMainRobotBattery,
94  (voltageMainRobotBatteryIsValid == true) ? "True" : "False");
95 
96  o << format(
97  "Measured VoltageMainRobotComputer: %.02fV isValid= %s \n",
98  voltageMainRobotComputer,
99  (voltageMainRobotComputerIsValid == true) ? "True" : "False");
100 
101  o << "VoltageOtherBatteries: \n";
102  for (CVectorDouble::Index i = 0; i < voltageOtherBatteries.size(); i++)
103  {
104  o << format(
105  "Index: %d --> %.02fV isValid= %s \n", int(i),
106  voltageOtherBatteries[i],
107  (voltageOtherBatteriesValid[i] == true) ? "True" : "False");
108  }
109 }
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
This represents a measurement of the batteries on the robot.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
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 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:52
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:86
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.
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
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020