Main MRPT website > C++ reference for MRPT 1.5.7
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(mrpt::utils::CStream &out, int *version) const
62 {
63  if (version)
64  *version = 0;
65  else
66  {
67  // The data
68  out << maxRange << sensorPose;
69 
70 // out << hasPoints3D;
71 // if (hasPoints3D)
72 // {
73 // uint32_t N = points3D_x.size();
74 // out << N;
75 // if (N)
76 // {
77 // out.WriteBufferFixEndianness( &points3D_x[0], N );
78 // out.WriteBufferFixEndianness( &points3D_y[0], N );
79 // out.WriteBufferFixEndianness( &points3D_z[0], N );
80 // }
81 // }
82 //
83  out << hasRangeImage; if (hasRangeImage) for (unsigned i=0; i < NUM_SENSORS; i++) out << rangeImages[i];
84  out << hasIntensityImage; if (hasIntensityImage) for (unsigned i=0; i < NUM_SENSORS; i++) out << intensityImages[i];
85 // out << hasConfidenceImage; if (hasConfidenceImage) out << confidenceImage;
86  for (unsigned i=0; i < NUM_SENSORS; i++) out << timestamps[i];
87 //
88  out << stdError;
89  out << timestamp;
90  out << sensorLabel;
91 
92  out << m_points3D_external_stored << m_points3D_external_file;
93  out << m_rangeImage_external_stored << m_rangeImage_external_file;
94  }
95 }
96 
97 /*---------------------------------------------------------------
98  Implements the reading from a CStream capability of CSerializable objects
99  ---------------------------------------------------------------*/
100 void CObservationRGBD360::readFromStream(mrpt::utils::CStream &in, int version)
101 {
102  switch(version)
103  {
104  case 0:
105  {
106  in >> maxRange >> sensorPose;
107 
108  in >> hasRangeImage;
109  if (hasRangeImage) for (unsigned i=0; i < NUM_SENSORS; i++)
110  {
111 #ifdef COBS3DRANGE_USE_MEMPOOL
112  // We should call "rangeImage_setSize()" to exploit the mempool:
113  this->rangeImage_setSize(240,320,i);
114 #endif
115  in >> rangeImages[i];
116  }
117 
118  in >> hasIntensityImage;
119  if (hasIntensityImage) for (unsigned i=0; i < NUM_SENSORS; i++)
120  in >>intensityImages[i];
121 
122 // in >> hasConfidenceImage;
123 // if (hasConfidenceImage)
124 // in >> confidenceImage;
125 
126 // in >> cameraParams;
127 
128  for (unsigned i=0; i < NUM_SENSORS; i++) in >> timestamps[i];
129  in >> stdError;
130  in >> timestamp;
131  in >> sensorLabel;
132 
133  in >> m_points3D_external_stored >> m_points3D_external_file;
134  in >> m_rangeImage_external_stored >> m_rangeImage_external_file;
135 
136  } break;
137  default:
139 
140  };
141 
142 }
143 
144 // Similar to calling "rangeImage.setSize(H,W)" but this method provides memory pooling to speed-up the memory allocation.
145 void CObservationRGBD360::rangeImage_setSize(const int H, const int W, const unsigned sensor_id)
146 {
147 #ifdef COBS3DRANGE_USE_MEMPOOL
148  // Request memory from the memory pool:
150  if (pool)
151  {
152  CObservationRGBD360_Ranges_MemPoolParams mem_params;
153  mem_params.H = H;
154  mem_params.W = W;
155 
156  CObservationRGBD360_Ranges_MemPoolData *mem_block = pool->request_memory(mem_params);
157 
158  if (mem_block)
159  { // Take the memory via swaps:
160  rangeImage.swap(mem_block->rangeImage);
161  delete mem_block;
162  return;
163  }
164  }
165  // otherwise, continue with the normal method:
166 #endif
167  // Fall-back to normal method:
168  rangeImages[sensor_id].setSize(H,W);
169 }
170 
171 void CObservationRGBD360::getDescriptionAsText(std::ostream &o) const
172 {
173  CObservation::getDescriptionAsText(o);
174 
175 }
176 
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.
Definition: zip.h:16
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:38
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.
int version
Definition: mrpt_jpeglib.h:898
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
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...
Declares a class that represents any robot&#39;s observation.
GLuint in
Definition: glext.h:6301
void mempool_donate_xyz_buffers(CObservation3DRangeScan &obs)



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 8277875f6 Mon Jun 11 02:47:32 2018 +0200 at lun oct 28 01:50:49 CET 2019