MRPT  2.0.4
CAngularObservationMesh.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, 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 #pragma once
10 
11 #include <mrpt/maps/CPointsMap.h>
12 #include <mrpt/math/CMatrixB.h>
19 
20 #include <mrpt/math/geometry.h>
21 
22 namespace mrpt::opengl
23 {
24 /**
25  * A mesh built from a set of 2D laser scan observations.
26  * Each element of this set is a single scan through the yaw, given a specific
27  * pitch.
28  * Each scan has a mrpt::poses::CPose3D identifying the origin of the scan,
29  * which ideally is the
30  * same for every one of them.
31  *
32  * <div align="center">
33  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px;
34  * border-style: solid;">
35  * <tr> <td> mrpt::opengl::CAngularObservationMesh </td> <td> \image html
36  * preview_CAngularObservationMesh.png </td> </tr>
37  * </table>
38  * </div>
39  *
40  * \ingroup mrpt_maps_grp
41  */
44 {
46  public:
47  /**
48  * Range specification type, with several uses.
49  */
50  struct TDoubleRange
51  {
52  private:
53  /**
54  * Range type.
55  * If 0, it's specified by an initial and a final value, and an
56  * increment.
57  * If 1, it's specified by an initial and a final value, and a fixed
58  * size of samples.
59  * If 2, it's specified by an aperture, a fixed size of samples and a
60  * boolean variable controlling direction. This type is always
61  * zero-centered.
62  */
63  char rangeType;
64  /**
65  * Union type with the actual data.
66  * \sa rangeType
67  */
68  union rd {
69  struct
70  {
71  double initial;
72  double final;
73  double increment;
74  } mode0;
75  struct
76  {
77  double initial;
78  double final;
79  size_t amount;
80  } mode1;
81  struct
82  {
83  double aperture;
84  size_t amount;
85  bool negToPos;
86  } mode2;
87  } rangeData;
88 
89  public:
90  /**
91  * Constructor from initial value, final value and range.
92  */
93  TDoubleRange(double a, double b, double c) : rangeType(0)
94  {
96  rangeData.mode0.final = b;
98  }
99  /**
100  * Constructor from initial value, final value and amount of samples.
101  */
102  TDoubleRange(double a, double b, size_t c) : rangeType(1)
103  {
104  rangeData.mode1.initial = a;
105  rangeData.mode1.final = b;
106  rangeData.mode1.amount = c;
107  }
108  /**
109  * Constructor from aperture, amount of samples and scan direction.
110  */
111  TDoubleRange(double a, size_t b, bool c) : rangeType(2)
112  {
114  rangeData.mode2.amount = b;
116  }
117  /**
118  * Creates a range of values from the initial value, the final value
119  * and the increment.
120  * \throw std::logic_error if the increment is zero.
121  */
123  double initial, double final, double increment)
124  {
125  if (increment == 0)
126  throw std::logic_error("Invalid increment value.");
127  return TDoubleRange(initial, final, increment);
128  }
129  /**
130  * Creates a range of values from the initial value, the final value
131  * and a desired amount of samples.
132  */
134  double initial, double final, size_t amount)
135  {
136  return TDoubleRange(initial, final, amount);
137  }
138  /**
139  * Creates a zero-centered range of values from an aperture, an amount
140  * of samples and a direction.
141  */
143  double aperture, size_t amount, bool negToPos = true)
144  {
146  }
147  /**
148  * Returns the total aperture of the range.
149  * \throw std::logic_error on invalid range type.
150  */
151  inline double aperture() const
152  {
153  switch (rangeType)
154  {
155  case 0:
156  return (mrpt::sign(rangeData.mode0.increment) ==
157  mrpt::sign(
160  ? fabs(
163  : 0;
164  case 1:
166  case 2:
167  return rangeData.mode2.aperture;
168  default:
169  throw std::logic_error("Unknown range type.");
170  }
171  }
172  /**
173  * Returns the first value of the range.
174  * \throw std::logic_error on invalid range type.
175  */
176  inline double initialValue() const
177  {
178  switch (rangeType)
179  {
180  case 0:
181  case 1:
182  return rangeData.mode0.initial;
183  case 2:
184  return rangeData.mode2.negToPos
185  ? -rangeData.mode2.aperture / 2
186  : rangeData.mode2.aperture / 2;
187  default:
188  throw std::logic_error("Unknown range type.");
189  }
190  }
191  /**
192  * Returns the last value of the range.
193  * \throw std::logic_error on invalid range type.
194  */
195  inline double finalValue() const
196  {
197  switch (rangeType)
198  {
199  case 0:
200  return (mrpt::sign(rangeData.mode0.increment) ==
201  mrpt::sign(
206  case 1:
207  return rangeData.mode1.final;
208  case 2:
209  return rangeData.mode2.negToPos
210  ? rangeData.mode2.aperture / 2
211  : -rangeData.mode2.aperture / 2;
212  default:
213  throw std::logic_error("Unknown range type.");
214  }
215  }
216  /**
217  * Returns the increment between two consecutive values of the range.
218  * \throw std::logic_error on invalid range type.
219  */
220  inline double increment() const
221  {
222  switch (rangeType)
223  {
224  case 0:
225  return rangeData.mode0.increment;
226  case 1:
228  static_cast<double>(rangeData.mode1.amount - 1);
229  case 2:
230  return rangeData.mode2.negToPos
232  static_cast<double>(
233  rangeData.mode2.amount - 1)
235  static_cast<double>(
236  rangeData.mode2.amount - 1);
237  default:
238  throw std::logic_error("Unknown range type.");
239  }
240  }
241  /**
242  * Returns the total amount of values in this range.
243  * \throw std::logic_error on invalid range type.
244  */
245  inline size_t amount() const
246  {
247  switch (rangeType)
248  {
249  case 0:
250  return (mrpt::sign(rangeData.mode0.increment) ==
251  mrpt::sign(
254  ? 1 + static_cast<size_t>(ceil(
258  : 1;
259  case 1:
260  return rangeData.mode1.amount;
261  case 2:
262  return rangeData.mode2.amount;
263  default:
264  throw std::logic_error("Unknown range type.");
265  }
266  }
267  /**
268  * Gets a vector with every value in the range.
269  * \throw std::logic_error on invalid range type.
270  */
271  void values(std::vector<double>& vals) const;
272  /**
273  * Returns the direction of the scan. True if the increment is
274  * positive, false otherwise.
275  * \throw std::logic_error on invalid range type.
276  */
277  inline bool negToPos() const
278  {
279  switch (rangeType)
280  {
281  case 0:
282  return mrpt::sign(rangeData.mode0.increment) > 0;
283  case 1:
284  return mrpt::sign(
286  rangeData.mode1.initial) > 0;
287  case 2:
288  return rangeData.mode2.negToPos;
289  default:
290  throw std::logic_error("Unknown range type.");
291  }
292  }
293  };
294 
295  void getBoundingBox(
297  mrpt::math::TPoint3D& bb_max) const override;
298 
299  protected:
300  /** Updates the mesh, if needed. It's a const method, but modifies mutable
301  * content. */
302  void updateMesh() const;
303  /** Actual set of triangles to be displayed. */
304  mutable std::vector<mrpt::opengl::TTriangle> triangles;
305  /** Internal method to add a triangle to the mutable mesh. */
306  void addTriangle(
307  const mrpt::math::TPoint3D& p1, const mrpt::math::TPoint3D& p2,
308  const mrpt::math::TPoint3D& p3) const;
309  /** Whether the mesh will be displayed wireframe or solid. */
310  bool m_Wireframe{true};
311  /** Mutable variable which controls if the object has suffered any change
312  * since last time the mesh was updated. */
313  mutable bool meshUpToDate{false};
314  /** Whether the object may present transparencies or not. */
316  /** Mutable object with the mesh's points. */
319  /** Scan validity matrix. */
321  /** Observation pitch range. When containing exactly two elements, they
322  * represent the bounds. */
323  std::vector<double> pitchBounds;
324  /** Actual scan set which is used to generate the mesh. */
325  std::vector<mrpt::obs::CObservation2DRangeScan> scanSet;
326 
327  public:
328  /**
329  * Basic constructor.
330  */
332  : actualMesh(0, 0), validityMatrix(0, 0), pitchBounds(), scanSet()
333  {
334  }
335  /** Empty destructor. */
336  ~CAngularObservationMesh() override = default;
337  /**
338  * Returns whether the object is configured as wireframe or solid.
339  */
340  inline bool isWireframe() const { return m_Wireframe; }
341  /**
342  * Sets the display mode for the object. True=wireframe, False=solid.
343  */
344  inline void setWireframe(bool enabled = true)
345  {
346  m_Wireframe = enabled;
348  }
349  /**
350  * Returns whether the object may be transparent or not.
351  */
352  inline bool isTransparencyEnabled() const { return mEnableTransparency; }
353  /**
354  * Enables or disables transparencies.
355  */
356  inline void enableTransparency(bool enabled = true)
357  {
358  mEnableTransparency = enabled;
360  }
361 
362  /** @name Renderizable shader API virtual methods
363  * @{ */
364  void freeOpenGLResources() override
365  {
368  }
369  void render(const RenderContext& rc) const override;
370  void renderUpdateBuffers() const override;
371 
372  virtual shader_list_t requiredShaders() const override
373  {
374  // May use up to two shaders (triangles and lines):
376  }
377  void onUpdateBuffers_Wireframe() override;
378  void onUpdateBuffers_Triangles() override;
379  /** @} */
380 
381  /**
382  * Traces a ray to the object, returning the distance to a given pose
383  * through its X axis.
384  * \sa mrpt::opengl::CRenderizable,trace2DSetOfRays,trace1DSetOfRays
385  */
386  bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const override;
387  /**
388  * Sets the pitch bounds for this range.
389  */
390  void setPitchBounds(const double initial, const double final);
391  /**
392  * Sets the pitch bounds for this range.
393  */
394  void setPitchBounds(const std::vector<double>& bounds);
395  /**
396  * Gets the initial and final pitch bounds for this range.
397  */
398  void getPitchBounds(double& initial, double& final) const;
399  /**
400  * Gets the pitch bounds for this range.
401  */
402  void getPitchBounds(std::vector<double>& bounds) const;
403  /**
404  * Gets the scan set.
405  */
406  void getScanSet(
407  std::vector<mrpt::obs::CObservation2DRangeScan>& scans) const;
408  /**
409  * Sets the scan set.
410  */
411  bool setScanSet(
412  const std::vector<mrpt::obs::CObservation2DRangeScan>& scans);
413  /**
414  * Gets the mesh as a set of triangles, for displaying them.
415  * \sa generateSetOfTriangles(std::vector<TPolygon3D>
416  * &),mrpt::opengl::CSetOfTriangles,mrpt::opengl::mrpt::opengl::TTriangle
417  */
419  /**
420  * Returns the scanned points as a 3D point cloud. The target pointmap must
421  * be passed as a pointer to allow the use of any derived class.
422  */
423  void generatePointCloud(mrpt::maps::CPointsMap* out_map) const;
424  /**
425  * Gets a set of lines containing the traced rays, for displaying them.
426  * \sa getUntracedRays,mrpt::opengl::CSetOfLines
427  */
428  void getTracedRays(CSetOfLines::Ptr& res) const;
429  /**
430  * Gets a set of lines containing the untraced rays, up to a specified
431  * distance, for displaying them.
432  * \sa getTracedRays,mrpt::opengl::CSetOfLines
433  */
434  void getUntracedRays(CSetOfLines::Ptr& res, double dist) const;
435  /**
436  * Gets the mesh as a set of polygons, to work with them.
437  * \sa generateSetOfTriangles(mrpt::opengl::CSetOfTriangles &)
438  */
439  void generateSetOfTriangles(std::vector<mrpt::math::TPolygon3D>& res) const;
440  /**
441  * Retrieves the full mesh, along with the validity matrix.
442  */
445  mrpt::math::CMatrixBool& validity) const
446  {
447  if (!meshUpToDate) updateMesh();
448  pts = actualMesh;
449  validity = validityMatrix;
450  }
451 
452  private:
453  /**
454  * Internal functor class to trace a ray.
455  */
456  template <class T>
457  class FTrace1D
458  {
459  protected:
461  const T& e;
462  std::vector<double>& values;
463  std::vector<char>& valid;
464 
465  public:
467  const T& s, const mrpt::poses::CPose3D& p, std::vector<double>& v,
468  std::vector<char>& v2)
469  : initial(p), e(s), values(v), valid(v2)
470  {
471  }
472  void operator()(double yaw)
473  {
474  double dist;
475  const mrpt::poses::CPose3D pNew =
476  initial + mrpt::poses::CPose3D(0.0, 0.0, 0.0, yaw, 0.0, 0.0);
477  if (e->traceRay(pNew, dist))
478  {
479  values.push_back(dist);
480  valid.push_back(1);
481  }
482  else
483  {
484  values.push_back(0);
485  valid.push_back(0);
486  }
487  }
488  };
489  /**
490  * Internal functor class to trace a set of rays.
491  */
492  template <class T>
493  class FTrace2D
494  {
495  protected:
496  const T& e;
500  std::vector<mrpt::obs::CObservation2DRangeScan>& vObs;
502 
503  public:
505  const T& s, const mrpt::poses::CPose3D& p,
508  std::vector<mrpt::obs::CObservation2DRangeScan>& obs,
509  const mrpt::poses::CPose3D& b)
510  : e(s), initial(p), caom(om), yaws(y), vObs(obs), pBase(b)
511  {
512  }
513  void operator()(double pitch)
514  {
515  std::vector<double> yValues;
516  yaws.values(yValues);
519  const mrpt::poses::CPose3D pNew =
520  initial + mrpt::poses::CPose3D(0, 0, 0, 0, pitch, 0);
521  std::vector<double> values;
522  std::vector<char> valid;
523  size_t nY = yValues.size();
524  values.reserve(nY);
525  valid.reserve(nY);
526  for_each(
527  yValues.begin(), yValues.end(),
528  FTrace1D<T>(e, pNew, values, valid));
529  o.aperture = yaws.aperture();
530  o.rightToLeft = yaws.negToPos();
531  o.maxRange = 10000;
532  o.sensorPose = pNew;
533  o.deltaPitch = 0;
534  o.resizeScan(values.size());
535  for (size_t i = 0; i < values.size(); i++)
536  {
537  o.setScanRange(i, values[i]);
538  o.setScanRangeValidity(i, valid[i] != 0);
539  }
540  vObs.push_back(o);
541  }
542  };
543 
544  public:
545  /**
546  * 2D ray tracing (will generate a 3D mesh). Given an object and two
547  * ranges, realizes a scan from the initial pose and stores it in a
548  * CAngularObservationMesh object.
549  * The objective may be a COpenGLScene, a CRenderizable or any children of
550  * its.
551  * \sa mrpt::opengl::CRenderizable,mrpt::opengl::COpenGLScene.
552  */
553  template <class T>
554  static void trace2DSetOfRays(
555  const T& e, const mrpt::poses::CPose3D& initial,
556  CAngularObservationMesh::Ptr& caom, const TDoubleRange& pitchs,
557  const TDoubleRange& yaws);
558  /**
559  * 2D ray tracing (will generate a vectorial mesh inside a plane). Given an
560  * object and a range, realizes a scan from the initial pose and stores it
561  * in a CObservation2DRangeScan object.
562  * The objective may be a COpenGLScene, a CRenderizable or any children of
563  * its.
564  * \sa mrpt::opengl::CRenderizable,mrpt::opengl::COpenGLScene.
565  */
566  template <class T>
567  static void trace1DSetOfRays(
568  const T& e, const mrpt::poses::CPose3D& initial,
570  {
571  std::vector<double> yValues;
572  yaws.values(yValues);
575  size_t nV = yaws.amount();
576  scanValues.reserve(nV);
577  valid.reserve(nV);
578  for_each(
579  yValues.begin(), yValues.end(),
580  FTrace1D<T>(e, initial, scanValues, valid));
581  obs.aperture = yaws.aperture();
582  obs.rightToLeft = yaws.negToPos();
583  obs.maxRange = 10000;
584  obs.sensorPose = initial;
585  obs.deltaPitch = 0;
586  for (size_t i = 0; i < nV; i++)
587  {
588  obs.setScanRange(i, scanValues[i]);
589  obs.setScanRangeValidity(i, valid[i]);
590  }
591  }
592 };
593 
594 template <class T>
596  const T& e, const mrpt::poses::CPose3D& initial,
597  CAngularObservationMesh::Ptr& caom, const TDoubleRange& pitchs,
598  const TDoubleRange& yaws)
599 {
600  std::vector<double> pValues;
601  pitchs.values(pValues);
602  std::vector<mrpt::obs::CObservation2DRangeScan> vObs;
603  vObs.reserve(pValues.size());
604  for_each(
605  pValues.begin(), pValues.end(),
606  FTrace2D<T>(e, initial, caom, yaws, vObs, initial));
607  caom->m_Wireframe = false;
608  caom->mEnableTransparency = false;
609  caom->setPitchBounds(pValues);
610  caom->setScanSet(vObs);
611 }
612 } // namespace mrpt::opengl
CSetOfLines.h
mrpt::opengl::CAngularObservationMesh::pitchBounds
std::vector< double > pitchBounds
Observation pitch range.
Definition: CAngularObservationMesh.h:323
mrpt::obs::CObservation2DRangeScan::setScanRange
void setScanRange(const size_t i, const float val)
Definition: CObservation2DRangeScan.cpp:507
mrpt::sign
int sign(T x)
Returns the sign of X as "1" or "-1".
Definition: core/include/mrpt/core/bits_math.h:90
mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::aperture
double aperture
Definition: CAngularObservationMesh.h:83
mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::final
double final
Definition: CAngularObservationMesh.h:72
mrpt::opengl::CAngularObservationMesh::generatePointCloud
void generatePointCloud(mrpt::maps::CPointsMap *out_map) const
Returns the scanned points as a 3D point cloud.
Definition: CAngularObservationMesh.cpp:293
mrpt::opengl::CAngularObservationMesh::triangles
std::vector< mrpt::opengl::TTriangle > triangles
Actual set of triangles to be displayed.
Definition: CAngularObservationMesh.h:304
mrpt::obs::CObservation2DRangeScan::maxRange
float maxRange
The maximum range allowed by the device, in meters (e.g.
Definition: CObservation2DRangeScan.h:119
mrpt::opengl::CAngularObservationMesh::TDoubleRange::amount
size_t amount() const
Returns the total amount of values in this range.
Definition: CAngularObservationMesh.h:245
mrpt::obs::CObservation2DRangeScan::rightToLeft
bool rightToLeft
The scanning direction: true=counterclockwise; false=clockwise.
Definition: CObservation2DRangeScan.h:116
mrpt::opengl::CAngularObservationMesh::scanSet
std::vector< mrpt::obs::CObservation2DRangeScan > scanSet
Actual scan set which is used to generate the mesh.
Definition: CAngularObservationMesh.h:325
mrpt::opengl::CAngularObservationMesh::onUpdateBuffers_Triangles
void onUpdateBuffers_Triangles() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
Definition: CAngularObservationMesh.cpp:197
mrpt::opengl::CRenderizable::notifyChange
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
Definition: CRenderizable.h:315
mrpt::opengl::CAngularObservationMesh::isTransparencyEnabled
bool isTransparencyEnabled() const
Returns whether the object may be transparent or not.
Definition: CAngularObservationMesh.h:352
mrpt::opengl::CAngularObservationMesh::TDoubleRange::initialValue
double initialValue() const
Returns the first value of the range.
Definition: CAngularObservationMesh.h:176
geometry.h
mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::mode0
struct mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::@6 mode0
mrpt::math::TPoint3D_< double >
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:152
CPointsMap.h
mrpt::opengl::CAngularObservationMesh::FTrace2D::vObs
std::vector< mrpt::obs::CObservation2DRangeScan > & vObs
Definition: CAngularObservationMesh.h:500
mrpt::obs::CObservation2DRangeScan
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
Definition: CObservation2DRangeScan.h:54
mrpt::opengl::CAngularObservationMesh::FTrace2D::operator()
void operator()(double pitch)
Definition: CAngularObservationMesh.h:513
mrpt::opengl::CAngularObservationMesh::FTrace1D::initial
const mrpt::poses::CPose3D & initial
Definition: CAngularObservationMesh.h:460
mrpt::opengl::CAngularObservationMesh::TDoubleRange::finalValue
double finalValue() const
Returns the last value of the range.
Definition: CAngularObservationMesh.h:195
mrpt::opengl::CAngularObservationMesh::getActualMesh
void getActualMesh(mrpt::math::CMatrixDynamic< mrpt::math::TPoint3D_data< double >> &pts, mrpt::math::CMatrixBool &validity) const
Retrieves the full mesh, along with the validity matrix.
Definition: CAngularObservationMesh.h:443
mrpt::opengl::CAngularObservationMesh::trace1DSetOfRays
static void trace1DSetOfRays(const T &e, const mrpt::poses::CPose3D &initial, mrpt::obs::CObservation2DRangeScan &obs, const TDoubleRange &yaws)
2D ray tracing (will generate a vectorial mesh inside a plane).
Definition: CAngularObservationMesh.h:567
mrpt::opengl::CAngularObservationMesh::addTriangle
void addTriangle(const mrpt::math::TPoint3D &p1, const mrpt::math::TPoint3D &p2, const mrpt::math::TPoint3D &p3) const
Internal method to add a triangle to the mutable mesh.
Definition: CAngularObservationMesh.cpp:49
mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd
Union type with the actual data.
Definition: CAngularObservationMesh.h:68
mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::increment
double increment
Definition: CAngularObservationMesh.h:73
mrpt::opengl::CRenderizableShaderWireFrame
Renderizable generic renderer for objects using the wireframe shader.
Definition: CRenderizableShaderWireFrame.h:24
mrpt::opengl::CAngularObservationMesh::FTrace1D::valid
std::vector< char > & valid
Definition: CAngularObservationMesh.h:463
mrpt::opengl::CAngularObservationMesh::TDoubleRange::CreateFromIncrement
static TDoubleRange CreateFromIncrement(double initial, double final, double increment)
Creates a range of values from the initial value, the final value and the increment.
Definition: CAngularObservationMesh.h:122
mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::amount
size_t amount
Definition: CAngularObservationMesh.h:79
mrpt::opengl::CAngularObservationMesh::CAngularObservationMesh
CAngularObservationMesh()
Basic constructor.
Definition: CAngularObservationMesh.h:331
CSetOfTriangles.h
mrpt::maps::CPointsMap
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors.
Definition: CPointsMap.h:67
mrpt::opengl::CAngularObservationMesh::TDoubleRange::CreateFromAmount
static TDoubleRange CreateFromAmount(double initial, double final, size_t amount)
Creates a range of values from the initial value, the final value and a desired amount of samples.
Definition: CAngularObservationMesh.h:133
mrpt::opengl::CAngularObservationMesh::TDoubleRange::TDoubleRange
TDoubleRange(double a, double b, size_t c)
Constructor from initial value, final value and amount of samples.
Definition: CAngularObservationMesh.h:102
mrpt::opengl::CAngularObservationMesh::TDoubleRange::TDoubleRange
TDoubleRange(double a, double b, double c)
Constructor from initial value, final value and range.
Definition: CAngularObservationMesh.h:93
mrpt::opengl::CAngularObservationMesh::TDoubleRange::increment
double increment() const
Returns the increment between two consecutive values of the range.
Definition: CAngularObservationMesh.h:220
mrpt::opengl::CAngularObservationMesh::getScanSet
void getScanSet(std::vector< mrpt::obs::CObservation2DRangeScan > &scans) const
Gets the scan set.
Definition: CAngularObservationMesh.cpp:270
mrpt::obs::CObservation2DRangeScan::resizeScan
void resizeScan(const size_t len)
Resizes all data vectors to allocate a given number of scan rays.
Definition: CObservation2DRangeScan.cpp:541
mrpt::obs::CObservation2DRangeScan::setScanRangeValidity
void setScanRangeValidity(const size_t i, const bool val)
Definition: CObservation2DRangeScan.cpp:534
mrpt::opengl::CAngularObservationMesh::FTrace2D::caom
CAngularObservationMesh::Ptr & caom
Definition: CAngularObservationMesh.h:498
mrpt::opengl::CAngularObservationMesh::FTrace2D::yaws
const CAngularObservationMesh::TDoubleRange & yaws
Definition: CAngularObservationMesh.h:499
mrpt::opengl::CAngularObservationMesh::FTrace1D::FTrace1D
FTrace1D(const T &s, const mrpt::poses::CPose3D &p, std::vector< double > &v, std::vector< char > &v2)
Definition: CAngularObservationMesh.h:466
mrpt::opengl::CRenderizableShaderTriangles::freeOpenGLResources
void freeOpenGLResources() override
Free opengl buffers.
Definition: CRenderizableShaderTriangles.h:45
mrpt::obs::CObservation2DRangeScan::deltaPitch
double deltaPitch
If the laser gathers data by sweeping in the pitch/elevation angle, this holds the increment in "pitc...
Definition: CObservation2DRangeScan.h:133
mrpt::opengl::CAngularObservationMesh::TDoubleRange::aperture
double aperture() const
Returns the total aperture of the range.
Definition: CAngularObservationMesh.h:151
mrpt::opengl::CAngularObservationMesh::updateMesh
void updateMesh() const
Updates the mesh, if needed.
Definition: CAngularObservationMesh.cpp:63
mrpt::opengl::CAngularObservationMesh::FTrace2D::FTrace2D
FTrace2D(const T &s, const mrpt::poses::CPose3D &p, CAngularObservationMesh::Ptr &om, const CAngularObservationMesh::TDoubleRange &y, std::vector< mrpt::obs::CObservation2DRangeScan > &obs, const mrpt::poses::CPose3D &b)
Definition: CAngularObservationMesh.h:504
mrpt::opengl::CAngularObservationMesh::FTrace2D::initial
const mrpt::poses::CPose3D & initial
Definition: CAngularObservationMesh.h:497
mrpt::opengl::CRenderizableShaderWireFrame::freeOpenGLResources
void freeOpenGLResources() override
Free opengl buffers.
Definition: CRenderizableShaderWireFrame.h:57
mrpt::opengl::CAngularObservationMesh::TDoubleRange
Range specification type, with several uses.
Definition: CAngularObservationMesh.h:50
mrpt::opengl::CAngularObservationMesh::FTrace1D::values
std::vector< double > & values
Definition: CAngularObservationMesh.h:462
mrpt::opengl::CAngularObservationMesh::enableTransparency
void enableTransparency(bool enabled=true)
Enables or disables transparencies.
Definition: CAngularObservationMesh.h:356
mrpt::aligned_std_vector
std::vector< T, mrpt::aligned_allocator_cpp11< T > > aligned_std_vector
Definition: aligned_std_vector.h:15
CRenderizableShaderTriangles.h
bb_max
const auto bb_max
Definition: CPose3DPDFGrid_unittest.cpp:25
mrpt::opengl::CAngularObservationMesh::TDoubleRange::negToPos
bool negToPos() const
Returns the direction of the scan.
Definition: CAngularObservationMesh.h:277
mrpt::opengl::DefaultShaderID::WIREFRAME
static constexpr shader_id_t WIREFRAME
Definition: DefaultShaders.h:25
bb_min
const auto bb_min
Definition: CPose3DPDFGrid_unittest.cpp:23
mrpt::opengl::CAngularObservationMesh::~CAngularObservationMesh
~CAngularObservationMesh() override=default
Empty destructor.
mrpt::opengl::CAngularObservationMesh::TDoubleRange::rangeType
char rangeType
Range type.
Definition: CAngularObservationMesh.h:63
mrpt::opengl::DefaultShaderID::TRIANGLES
static constexpr shader_id_t TRIANGLES
Definition: DefaultShaders.h:27
mrpt::opengl::CAngularObservationMesh::getBoundingBox
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
Definition: CAngularObservationMesh.cpp:427
mrpt::obs::CObservation2DRangeScan::aperture
float aperture
The "aperture" or field-of-view of the range finder, in radians (typically M_PI = 180 degrees).
Definition: CObservation2DRangeScan.h:114
mrpt::opengl::CAngularObservationMesh::requiredShaders
virtual shader_list_t requiredShaders() const override
Returns the ID of the OpenGL shader program required to render this class.
Definition: CAngularObservationMesh.h:372
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
mrpt::opengl::CAngularObservationMesh::mEnableTransparency
bool mEnableTransparency
Whether the object may present transparencies or not.
Definition: CAngularObservationMesh.h:315
mrpt::opengl::CAngularObservationMesh::setWireframe
void setWireframe(bool enabled=true)
Sets the display mode for the object.
Definition: CAngularObservationMesh.h:344
mrpt::opengl::CAngularObservationMesh
A mesh built from a set of 2D laser scan observations.
Definition: CAngularObservationMesh.h:42
mrpt::opengl::CSetOfLines::Ptr
std::shared_ptr< mrpt::opengl ::CSetOfLines > Ptr
Definition: CSetOfLines.h:35
CRenderizableShaderWireFrame.h
mrpt::math::CMatrixB
This class is a "CSerializable" wrapper for "CMatrixBool".
Definition: CMatrixB.h:21
mrpt::opengl::CAngularObservationMesh::render
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
Definition: CAngularObservationMesh.cpp:160
mrpt::opengl::CAngularObservationMesh::generateSetOfTriangles
void generateSetOfTriangles(CSetOfTriangles::Ptr &res) const
Gets the mesh as a set of triangles, for displaying them.
Definition: CAngularObservationMesh.cpp:276
mrpt::opengl::CAngularObservationMesh::Ptr
std::shared_ptr< mrpt::opengl ::CAngularObservationMesh > Ptr
Definition: CAngularObservationMesh.h:45
CMatrixB.h
mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::mode2
struct mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::@8 mode2
mrpt::opengl::CAngularObservationMesh::traceRay
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Traces a ray to the object, returning the distance to a given pose through its X axis.
Definition: CAngularObservationMesh.cpp:211
CMatrixDynamic.h
mrpt::opengl::CAngularObservationMesh::TDoubleRange::CreateFromAperture
static TDoubleRange CreateFromAperture(double aperture, size_t amount, bool negToPos=true)
Creates a zero-centered range of values from an aperture, an amount of samples and a direction.
Definition: CAngularObservationMesh.h:142
mrpt::obs::gnss::pitch
double pitch
Definition: gnss_messages_novatel.h:306
mrpt::opengl::CAngularObservationMesh::meshUpToDate
bool meshUpToDate
Mutable variable which controls if the object has suffered any change since last time the mesh was up...
Definition: CAngularObservationMesh.h:313
mrpt::opengl::CAngularObservationMesh::FTrace2D::pBase
const mrpt::poses::CPose3D & pBase
Definition: CAngularObservationMesh.h:501
mrpt::opengl::CAngularObservationMesh::setScanSet
bool setScanSet(const std::vector< mrpt::obs::CObservation2DRangeScan > &scans)
Sets the scan set.
Definition: CAngularObservationMesh.cpp:219
mrpt::opengl::CAngularObservationMesh::FTrace1D
Internal functor class to trace a ray.
Definition: CAngularObservationMesh.h:457
mrpt::opengl::CAngularObservationMesh::FTrace2D
Internal functor class to trace a set of rays.
Definition: CAngularObservationMesh.h:493
mrpt::math::TPoint3D_data< double >
mrpt::opengl::CAngularObservationMesh::FTrace2D::e
const T & e
Definition: CAngularObservationMesh.h:496
mrpt::opengl::CAngularObservationMesh::FTrace1D::e
const T & e
Definition: CAngularObservationMesh.h:461
mrpt::opengl::CAngularObservationMesh::TDoubleRange::TDoubleRange
TDoubleRange(double a, size_t b, bool c)
Constructor from aperture, amount of samples and scan direction.
Definition: CAngularObservationMesh.h:111
mrpt::opengl::CAngularObservationMesh::TDoubleRange::rangeData
union mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd rangeData
mrpt::opengl::CAngularObservationMesh::isWireframe
bool isWireframe() const
Returns whether the object is configured as wireframe or solid.
Definition: CAngularObservationMesh.h:340
mrpt::opengl::CAngularObservationMesh::setPitchBounds
void setPitchBounds(const double initial, const double final)
Sets the pitch bounds for this range.
Definition: CAngularObservationMesh.cpp:241
mrpt::opengl::CAngularObservationMesh::getTracedRays
void getTracedRays(CSetOfLines::Ptr &res) const
Gets a set of lines containing the traced rays, for displaying them.
Definition: CAngularObservationMesh.cpp:349
mrpt::opengl::CAngularObservationMesh::onUpdateBuffers_Wireframe
void onUpdateBuffers_Wireframe() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
Definition: CAngularObservationMesh.cpp:178
mrpt::opengl::CAngularObservationMesh::getUntracedRays
void getUntracedRays(CSetOfLines::Ptr &res, double dist) const
Gets a set of lines containing the untraced rays, up to a specified distance, for displaying them.
Definition: CAngularObservationMesh.cpp:403
mrpt::opengl::CAngularObservationMesh::TDoubleRange::values
void values(std::vector< double > &vals) const
Gets a vector with every value in the range.
Definition: CAngularObservationMesh.cpp:338
mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::mode1
struct mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::@7 mode1
mrpt::opengl::CSetOfTriangles::Ptr
std::shared_ptr< mrpt::opengl ::CSetOfTriangles > Ptr
Definition: CSetOfTriangles.h:24
mrpt::opengl::shader_list_t
std::vector< shader_id_t > shader_list_t
A list of shader IDs.
Definition: Shader.h:26
mrpt::opengl::CAngularObservationMesh::freeOpenGLResources
void freeOpenGLResources() override
Free opengl buffers.
Definition: CAngularObservationMesh.h:364
mrpt::opengl::CRenderizableShaderTriangles
Renderizable generic renderer for objects using the triangles shader.
Definition: CRenderizableShaderTriangles.h:25
mrpt::opengl::CAngularObservationMesh::m_Wireframe
bool m_Wireframe
Whether the mesh will be displayed wireframe or solid.
Definition: CAngularObservationMesh.h:310
mrpt::opengl::CAngularObservationMesh::validityMatrix
mrpt::math::CMatrixB validityMatrix
Scan validity matrix.
Definition: CAngularObservationMesh.h:320
mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::initial
double initial
Definition: CAngularObservationMesh.h:71
mrpt::opengl::CAngularObservationMesh::renderUpdateBuffers
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers,...
Definition: CAngularObservationMesh.cpp:172
mrpt::opengl::CAngularObservationMesh::FTrace1D::operator()
void operator()(double yaw)
Definition: CAngularObservationMesh.h:472
mrpt::obs::CObservation2DRangeScan::sensorPose
mrpt::poses::CPose3D sensorPose
The 6D pose of the sensor on the robot at the moment of starting the scan.
Definition: CObservation2DRangeScan.h:122
mrpt::opengl::CAngularObservationMesh::actualMesh
mrpt::math::CMatrixDynamic< mrpt::math::TPoint3D_data< double > > actualMesh
Mutable object with the mesh's points.
Definition: CAngularObservationMesh.h:318
mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::negToPos
bool negToPos
Definition: CAngularObservationMesh.h:85
mrpt::opengl
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
mrpt::math::CMatrixDynamic
This template class provides the basic functionality for a general 2D any-size, resizable container o...
Definition: CMatrixDynamic.h:39
mrpt::opengl::CAngularObservationMesh::trace2DSetOfRays
static void trace2DSetOfRays(const T &e, const mrpt::poses::CPose3D &initial, CAngularObservationMesh::Ptr &caom, const TDoubleRange &pitchs, const TDoubleRange &yaws)
2D ray tracing (will generate a 3D mesh).
Definition: CAngularObservationMesh.h:595
CObservation2DRangeScan.h
mrpt::opengl::CAngularObservationMesh::getPitchBounds
void getPitchBounds(double &initial, double &final) const
Gets the initial and final pitch bounds for this range.
Definition: CAngularObservationMesh.cpp:260



Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sat Jun 27 14:00:59 UTC 2020