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-2017, 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>
14 
17 #include <mrpt/utils/CTimeLogger.h>
18 
19 using namespace std;
20 using namespace mrpt::obs;
21 using namespace mrpt::utils;
22 using namespace mrpt::poses;
23 using namespace mrpt::math;
24 
25 // This must be added to any CSerializable class implementation file.
27 
28 /*---------------------------------------------------------------
29  Constructor
30  ---------------------------------------------------------------*/
32  : m_points3D_external_stored(false),
33  m_rangeImage_external_stored(false),
34  // hasPoints3D(false),
35  hasRangeImage(false),
36  // range_is_depth(true),
37  hasIntensityImage(false),
38  // hasConfidenceImage(false),
39  // cameraParams(),
40  maxRange(10.0f),
41  sensorPose(),
42  stdError(0.01f)
43 {
44 }
45 
46 /*---------------------------------------------------------------
47  Destructor
48  ---------------------------------------------------------------*/
49 
50 CObservationRGBD360::~CObservationRGBD360()
51 {
52 #ifdef COBS3DRANGE_USE_MEMPOOL
55 #endif
56 }
57 
58 /*---------------------------------------------------------------
59  Implements the writing to a CStream capability of CSerializable objects
60  ---------------------------------------------------------------*/
61 void CObservationRGBD360::writeToStream(
62  mrpt::utils::CStream& out, int* version) const
63 {
64  if (version)
65  *version = 0;
66  else
67  {
68  // The data
69  out << maxRange << sensorPose;
70 
71  // out << hasPoints3D;
72  // if (hasPoints3D)
73  // {
74  // uint32_t N = points3D_x.size();
75  // out << N;
76  // if (N)
77  // {
78  // out.WriteBufferFixEndianness( &points3D_x[0], N );
79  // out.WriteBufferFixEndianness( &points3D_y[0], N );
80  // out.WriteBufferFixEndianness( &points3D_z[0], N );
81  // }
82  // }
83  //
84  out << hasRangeImage;
85  if (hasRangeImage)
86  for (unsigned i = 0; i < NUM_SENSORS; i++) out << rangeImages[i];
87  out << hasIntensityImage;
88  if (hasIntensityImage)
89  for (unsigned i = 0; i < NUM_SENSORS; i++)
90  out << intensityImages[i];
91  // out << hasConfidenceImage; if (hasConfidenceImage) out <<
92  // confidenceImage;
93  for (unsigned i = 0; i < NUM_SENSORS; i++) out << timestamps[i];
94  //
95  out << stdError;
96  out << timestamp;
97  out << sensorLabel;
98 
99  out << m_points3D_external_stored << m_points3D_external_file;
100  out << m_rangeImage_external_stored << m_rangeImage_external_file;
101  }
102 }
103 
104 /*---------------------------------------------------------------
105  Implements the reading from a CStream capability of CSerializable objects
106  ---------------------------------------------------------------*/
107 void CObservationRGBD360::readFromStream(mrpt::utils::CStream& in, int version)
108 {
109  switch (version)
110  {
111  case 0:
112  {
113  in >> maxRange >> sensorPose;
114 
115  in >> hasRangeImage;
116  if (hasRangeImage)
117  for (unsigned i = 0; i < NUM_SENSORS; i++)
118  {
119 #ifdef COBS3DRANGE_USE_MEMPOOL
120  // We should call "rangeImage_setSize()" to exploit the
121  // mempool:
122  this->rangeImage_setSize(240, 320, i);
123 #endif
124  in >> rangeImages[i];
125  }
126 
127  in >> hasIntensityImage;
128  if (hasIntensityImage)
129  for (unsigned i = 0; i < NUM_SENSORS; i++)
130  in >> intensityImages[i];
131 
132  // in >> hasConfidenceImage;
133  // if (hasConfidenceImage)
134  // in >> confidenceImage;
135 
136  // in >> cameraParams;
137 
138  for (unsigned i = 0; i < NUM_SENSORS; i++) in >> timestamps[i];
139  in >> stdError;
140  in >> timestamp;
141  in >> sensorLabel;
142 
143  in >> m_points3D_external_stored >> m_points3D_external_file;
144  in >> m_rangeImage_external_stored >> m_rangeImage_external_file;
145  }
146  break;
147  default:
149  };
150 }
151 
152 // Similar to calling "rangeImage.setSize(H,W)" but this method provides memory
153 // pooling to speed-up the memory allocation.
154 void CObservationRGBD360::rangeImage_setSize(
155  const int H, const int W, const unsigned sensor_id)
156 {
157 #ifdef COBS3DRANGE_USE_MEMPOOL
158  // Request memory from the memory pool:
160  if (pool)
161  {
162  CObservationRGBD360_Ranges_MemPoolParams mem_params;
163  mem_params.H = H;
164  mem_params.W = W;
165 
166  CObservationRGBD360_Ranges_MemPoolData* mem_block =
167  pool->request_memory(mem_params);
168 
169  if (mem_block)
170  { // Take the memory via swaps:
171  rangeImage.swap(mem_block->rangeImage);
172  delete mem_block;
173  return;
174  }
175  }
176 // otherwise, continue with the normal method:
177 #endif
178  // Fall-back to normal method:
179  rangeImages[sensor_id].setSize(H, W);
180 }
181 
182 void CObservationRGBD360::getDescriptionAsText(std::ostream& o) const
183 {
184  CObservation::getDescriptionAsText(o);
185 }
Declares a class derived from "CObservation" that encapsules an omnidirectional RGBD measurement from...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
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.
A generic system for versatile memory pooling.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
This namespace contains representation of robot actions and observations.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:41
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: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019