class mrpt::opengl::CPlanarLaserScan

This object renders a 2D laser scan by means of three elements: the points, the line along end-points and the 2D scanned surface.

By default, all those three elements are drawn, but you can individually switch them on/off with:

To change the final result, more methods allow further customization of the 3D object (color of each element, etc.).

The scan is passed or updated through CPlanarLaserScan::setScan()

The laser points are projected at the sensor pose as given in the “scan” object, so this CPlanarLaserScan object should be placed at the exact pose of the robot coordinates origin.

See also:

mrpt::opengl::CPointCloud, opengl::COpenGLScene

#include <mrpt/opengl/CPlanarLaserScan.h>

class CPlanarLaserScan:
    public mrpt::opengl::CRenderizableShaderPoints,
    public mrpt::opengl::CRenderizableShaderTriangles,
    public mrpt::opengl::CRenderizableShaderWireFrame
{
public:
    // construction

    CPlanarLaserScan();

    //
methods

    virtual void render(const RenderContext& rc) const;
    virtual void renderUpdateBuffers() const;
    virtual void freeOpenGLResources();
    virtual shader_list_t requiredShaders() const;
    virtual void onUpdateBuffers_Wireframe();
    virtual void onUpdateBuffers_Triangles();
    virtual void onUpdateBuffers_Points();
    virtual mrpt::math::TPoint3Df getLocalRepresentativePoint() const;
    void clear();
    void enablePoints(bool enable = true);
    void enableLine(bool enable = true);
    void enableSurface(bool enable = true);

    void setLineColor(
        float R,
        float G,
        float B,
        float A = 1.0f
        );

    void setPointsColor(
        float R,
        float G,
        float B,
        float A = 1.0f
        );

    void setSurfaceColor(
        float R,
        float G,
        float B,
        float A = 1.0f
        );

    void setScan(const mrpt::obs::CObservation2DRangeScan& scan);
    virtual auto internalBoundingBoxLocal() const;
};

Inherited Members

public:
    // structs

    struct RenderContext;
    struct State;

    //
methods

    virtual void render(const RenderContext& rc) const = 0;
    virtual void renderUpdateBuffers() const = 0;
    virtual shader_list_t requiredShaders() const;
    virtual void freeOpenGLResources() = 0;
    virtual void onUpdateBuffers_Points() = 0;
    virtual void onUpdateBuffers_Triangles() = 0;
    virtual void onUpdateBuffers_Wireframe() = 0;

Methods

virtual void render(const RenderContext& rc) const

Implements the rendering of 3D objects in each class derived from CRenderizable.

This can be called more than once (one per required shader program) if the object registered several shaders.

See also:

renderUpdateBuffers

virtual void renderUpdateBuffers() const

Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.

before they are sent for rendering in render()

virtual void freeOpenGLResources()

Free opengl buffers.

virtual shader_list_t requiredShaders() const

Returns the ID of the OpenGL shader program required to render this class.

See also:

DefaultShaderID

virtual void onUpdateBuffers_Wireframe()

Must be implemented in derived classes to update the geometric entities to be drawn in “m_*_buffer” fields.

virtual void onUpdateBuffers_Triangles()

Must be implemented in derived classes to update the geometric entities to be drawn in “m_*_buffer” fields.

virtual void onUpdateBuffers_Points()

Must be implemented in derived classes to update the geometric entities to be drawn in “m_*_buffer” fields.

virtual mrpt::math::TPoint3Df getLocalRepresentativePoint() const

Provide a representative point (in object local coordinates), used to sort objects by eye-distance while rendering with transparencies (Default=[0,0,0])

void clear()

Clear the scan.

void enablePoints(bool enable = true)

Show or hides the scanned points.

See also:

sePointsWidth, setPointsColor

void enableLine(bool enable = true)

Show or hides lines along all scanned points.

See also:

setLineWidth, setLineColor

void enableSurface(bool enable = true)

Show or hides the scanned area as a 2D surface.

See also:

setSurfaceColor

virtual auto internalBoundingBoxLocal() const

Must be implemented by derived classes to provide the updated bounding box in the object local frame of coordinates.

This will be called only once after each time the derived class reports to notifyChange() that the object geometry changed.

See also:

getBoundingBox(), getBoundingBoxLocal(), getBoundingBoxLocalf()