MRPT  1.9.9
CObservationRFID.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 
15 using namespace mrpt::obs;
16 using namespace mrpt::poses;
17 
18 // This must be added to any CSerializable class implementation file.
20 
21 /** Constructor
22  */
23 CObservationRFID::CObservationRFID() : tag_readings() {}
26 {
27  // The data
28  const uint32_t Ntags = tag_readings.size();
29  out << Ntags; // new in v4
30 
31  // (Fields are dumped in separate for loops for backward compatibility
32  // with old serialization versions)
33  for (uint32_t i = 0; i < Ntags; i++) out << tag_readings[i].power;
34  for (uint32_t i = 0; i < Ntags; i++) out << tag_readings[i].epc;
35  for (uint32_t i = 0; i < Ntags; i++) out << tag_readings[i].antennaPort;
36 
37  out << sensorLabel;
38  out << timestamp;
39  out << sensorPoseOnRobot; // Added in v3
40 }
41 
44 {
45  // MRPT_UNUSED_PARAM(in);
46  switch (version)
47  {
48  case 0:
49  case 1:
50  case 2:
51  case 3:
52  case 4:
53  {
54  uint32_t Ntags = 0;
55  if (version < 4)
56  {
57  std::string ntags;
58  in >> ntags;
59  Ntags = atoi(ntags.c_str());
60  }
61  else
62  {
63  in >> Ntags;
64  }
65 
66  // (Fields are read in separate for loops for backward compatibility
67  // with old serialization versions)
68  tag_readings.resize(Ntags);
69  for (uint32_t i = 0; i < Ntags; i++) in >> tag_readings[i].power;
70  for (uint32_t i = 0; i < Ntags; i++) in >> tag_readings[i].epc;
71  for (uint32_t i = 0; i < Ntags; i++)
72  in >> tag_readings[i].antennaPort;
73 
74  if (version >= 1)
75  in >> sensorLabel;
76  else
77  sensorLabel = "";
78 
79  if (version >= 2)
80  in >> timestamp;
81  else
82  timestamp = INVALID_TIMESTAMP;
83 
84  if (version >= 3)
85  in >> sensorPoseOnRobot;
86  else
87  sensorPoseOnRobot = CPose3D();
88  }
89  break;
90  default:
92  };
93 }
94 
95 void CObservationRFID::getSensorPose(CPose3D& out_sensorPose) const
96 {
97  out_sensorPose = sensorPoseOnRobot;
98 }
99 
100 void CObservationRFID::setSensorPose(const CPose3D& newSensorPose)
101 {
102  sensorPoseOnRobot = newSensorPose;
103 }
104 
105 void CObservationRFID::getDescriptionAsText(std::ostream& o) const
106 {
108 
109  o << "Number of RFID tags sensed: " << tag_readings.size() << "\n";
110  for (size_t i = 0; i < tag_readings.size(); i++)
111  {
112  const auto& rfid = tag_readings[i];
113  o << "#" << i << ": Power=" << rfid.power
114  << " (dBm) | AntennaPort=" << rfid.antennaPort
115  << " | EPC=" << rfid.epc << std::endl;
116  }
117 }
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
void getSensorPose(mrpt::poses::CPose3D &out_sensorPose) const override
A general method to retrieve the sensor pose on the robot.
unsigned char uint8_t
Definition: rptypes.h:41
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) override
A general method to change the sensor pose on the robot.
This namespace contains representation of robot actions and observations.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
GLsizei const GLchar ** string
Definition: glext.h:4101
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
GLuint in
Definition: glext.h:7274
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 represents one or more RFID tags observed by a receiver.
unsigned __int32 uint32_t
Definition: rptypes.h:47
#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...
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.



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