MRPT  1.9.9
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-2019, 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 
35 CObservationRGBD360::~CObservationRGBD360()
36 {
37 #ifdef COBS3DRANGE_USE_MEMPOOL
40 #endif
41 }
42 
43 uint8_t CObservationRGBD360::serializeGetVersion() const { return 0; }
44 void CObservationRGBD360::serializeTo(mrpt::serialization::CArchive& out) const
45 {
46  // The data
47  out << maxRange << sensorPose;
48 
49  // out << hasPoints3D;
50  // if (hasPoints3D)
51  // {
52  // uint32_t N = points3D_x.size();
53  // out << N;
54  // if (N)
55  // {
56  // out.WriteBufferFixEndianness( &points3D_x[0], N );
57  // out.WriteBufferFixEndianness( &points3D_y[0], N );
58  // out.WriteBufferFixEndianness( &points3D_z[0], N );
59  // }
60  // }
61  //
62  out << hasRangeImage;
63  if (hasRangeImage)
64  for (const auto& rangeImage : rangeImages) out << rangeImage;
65  out << hasIntensityImage;
66  if (hasIntensityImage)
67  for (const auto& intensityImage : intensityImages)
68  out << intensityImage;
69  // out << hasConfidenceImage; if (hasConfidenceImage) out <<
70  // confidenceImage;
71  for (auto t : timestamps) out << t;
72  //
73  out << stdError;
74  out << timestamp;
75  out << sensorLabel;
76 
77  out << m_points3D_external_stored << m_points3D_external_file;
78  out << m_rangeImage_external_stored << m_rangeImage_external_file;
79 }
80 
81 void CObservationRGBD360::serializeFrom(
83 {
84  switch (version)
85  {
86  case 0:
87  {
88  in >> maxRange >> sensorPose;
89  in >> hasRangeImage;
90  if (hasRangeImage)
91  for (auto& rangeImage : rangeImages)
92  {
93 #ifdef COBS3DRANGE_USE_MEMPOOL
94  // We should call "rangeImage_setSize()" to exploit the
95  // mempool:
96  this->rangeImage_setSize(240, 320, i);
97 #endif
98  in >> rangeImage;
99  }
100 
101  in >> hasIntensityImage;
102  if (hasIntensityImage)
103  for (auto& intensityImage : intensityImages)
104  in >> intensityImage;
105 
106  // in >> hasConfidenceImage;
107  // if (hasConfidenceImage)
108  // in >> confidenceImage;
109 
110  // in >> cameraParams;
111 
112  for (auto& t : timestamps) in >> t;
113  in >> stdError;
114  in >> timestamp;
115  in >> sensorLabel;
116 
117  in >> m_points3D_external_stored >> m_points3D_external_file;
118  in >> m_rangeImage_external_stored >> m_rangeImage_external_file;
119  }
120  break;
121  default:
123  };
124 }
125 
126 // Similar to calling "rangeImage.setSize(H,W)" but this method provides memory
127 // pooling to speed-up the memory allocation.
128 void CObservationRGBD360::rangeImage_setSize(
129  const int H, const int W, const unsigned sensor_id)
130 {
131 #ifdef COBS3DRANGE_USE_MEMPOOL
132  // Request memory from the memory pool:
134  if (pool)
135  {
136  CObservationRGBD360_Ranges_MemPoolParams mem_params;
137  mem_params.H = H;
138  mem_params.W = W;
139 
140  CObservationRGBD360_Ranges_MemPoolData* mem_block =
141  pool->request_memory(mem_params);
142 
143  if (mem_block)
144  { // Take the memory via swaps:
145  rangeImage.swap(mem_block->rangeImage);
146  delete mem_block;
147  return;
148  }
149  }
150 // otherwise, continue with the normal method:
151 #endif
152  // Fall-back to normal method:
153  rangeImages[sensor_id].setSize(H, W);
154 }
155 
156 void CObservationRGBD360::getDescriptionAsText(std::ostream& o) const
157 {
158  CObservation::getDescriptionAsText(o);
159 }
Declares a class derived from "CObservation" that encapsules an omnidirectional RGBD measurement from...
GLdouble GLdouble t
Definition: glext.h:3695
void mempool_donate_range_matrix(CObservation3DRangeScan &obs)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
STL namespace.
POOLABLE_DATA * request_memory(const DATA_PARAMS &params)
Request a block of data which fulfils the size requirements stated in params.
unsigned char uint8_t
Definition: rptypes.h:44
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
A generic system for versatile memory pooling.
This base provides a set of functions for maths stuff.
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:53
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:43
GLuint in
Definition: glext.h:7391
void mempool_donate_xyz_buffers(CObservation3DRangeScan &obs)
static CGenericMemoryPool< DATA_PARAMS, POOLABLE_DATA > * getInstance(const size_t max_pool_entries=5)
Construct-on-first-use (~singleton) pattern: Return the unique instance of this class for a given tem...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019