struct mrpt::math::TTwist2D

2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)

See also:

mrpt::math::TTwist3D, mrpt::math::TPose2D

#include <mrpt/math/TTwist2D.h>

struct TTwist2D: public mrpt::math::internal::ProvideStaticResize
{
    // enums

    enum
    {
        static_size = 3,
    };

    //
fields

    double vx {.0};
    double vy {.0};
    double omega {.0};

    // construction

    TTwist2D(double vx_, double vy_, double omega_);
    TTwist2D();

    //
methods

    double& operator [] (size_t i);
    constexpr double operator [] (size_t i) const;

    template <typename Vector>
    void asVector(Vector& v) const;

    template <typename Vector>
    Vector asVector() const;

    void rotate(const double ang);
    TTwist2D rotated(const double ang) const;
    bool operator == (const TTwist2D& o) const;
    bool operator != (const TTwist2D& o) const;
    mrpt::math::TPose2D operator * (const double dt) const;
    void operator *= (const double k);
    void asString(std::string& s) const;
    std::string asString() const;
    void fromString(const std::string& s);

    template <typename Vector>
    static TTwist2D FromVector(const Vector& v);

    static TTwist2D FromString(const std::string& s);
};

Inherited Members

public:
    //
methods

    void resize(std::size_t n);

Fields

double vx {.0}

Velocity components: X,Y (m/s)

double omega {.0}

Angular velocity (rad/s)

Construction

TTwist2D(double vx_, double vy_, double omega_)

Constructor from components.

TTwist2D()

Default fast constructor.

Initializes to zeros

Methods

double& operator [] (size_t i)

Coordinate access using operator[].

Order: vx,vy,vphi

constexpr double operator [] (size_t i) const

Coordinate access using operator[].

Order: vx,vy,vphi

template <typename Vector>
void asVector(Vector& v) const

Gets the twist as a vector of doubles.

Parameters:

Vector

It can be std::vector<double>, Eigen::VectorXd, etc.

template <typename Vector>
Vector asVector() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void rotate(const double ang)

Transform the (vx,vy) components for a counterclockwise rotation of ang radians.

TTwist2D rotated(const double ang) const

Like rotate(), but returning a copy of the rotated twist.

New in MRPT 2.3.2

mrpt::math::TPose2D operator * (const double dt) const

Returns the pose increment of multiplying each twist component times “dt” seconds.

void operator *= (const double k)

Scale factor.

void asString(std::string& s) const

Returns a human-readable textual representation of the object (eg: “[vx vy omega]”, omega in deg/s)

See also:

fromString

void fromString(const std::string& s)

Set the current object value from a string generated by ‘asString’ (eg: “[0.02 1.04 -45.0]” )

Parameters:

std::exception

On invalid format

See also:

asString

template <typename Vector>
static TTwist2D FromVector(const Vector& v)

Builds from the first 3 elements of a vector-like object: [vx vy w].

Parameters:

Vector

It can be std::vector<double>, Eigen::VectorXd, etc.