Main MRPT website > C++ reference for MRPT 1.9.9
CObservationRGBD360.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 
13 #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  : m_points3D_external_stored(false),
32  m_rangeImage_external_stored(false),
33  // hasPoints3D(false),
34  hasRangeImage(false),
35  // range_is_depth(true),
36  hasIntensityImage(false),
37  // hasConfidenceImage(false),
38  // cameraParams(),
39  maxRange(10.0f),
40  sensorPose(),
41  stdError(0.01f)
42 {
43 }
44 
45 /*---------------------------------------------------------------
46  Destructor
47  ---------------------------------------------------------------*/
48 
49 CObservationRGBD360::~CObservationRGBD360()
50 {
51 #ifdef COBS3DRANGE_USE_MEMPOOL
54 #endif
55 }
56 
57 uint8_t CObservationRGBD360::serializeGetVersion() const { return 0; }
58 void CObservationRGBD360::serializeTo(mrpt::serialization::CArchive& out) const
59 {
60  // The data
61  out << maxRange << sensorPose;
62 
63  // out << hasPoints3D;
64  // if (hasPoints3D)
65  // {
66  // uint32_t N = points3D_x.size();
67  // out << N;
68  // if (N)
69  // {
70  // out.WriteBufferFixEndianness( &points3D_x[0], N );
71  // out.WriteBufferFixEndianness( &points3D_y[0], N );
72  // out.WriteBufferFixEndianness( &points3D_z[0], N );
73  // }
74  // }
75  //
76  out << hasRangeImage;
77  if (hasRangeImage)
78  for (unsigned i = 0; i < NUM_SENSORS; i++) out << rangeImages[i];
79  out << hasIntensityImage;
80  if (hasIntensityImage)
81  for (unsigned i = 0; i < NUM_SENSORS; i++) out << intensityImages[i];
82  // out << hasConfidenceImage; if (hasConfidenceImage) out <<
83  // confidenceImage;
84  for (unsigned i = 0; i < NUM_SENSORS; i++) out << timestamps[i];
85  //
86  out << stdError;
87  out << timestamp;
88  out << sensorLabel;
89 
90  out << m_points3D_external_stored << m_points3D_external_file;
91  out << m_rangeImage_external_stored << m_rangeImage_external_file;
92 }
93 
94 void CObservationRGBD360::serializeFrom(
96 {
97  switch (version)
98  {
99  case 0:
100  {
101  in >> maxRange >> sensorPose;
102  in >> hasRangeImage;
103  if (hasRangeImage)
104  for (unsigned i = 0; i < NUM_SENSORS; i++)
105  {
106 #ifdef COBS3DRANGE_USE_MEMPOOL
107  // We should call "rangeImage_setSize()" to exploit the
108  // mempool:
109  this->rangeImage_setSize(240, 320, i);
110 #endif
111  in >> rangeImages[i];
112  }
113 
114  in >> hasIntensityImage;
115  if (hasIntensityImage)
116  for (unsigned i = 0; i < NUM_SENSORS; i++)
117  in >> intensityImages[i];
118 
119  // in >> hasConfidenceImage;
120  // if (hasConfidenceImage)
121  // in >> confidenceImage;
122 
123  // in >> cameraParams;
124 
125  for (unsigned i = 0; i < NUM_SENSORS; i++) in >> timestamps[i];
126  in >> stdError;
127  in >> timestamp;
128  in >> sensorLabel;
129 
130  in >> m_points3D_external_stored >> m_points3D_external_file;
131  in >> m_rangeImage_external_stored >> m_rangeImage_external_file;
132  }
133  break;
134  default:
136  };
137 }
138 
139 // Similar to calling "rangeImage.setSize(H,W)" but this method provides memory
140 // pooling to speed-up the memory allocation.
141 void CObservationRGBD360::rangeImage_setSize(
142  const int H, const int W, const unsigned sensor_id)
143 {
144 #ifdef COBS3DRANGE_USE_MEMPOOL
145  // Request memory from the memory pool:
147  if (pool)
148  {
149  CObservationRGBD360_Ranges_MemPoolParams mem_params;
150  mem_params.H = H;
151  mem_params.W = W;
152 
153  CObservationRGBD360_Ranges_MemPoolData* mem_block =
154  pool->request_memory(mem_params);
155 
156  if (mem_block)
157  { // Take the memory via swaps:
158  rangeImage.swap(mem_block->rangeImage);
159  delete mem_block;
160  return;
161  }
162  }
163 // otherwise, continue with the normal method:
164 #endif
165  // Fall-back to normal method:
166  rangeImages[sensor_id].setSize(H, W);
167 }
168 
169 void CObservationRGBD360::getDescriptionAsText(std::ostream& o) const
170 {
171  CObservation::getDescriptionAsText(o);
172 }
mrpt::system::CGenericMemoryPool::request_memory
POOLABLE_DATA * request_memory(const DATA_PARAMS &params)
Request a block of data which fulfils the size requirements stated in params.
Definition: CGenericMemoryPool.h:93
CFileGZOutputStream.h
mrpt::system::CGenericMemoryPool
A generic system for versatile memory pooling.
Definition: CGenericMemoryPool.h:45
obs-precomp.h
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
mrpt::poses
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CHierarchicalMapMHPartition.h:25
mrpt::obs
This namespace contains representation of robot actions and observations.
Definition: CParticleFilter.h:17
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
mempool_donate_xyz_buffers
void mempool_donate_xyz_buffers(CObservation3DRangeScan &obs)
Definition: CObservation3DRangeScan.cpp:109
CPosePDF.h
mempool_donate_range_matrix
void mempool_donate_range_matrix(CObservation3DRangeScan &obs)
Definition: CObservation3DRangeScan.cpp:141
IMPLEMENTS_SERIALIZABLE
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
Definition: CSerializable.h:114
CTimeLogger.h
mrpt::obs::CObservationRGBD360
Declares a class derived from "CObservation" that encapsules an omnidirectional RGBD measurement from...
Definition: CObservationRGBD360.h:84
CFileGZInputStream.h
mrpt::obs::CObservation
Declares a class that represents any robot's observation.
Definition: CObservation.h:43
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:13
in
GLuint in
Definition: glext.h:7274
CObservationRGBD360.h
CArchive.h
mrpt::system::CGenericMemoryPool::getInstance
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...
Definition: CGenericMemoryPool.h:74
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST