9 #ifndef opengl_CAngularObservationMesh_H
10 #define opengl_CAngularObservationMesh_H
124 double initial,
double final,
double increment)
127 throw std::logic_error(
"Invalid increment value.");
135 double initial,
double final,
size_t amount)
170 throw std::logic_error(
"Unknown range type.");
189 throw std::logic_error(
"Unknown range type.");
214 throw std::logic_error(
"Unknown range type.");
239 throw std::logic_error(
"Unknown range type.");
255 ? 1 +
static_cast<size_t>(
266 throw std::logic_error(
"Unknown range type.");
273 void values(std::vector<double>& vals)
const;
292 throw std::logic_error(
"Unknown range type.");
306 mutable std::vector<CSetOfTriangles::TTriangle>
triangles;
326 std::vector<mrpt::obs::CObservation2DRangeScan>
scanSet;
399 std::vector<mrpt::obs::CObservation2DRangeScan>& scans)
const;
404 const std::vector<mrpt::obs::CObservation2DRangeScan>& scans);
460 std::vector<char>&
v2)
469 if (
e->traceRay(pNew, dist))
492 std::vector<mrpt::obs::CObservation2DRangeScan>&
vObs;
500 std::vector<mrpt::obs::CObservation2DRangeScan>& obs,
507 std::vector<double> yValues;
513 std::vector<double>
values;
514 std::vector<char> valid;
515 size_t nY = yValues.size();
519 yValues.begin(), yValues.end(),
527 for (
size_t i = 0; i <
values.size(); i++)
549 const TDoubleRange& yaws);
563 std::vector<double> yValues;
565 std::vector<float> scanValues;
566 std::vector<char> valid;
567 size_t nV = yaws.
amount();
568 scanValues.reserve(nV);
571 yValues.begin(), yValues.end(),
578 obs.
scan = scanValues;
589 std::vector<double> pValues;
591 std::vector<mrpt::obs::CObservation2DRangeScan> vObs;
592 vObs.reserve(pValues.size());
594 pValues.begin(), pValues.end(),
595 FTrace2D<T>(e, initial, caom, yaws, vObs, initial));
596 caom->mWireframe =
false;
597 caom->mEnableTransparency =
false;
598 caom->setPitchBounds(pValues);
599 caom->setScanSet(vObs);
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors.
This class is a "CSerializable" wrapper for "CMatrixBool".
Declares a matrix of booleans (non serializable).
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
float maxRange
The maximum range allowed by the device, in meters (e.g.
mrpt::utils::ContainerReadOnlyProxyAccessor< std::vector< char > > validRange
It's false (=0) on no reflected rays, referenced to elements in scan.
double deltaPitch
If the laser gathers data by sweeping in the pitch/elevation angle, this holds the increment in "pitc...
float aperture
The "aperture" or field-of-view of the range finder, in radians (typically M_PI = 180 degrees).
mrpt::poses::CPose3D sensorPose
The 6D pose of the sensor on the robot at the moment of starting the scan.
bool rightToLeft
The scanning direction: true=counterclockwise; false=clockwise.
mrpt::utils::ContainerReadOnlyProxyAccessor< std::vector< float > > scan
The range values of the scan, in meters.
void resizeScan(const size_t len)
Resizes all data vectors to allocate a given number of scan rays.
void setScanRangeValidity(const size_t i, const bool val)
void setScanRange(const size_t i, const float val)
Internal functor class to trace a ray.
void operator()(double yaw)
std::vector< double > & values
const mrpt::poses::CPose3D & initial
std::vector< char > & valid
FTrace1D(const T &s, const mrpt::poses::CPose3D &p, std::vector< double > &v, std::vector< char > &v2)
Internal functor class to trace a set of rays.
CAngularObservationMesh::Ptr & caom
void operator()(double pitch)
const mrpt::poses::CPose3D & pBase
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)
const CAngularObservationMesh::TDoubleRange & yaws
std::vector< mrpt::obs::CObservation2DRangeScan > & vObs
const mrpt::poses::CPose3D & initial
A mesh built from a set of 2D laser scan observations.
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.
CAngularObservationMesh()
Basic constructor.
mrpt::math::CMatrixB validityMatrix
Scan validity matrix.
void generateSetOfTriangles(CSetOfTriangles::Ptr &res) const
Gets the mesh as a set of triangles, for displaying them.
void setPitchBounds(const double initial, const double final)
Sets the pitch bounds for this range.
std::vector< CSetOfTriangles::TTriangle > triangles
Actual set of triangles to be displayed.
bool mWireframe
Whether the mesh will be displayed wireframe or solid.
mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D > actualMesh
Mutable object with the mesh's points.
void generatePointCloud(mrpt::maps::CPointsMap *out_map) const
Returns the scanned points as a 3D point cloud.
void getPitchBounds(double &initial, double &final) const
Gets the initial and final pitch bounds for this range.
void setWireframe(bool enabled=true)
Sets the display mode for the object.
bool meshUpToDate
Mutable variable which controls if the object has suffered any change since last time the mesh was up...
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.
void getTracedRays(CSetOfLines::Ptr &res) const
Gets a set of lines containing the traced rays, for displaying them.
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).
virtual ~CAngularObservationMesh()
Empty destructor.
bool mEnableTransparency
Whether the object may present transparencies or not.
void updateMesh() const
Updates the mesh, if needed.
bool isWireframe() const
Returns whether the object is configured as wireframe or solid.
std::vector< double > pitchBounds
Observation pitch range.
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.
void getActualMesh(mrpt::math::CMatrixTemplate< mrpt::math::TPoint3D > &pts, mrpt::math::CMatrixBool &validity) const
Retrieves the full mesh, along with the validity matrix.
std::vector< mrpt::obs::CObservation2DRangeScan > scanSet
Actual scan set which is used to generate the mesh.
std::shared_ptr< CAngularObservationMesh > Ptr
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...
virtual void render_dl() const override
Renderizes the object.
void getScanSet(std::vector< mrpt::obs::CObservation2DRangeScan > &scans) const
Gets the scan set.
void enableTransparency(bool enabled=true)
Enables or disables transparencies.
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).
bool setScanSet(const std::vector< mrpt::obs::CObservation2DRangeScan > &scans)
Sets the scan set.
bool isTransparencyEnabled() const
Returns whether the object may be transparent or not.
A renderizable object suitable for rendering with OpenGL's display lists.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
std::shared_ptr< CSetOfLines > Ptr
std::shared_ptr< CSetOfTriangles > Ptr
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
GLboolean GLenum GLenum GLvoid * values
GLfloat GLfloat GLfloat v2
GLubyte GLubyte GLubyte a
int sign(T x)
Returns the sign of X as "1" or "-1".
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Range specification type, with several uses.
TDoubleRange(double a, size_t b, bool c)
Constructor from aperture, amount of samples and scan direction.
double increment() const
Returns the increment between two consecutive values of the range.
double aperture() const
Returns the total aperture of the range.
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.
double initialValue() const
Returns the first value of the range.
TDoubleRange(double a, double b, double c)
Constructor from initial value, final value and range.
size_t amount() const
Returns the total amount of values in this range.
bool negToPos() const
Returns the direction of the scan.
double finalValue() const
Returns the last value of the range.
static TDoubleRange CreateFromIncrement(double initial, double final, double increment)
Creates a range of values from the initial value, the final value and the increment.
char rangeType
Range type.
void values(std::vector< double > &vals) const
Gets a vector with every value in the range.
union mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd rangeData
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.
TDoubleRange(double a, double b, size_t c)
Constructor from initial value, final value and amount of samples.
Union type with the actual data.
struct mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::@57 mode0
struct mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::@58 mode1
struct mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::@59 mode2