Main MRPT website > C++ reference for MRPT 1.5.6
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 
13 #include <mrpt/utils/CStream.h>
15 #include <mrpt/system/os.h>
16 
17 using namespace mrpt::obs;
18 using namespace mrpt::utils;
19 using namespace mrpt::poses;
20 using namespace mrpt::math;
21 
22 // This must be added to any CSerializable class implementation file.
24 
25 /** Constructor
26  */
28  voltageMainRobotBattery(0),
29  voltageMainRobotComputer(0),
30  voltageMainRobotBatteryIsValid(false),
31  voltageMainRobotComputerIsValid(false),
32  voltageOtherBatteries(),
33  voltageOtherBatteriesValid()
34 {
35 }
36 
37 /*---------------------------------------------------------------
38  Implements the writing to a CStream capability of CSerializable objects
39  ---------------------------------------------------------------*/
41 {
42  MRPT_UNUSED_PARAM(out);
43  if (version)
44  *version = 2;
45  else
46  {
47  // The data
48  out << voltageMainRobotBattery
49  << voltageMainRobotComputer
50  << voltageMainRobotBatteryIsValid
51  << voltageMainRobotComputerIsValid
52  << voltageOtherBatteries
53  << voltageOtherBatteriesValid
54  << sensorLabel
55  << timestamp;
56  }
57 }
58 
59 /*---------------------------------------------------------------
60  Implements the reading from a CStream capability of CSerializable objects
61  ---------------------------------------------------------------*/
63 {
65  switch(version)
66  {
67  case 0:
68  case 1:
69  case 2:
70  {
71  in >> voltageMainRobotBattery
72  >> voltageMainRobotComputer
73  >> voltageMainRobotBatteryIsValid
74  >> voltageMainRobotComputerIsValid
75  >> voltageOtherBatteries
76  >> voltageOtherBatteriesValid;
77  if (version>=1)
78  in >> sensorLabel;
79  else sensorLabel="";
80 
81  if (version>=2)
82  in >> timestamp;
83  else timestamp = INVALID_TIMESTAMP;
84  } break;
85  default:
87 
88  };
89 
90 }
91 
92 // See base class docs
93 void CObservationBatteryState::getSensorPose( CPose3D &out_sensorPose ) const {
94  out_sensorPose=CPose3D(0,0,0);
95 }
96 
97 // See base class docs
98 void CObservationBatteryState::setSensorPose( const CPose3D &newSensorPose ) {
99  MRPT_UNUSED_PARAM(newSensorPose);
100 }
101 
103 {
105 
106  o << format("Measured VoltageMainRobotBattery: %.02fV isValid= %s \n",
107  voltageMainRobotBattery,
108  (voltageMainRobotBatteryIsValid == true)? "True":"False" );
109 
110  o << format("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("Index: %d --> %.02fV isValid= %s \n",
118  int(i),
119  voltageOtherBatteries[i],
120  (voltageOtherBatteriesValid[i] == true)? "True":"False" );
121  }
122 
123 }
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.
Definition: zip.h:16
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) MRPT_OVERRIDE
A general method to change the sensor pose on the robot.
void getDescriptionAsText(std::ostream &o) const MRPT_OVERRIDE
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
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 readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
This namespace contains representation of robot actions and observations.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:21
int version
Definition: mrpt_jpeglib.h:898
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:17
void getSensorPose(mrpt::poses::CPose3D &out_sensorPose) const MRPT_OVERRIDE
A general method to retrieve the sensor pose on the robot.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
Declares a class that represents any robot&#39;s observation.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
GLuint in
Definition: glext.h:6301
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.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019