template class mrpt::viz::CGeneralizedEllipsoidTemplate

Overview

A class that generalizes the concept of an ellipsoid to arbitrary parameterizations of uncertainty shapes in either 2D or 3D.

See derived classes for examples.

Please read the documentation of CGeneralizedEllipsoidTemplate::setQuantiles() for learning the mathematical details about setting the desired confidence interval.

The main method to set the modeled uncertainty is setCovMatrixAndMean()

By default, only the front faces are rendered. Use cullFaces() to change if needed.

Parameters:

DIM

The dimensionality of the parameter space, which must coincide with that of the rendering space (2 or 3)

#include <mrpt/viz/CGeneralizedEllipsoidTemplate.h>

template <int DIM>
class CGeneralizedEllipsoidTemplate:
    public mrpt::viz::CVisualObject,
    public mrpt::viz::VisualObjectParams_Lines,
    public mrpt::viz::VisualObjectParams_Triangles
{
public:
    // typedefs

    typedef mrpt::math::CMatrixFixed<double, DIM, DIM> cov_matrix_t;
    typedef mrpt::math::CMatrixFixed<double, DIM, 1> mean_vector_t;
    typedef mrpt::math::CMatrixFixed<float, DIM, 1> array_parameter_t;
    typedef mrpt::math::CMatrixFixed<float, DIM, 1> array_point_t;

    // methods

    template <typename MATRIX, typename VECTOR>
    void setCovMatrixAndMean(
        const MATRIX& new_cov,
        const VECTOR& new_mean
        );

    cov_matrix_t getCovMatrix() const;

    template <typename MATRIX>
    void setCovMatrix(const MATRIX& new_cov);

    void setQuantiles(float q);
    float getQuantiles() const;
    void setNumberOfSegments(const uint32_t numSegments);
    uint32_t getNumberOfSegments() const;
    void enableDrawSolid3D(bool v);
    virtual bool traceRay(] const mrpt::poses::CPose3D& o, ] double& dist) const;
    virtual void updateBuffers() const;
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
};

// direct descendants

class CEllipsoid2D;
class CEllipsoid3D;
class CEllipsoidInverseDepth2D;
class CEllipsoidInverseDepth3D;
class CEllipsoidRangeBearing2D;
class CSphere;

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<CObject> Ptr;
    typedef std::shared_ptr<const CObject> ConstPtr;
    typedef std::unique_ptr<CObject> UniquePtr;
    typedef std::unique_ptr<const CObject> ConstUniquePtr;
    typedef std::shared_ptr<CSerializable> Ptr;
    typedef std::shared_ptr<const CSerializable> ConstPtr;
    typedef std::shared_ptr<CVisualObject> Ptr;
    typedef std::shared_ptr<const CVisualObject> ConstPtr;

    // structs

    struct BuffersVersion;
    struct ChangeCounter;
    struct PoseAndScale;
    struct State;

    // methods

    mrpt::rtti::CObject::Ptr duplicateGetSmartPtr() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual CObject* clone() const = 0;
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    void setName(const std::string& n);
    std::string getName() const;
    bool isVisible() const;
    void setVisibility(bool visible = true);
    bool castShadows() const;
    void castShadows(bool doCast);
    void enableShowName(bool showName = true);
    bool isShowNameEnabled() const;
    CVisualObject& setPose(const mrpt::poses::CPose3D& o);
    CVisualObject& setPose(const mrpt::poses::CPose2D& o);
    CVisualObject& setPose(const mrpt::math::TPose3D& o);
    CVisualObject& setPose(const mrpt::math::TPose2D& o);
    CVisualObject& setPose(const mrpt::poses::CPoint3D& o);
    CVisualObject& setPose(const mrpt::poses::CPoint2D& o);
    mrpt::math::TPose3D getPose() const;
    PoseAndScale getPoseAndScale() const;
    mrpt::poses::CPose3D getCPose() const;
    CVisualObject& setLocation(double x, double y, double z);
    CVisualObject& setLocation(const mrpt::math::TPoint3D& p);
    mrpt::img::TColorf getColor() const;
    mrpt::img::TColor getColor_u8() const;
    CVisualObject& setColorA(const float a);
    virtual CVisualObject& setColorA_u8(const uint8_t a);
    float materialShininess() const;
    void materialShininess(float shininess);
    float materialSpecularExponent() const;
    void materialSpecularExponent(float exponent);
    mrpt::img::TColorf materialEmissive() const;
    void materialEmissive(const mrpt::img::TColorf& color);
    CVisualObject& setScale(float s);
    CVisualObject& setScale(float sx, float sy, float sz);
    float getScaleX() const;
    float getScaleY() const;
    float getScaleZ() const;
    CVisualObject& setColor(const mrpt::img::TColorf& c);
    CVisualObject& setColor(float R, float G, float B, float A = 1);
    virtual CVisualObject& setColor_u8(const mrpt::img::TColor& c);
    CVisualObject& setColor_u8(uint8_t R, uint8_t G, uint8_t B, uint8_t A = 255);
    virtual bool cullElegible() const;
    virtual void toYAMLMap(mrpt::containers::yaml& propertiesMap) const;
    virtual bool isCompositeObject() const;
    virtual const std::deque<std::shared_ptr<CVisualObject>>& getInternalChildren() const;
    void notifyChange() const;
    void notifyTransformChange() const;
    void clearChangedFlag() const;
    void notifyBBoxChange() const;
    bool hasToUpdateBuffers() const;
    uint64_t dataVersion() const;
    uint64_t transformVersion() const;
    bool hasToUpdateBuffersSince(uint64_t sinceVersion) const;
    void updateBuffersIfNeeded() const;
    virtual void updateBuffers() const;
    virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const;
    auto getBoundingBox() const;
    auto getBoundingBoxLocal() const;
    auto getBoundingBoxLocalf() const;
    virtual mrpt::math::TPoint3Df getLocalRepresentativePoint() const;
    void setLocalRepresentativePoint(const mrpt::math::TPoint3Df& p);
    mrpt::viz::CText& labelObject() const;
    std::shared_ptr<mrpt::viz::CText> labelObjectPtr() const;
    const auto& shaderLinesVertexPointBuffer() const;
    const auto& shaderLinesVertexColorBuffer() const;
    auto& shaderLinesBufferMutex() const;
    void setLineWidth(float w);
    float getLineWidth() const;
    void enableAntiAliasing(bool enable = true);
    bool isAntiAliasingEnabled() const;
    const auto& shaderTrianglesBuffer() const;
    auto& shaderTrianglesBufferMutex() const;
    bool isLightEnabled() const;
    void enableLight(bool enable = true);
    void cullFaces(const TCullFace& cf);
    TCullFace cullFaces() const;

