MRPT  2.0.0
CObservationRGBD360.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-2020, 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 
15 #include <mrpt/poses/CPosePDF.h>
18 
19 using namespace std;
20 using namespace mrpt::obs;
21 using namespace mrpt::poses;
22 using namespace mrpt::math;
23 
24 // This must be added to any CSerializable class implementation file.
26 
27 /*---------------------------------------------------------------
28  Constructor
29  ---------------------------------------------------------------*/
31 /*---------------------------------------------------------------
32  Destructor
33  ---------------------------------------------------------------*/
34 CObservationRGBD360::~CObservationRGBD360() {}
35 
36 uint8_t CObservationRGBD360::serializeGetVersion() const { return 1; }
37 void CObservationRGBD360::serializeTo(mrpt::serialization::CArchive& out) const
38 {
39  // The data
40  out << maxRange << sensorPose;
41 
42  out << hasRangeImage;
43  if (hasRangeImage)
44  for (const auto& ri : rangeImages)
45  {
46  out.WriteAs<uint32_t>(ri.rows());
47  out.WriteAs<uint32_t>(ri.cols());
48  if (ri.size() == 0) continue;
49  out.WriteBufferFixEndianness<uint16_t>(ri.data(), ri.size());
50  }
51  out << hasIntensityImage;
52  if (hasIntensityImage)
53  for (const auto& intensityImage : intensityImages)
54  out << intensityImage;
55  // out << hasConfidenceImage; if (hasConfidenceImage) out <<
56  // confidenceImage;
57  for (auto t : timestamps) out << t;
58  //
59  out << stdError;
60  out << timestamp;
61  out << sensorLabel;
62 
63  out << m_points3D_external_stored << m_points3D_external_file;
64  out << m_rangeImage_external_stored << m_rangeImage_external_file;
65 }
66 
67 void CObservationRGBD360::serializeFrom(
68  mrpt::serialization::CArchive& in, uint8_t version)
69 {
70  switch (version)
71  {
72  case 0:
74  "Import from serialization version 0 not implemented!");
75  break;
76  case 1:
77  {
78  in >> maxRange >> sensorPose;
79  in >> hasRangeImage;
80  if (hasRangeImage)
81  for (auto& ri : rangeImages)
82  {
83  const auto rows = in.ReadAs<uint32_t>();
84  const auto cols = in.ReadAs<uint32_t>();
85  ri.setSize(rows, cols);
86  in.ReadBufferFixEndianness<uint16_t>(ri.data(), ri.size());
87  }
88 
89  in >> hasIntensityImage;
90  if (hasIntensityImage)
91  for (auto& intensityImage : intensityImages)
92  in >> intensityImage;
93 
94  for (auto& t : timestamps) in >> t;
95  in >> stdError;
96  in >> timestamp;
97  in >> sensorLabel;
98 
99  in >> m_points3D_external_stored >> m_points3D_external_file;
100  in >> m_rangeImage_external_stored >> m_rangeImage_external_file;
101  }
102  break;
103  default:
105  };
106 }
107 
108 // Similar to calling "rangeImage.setSize(H,W)" but this method provides memory
109 // pooling to speed-up the memory allocation.
110 void CObservationRGBD360::rangeImage_setSize(
111  const int H, const int W, const unsigned sensor_id)
112 {
113  // Fall-back to normal method:
114  rangeImages[sensor_id].setSize(H, W);
115 }
116 
117 void CObservationRGBD360::getDescriptionAsText(std::ostream& o) const
118 {
119  CObservation::getDescriptionAsText(o);
120 }
Declares a class derived from "CObservation" that encapsules an omnidirectional RGBD measurement from...
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:67
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
STL namespace.
#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.
STORED_TYPE ReadAs()
De-serialize a variable and returns it by value.
Definition: CArchive.h:155
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
mrpt::vision::TStereoCalibResults out
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:43
size_t ReadBufferFixEndianness(T *ptr, size_t ElementCount)
Reads a sequence of elemental datatypes, taking care of reordering their bytes from the MRPT stream s...
Definition: CArchive.h:94



Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020