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 }
Declares a class derived from "CObservation" that encapsules an omnidirectional RGBD measurement from...
void mempool_donate_range_matrix(CObservation3DRangeScan &obs)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in 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:41
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
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:52
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:43
GLuint in
Definition: glext.h:7274
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020