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