Typedefs

typedef mrpt::math::CMatrixFixed<double, DIM, DIM> cov_matrix_t

The type of fixed-size covariance matrices for this representation.

typedef mrpt::math::CMatrixFixed<double, DIM, 1> mean_vector_t

The type of fixed-size vector for this representation.

Methods

template <typename MATRIX, typename VECTOR>
void setCovMatrixAndMean(
    const MATRIX& new_cov,
    const VECTOR& new_mean
    )

Set the NxN covariance matrix that will determine the aspect of the ellipsoid - Notice that the covariance determines the uncertainty in the parameter space, which would be transformed by derived function.

cov_matrix_t getCovMatrix() const

Gets the current uncertainty covariance of parameter space.

template <typename MATRIX>
void setCovMatrix(const MATRIX& new_cov)

Like setCovMatrixAndMean(), for mean=zero.

void setQuantiles(float q)

Changes the scale of the “sigmas” for drawing the ellipse/ellipsoid (default=3, ~97 or ~98% CI); the exact mathematical meaning is: This value of “quantiles” q should be set to the square root of the chi-squared inverse cdf corresponding to the desired confidence interval.

Note that this value depends on the dimensionality. Refer to the MATLAB functions chi2inv() and chi2cdf().

Some common values follow here for the convenience of users:

  • Dimensionality=3 (3D ellipsoids):

    • 19.8748% CI -> q=1

    • 73.8536% CI -> q=2

    • 97.0709% CI -> q=3

    • 99.8866% CI -> q=4

  • Dimensionality=2 (2D ellipses):

    • 39.347% CI -> q=1

    • 86.466% CI -> q=2

    • 98.8891% CI -> q=3

    • 99.9664% CI -> q=4

  • Dimensionality=1 (Not aplicable to this class but provided for reference):

    • 68.27% CI -> q=1

    • 95.45% CI -> q=2

    • 99.73% CI -> q=3

    • 99.9937% CI -> q=4

float getQuantiles() const

Refer to documentation of setQuantiles()

void setNumberOfSegments(const uint32_t numSegments)

Set the number of segments of the surface/curve (higher means with greater resolution)

void enableDrawSolid3D(bool v)

If set to “true”, a whole ellipsoid surface will be drawn, or if set to “false” (default) it will be drawn as a “wireframe”.

virtual bool traceRay(] const mrpt::poses::CPose3D& o, ] double& dist) const

Ray tracing

virtual void updateBuffers() const

Called by the rendering system to update internal geometry buffers.

Derived classes should override this to populate their data buffers (triangles, points, lines) when the object geometry changes.

This is called automatically when hasToUpdateBuffers() returns true, which happens after notifyChange() was called.

The base implementation does nothing; derived classes should override.

Thread safety: implementations should lock the appropriate mutexes when writing to shared buffers.

virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const

Returns information about the class of an object in runtime.