Main MRPT website > C++ reference for MRPT 1.5.9
CObservationWirelessPower.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 
13 #include <mrpt/utils/CStream.h>
14 
15 using namespace mrpt::obs;
16 using namespace mrpt::utils;
17 using namespace mrpt::poses;
18 
19 
20 // This must be added to any CSerializable class implementation file.
22 
23 /** Constructor
24  */
26  power(0)
27 {
28 }
29 
30 /*---------------------------------------------------------------
31  Implements the writing to a CStream capability of CSerializable objects
32  ---------------------------------------------------------------*/
34 {
35  MRPT_UNUSED_PARAM(out);
36  if (version)
37  *version = 3;
38  else
39  {
40  // The data
41  out << power
42  << sensorLabel
43  << timestamp
44  << sensorPoseOnRobot; // Added in v3
45  }
46 }
47 
48 /*---------------------------------------------------------------
49  Implements the reading from a CStream capability of CSerializable objects
50  ---------------------------------------------------------------*/
52 {
53  //MRPT_UNUSED_PARAM(in);
54  switch(version)
55  {
56  case 0:
57  case 1:
58  case 2:
59  case 3:
60  {
61  in >> power;
62  if (version>=1)
63  in >> sensorLabel;
64  else sensorLabel="";
65 
66  if (version>=2)
67  in >> timestamp;
68  else timestamp = INVALID_TIMESTAMP;
69 
70  if (version>=3)
71  in >> sensorPoseOnRobot;
72  else sensorPoseOnRobot = CPose3D();
73 
74  } break;
75  default:
77 
78  };
79 
80 }
81 
82 
83 
85 {
86  out_sensorPose=sensorPoseOnRobot;
87 }
88 
90 {
91  sensorPoseOnRobot = newSensorPose;
92 }
93 
95 {
97 
98  std::cout << format("Measured Power: %.02f/100\n", power);
99 }
100 
101 
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
void getSensorPose(mrpt::poses::CPose3D &out_sensorPose) const MRPT_OVERRIDE
A general method to retrieve the sensor pose on the robot.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) MRPT_OVERRIDE
A general method to change the sensor pose on the robot.
IMPLEMENTS_SERIALIZABLE(CLogFileRecord_FullEval, CHolonomicLogFileRecord, mrpt::nav) IMPLEMENTS_SERIALIZABLE(CHolonomicFullEval
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
#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
This represents a measurement of the wireless strength perceived by the robot.
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 readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
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 getDescriptionAsText(std::ostream &o) const MRPT_OVERRIDE
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
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.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020