class mrpt::kinematics::CVehicleSimulVirtualBase

Python API: mrpt.kinematics.CVehicleSimulVirtualBase

Overview

Virtual base for planar vehicle kinematic simulators (see CVehicleSimul_DiffDriven, CVehicleSimul_Holo), including odometry errors.

Main API methods are:

  • sendVelCmd() : sends a velocity command to the vehicle, whose dynamics depend on the derived class.

  • simulateOneTimeStep() : runs the simulator for a given time period.

#include <mrpt/kinematics/CVehicleSimulVirtualBase.h>

class CVehicleSimulVirtualBase
{
public:
    // construction

    CVehicleSimulVirtualBase();

    // methods

    void simulateOneTimeStep(const double dt);
    const mrpt::math::TPose2D& getCurrentGTPose() const;
    void setCurrentGTPose(const mrpt::math::TPose2D& pose);
    const mrpt::math::TPose2D& getCurrentOdometricPose() const;

    template <typename T>
    void setCurrentOdometricPose(const T& pose);

    const mrpt::math::TTwist2D& getCurrentGTVel() const;
    mrpt::math::TTwist2D getCurrentGTVelLocal() const;
    const mrpt::math::TTwist2D& getCurrentOdometricVel() const;
    mrpt::math::TTwist2D getCurrentOdometricVelLocal() const;
    double getTime() const;
    virtual void sendVelCmd(const CVehicleVelCmd& cmd_vel) = 0;
    virtual CVehicleVelCmd::Ptr getVelCmdType() const = 0;

    void setOdometryErrors(
        bool enabled,
        double Ax_err_bias = 1e-3,
        double Ax_err_std = 10e-3,
        double Ay_err_bias = 1e-3,
        double Ay_err_std = 10e-3,
        double Aphi_err_bias = mrpt::DEG2RAD(1e-3),
        double Aphi_err_std = mrpt::DEG2RAD(10e-3)
        );

    void resetStatus();
    void resetTime();
};

// direct descendants

class CVehicleSimul_DiffDriven;
class CVehicleSimul_Holo;

Methods

void simulateOneTimeStep(const double dt)

Runs the simulator during “dt” seconds.

It will be split into periods of “m_firmware_control_period”, the last one shortened to end exactly at the requested time. Non-positive values of dt have no effect.

const mrpt::math::TPose2D& getCurrentGTPose() const

Returns the instantaneous, ground truth pose in world coordinates.

void setCurrentGTPose(const mrpt::math::TPose2D& pose)

Brute-force move robot to target coordinates (“teleport”)

const mrpt::math::TPose2D& getCurrentOdometricPose() const

Returns the current pose according to (noisy) odometry.

See also:

setOdometryErrors

template <typename T>
void setCurrentOdometricPose(const T& pose)

Brute-force overwrite robot odometry

const mrpt::math::TTwist2D& getCurrentGTVel() const

Returns the instantaneous, ground truth velocity vector (vx,vy,omega) in world coordinates.

With odometry errors enabled, this is the noise-free commanded velocity, not the rate of change of the ground truth pose.

mrpt::math::TTwist2D getCurrentGTVelLocal() const

Returns the instantaneous, ground truth velocity vector (vx,vy,omega) in the robot local frame.

const mrpt::math::TTwist2D& getCurrentOdometricVel() const

Returns the instantaneous, odometric velocity vector (vx,vy,omega) in the odometry frame of reference.

mrpt::math::TTwist2D getCurrentOdometricVelLocal() const

Returns the instantaneous, odometric velocity vector (vx,vy,omega) in the robot local frame.

double getTime() const

Get the current simulation time.

virtual void sendVelCmd(const CVehicleVelCmd& cmd_vel) = 0

Sends a velocity command to the robot.

The number of components and their meaning depends on the vehicle-kinematics derived class

virtual CVehicleVelCmd::Ptr getVelCmdType() const = 0

Gets an empty velocity command object that can be queried to find out the number of velcmd components,…

void setOdometryErrors(
    bool enabled,
    double Ax_err_bias = 1e-3,
    double Ax_err_std = 10e-3,
    double Ay_err_bias = 1e-3,
    double Ay_err_std = 10e-3,
    double Aphi_err_bias = mrpt::DEG2RAD(1e-3),
    double Aphi_err_std = mrpt::DEG2RAD(10e-3)
    )

Enable/Disable odometry errors.

Errors are relative factors applied to the displacement in the vehicle frame (x: forward, y: left, phi: heading change). Bias values are relative errors; std values are the 1-sigma relative errors accumulated over 1 second of motion (Gaussian white noise, independent of the internal control period). All of them are dimensionless: the DEG2RAD() in the default Aphi values is not a unit conversion.

void resetStatus()

Reset all simulator variables to 0 (except the simulation time).

See also:

resetTime

void resetTime()

Reset time counter.

See also:

resetStatus