123 double initial,
double final,
double increment)
126 throw std::logic_error(
"Invalid increment value.");
134 double initial,
double final,
size_t amount)
169 throw std::logic_error(
"Unknown range type.");
188 throw std::logic_error(
"Unknown range type.");
213 throw std::logic_error(
"Unknown range type.");
238 throw std::logic_error(
"Unknown range type.");
254 ? 1 +
static_cast<size_t>(ceil(
264 throw std::logic_error(
"Unknown range type.");
271 void values(std::vector<double>& vals)
const;
290 throw std::logic_error(
"Unknown range type.");
325 std::vector<mrpt::obs::CObservation2DRangeScan>
scanSet;
369 void render(
const RenderContext& rc)
const override;
407 std::vector<mrpt::obs::CObservation2DRangeScan>& scans)
const;
412 const std::vector<mrpt::obs::CObservation2DRangeScan>& scans);
468 std::vector<char>& v2)
477 if (
e->traceRay(pNew, dist))
500 std::vector<mrpt::obs::CObservation2DRangeScan>&
vObs;
508 std::vector<mrpt::obs::CObservation2DRangeScan>& obs,
515 std::vector<double> yValues;
521 std::vector<double> values;
522 std::vector<char> valid;
523 size_t nY = yValues.size();
527 yValues.begin(), yValues.end(),
535 for (
size_t i = 0; i < values.size(); i++)
557 const TDoubleRange& yaws);
571 std::vector<double> yValues;
575 size_t nV = yaws.
amount();
576 scanValues.reserve(nV);
579 yValues.begin(), yValues.end(),
586 for (
size_t i = 0; i < nV; i++)
600 std::vector<double> pValues;
602 std::vector<mrpt::obs::CObservation2DRangeScan> vObs;
603 vObs.reserve(pValues.size());
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);
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.
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.
struct mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::@8 mode2
Trivially copiable underlying data for TPoint3D 1-byte memory packed, no padding].
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)
TDoubleRange(double a, size_t b, bool c)
Constructor from aperture, amount of samples and scan direction.
void freeOpenGLResources() override
Free opengl buffers.
void setScanRange(const size_t i, const float val)
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
const mrpt::poses::CPose3D & initial
char rangeType
Range type.
Renderizable generic renderer for objects using the triangles shader.
struct mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::@7 mode1
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.
std::vector< shader_id_t > shader_list_t
A list of shader IDs.
std::vector< mrpt::opengl::TTriangle > triangles
Actual set of triangles to be displayed.
bool isTransparencyEnabled() const
Returns whether the object may be transparent or not.
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.
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.
void operator()(double pitch)
double finalValue() const
Returns the last value of the range.
mrpt::math::CMatrixDynamic< mrpt::math::TPoint3D_data< double > > actualMesh
Mutable object with the mesh's points.
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.
static constexpr shader_id_t WIREFRAME
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
struct mrpt::opengl::CAngularObservationMesh::TDoubleRange::rd::@6 mode0
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)
int sign(T x)
Returns the sign of X as "1" or "-1".
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.
double increment() const
Returns the increment between two consecutive values of the range.
void onUpdateBuffers_Triangles() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
static constexpr shader_id_t TRIANGLES
std::vector< double > & values
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).
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.
void freeOpenGLResources() override
Free opengl buffers.
~CAngularObservationMesh() override=default
Empty destructor.
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).
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...
Renderizable generic renderer for objects using the wireframe shader.
double deltaPitch
If the laser gathers data by sweeping in the pitch/elevation angle, this holds the increment in "pitc...
void onUpdateBuffers_Wireframe() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
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".
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.
TDoubleRange(double a, double b, double c)
Constructor from initial value, final value and range.
void updateMesh() const
Updates the mesh, if needed.
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
CAngularObservationMesh::Ptr & caom
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).
void freeOpenGLResources() override
Free opengl buffers.
const mrpt::poses::CPose3D & initial
virtual shader_list_t requiredShaders() const override
Returns the ID of the OpenGL shader program required to render this class.
bool setScanSet(const std::vector< mrpt::obs::CObservation2DRangeScan > &scans)
Sets the scan set.
This template class provides the basic functionality for a general 2D any-size, resizable container o...
bool m_Wireframe
Whether the mesh will be displayed wireframe or solid.
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)