struct MinimalRobotIF

Overview

Unit tests for TWaypoint / TWaypointSequence data structures and PlannerRRT_SE2_TPS, exercised in isolation.

struct MinimalRobotIF: public mrpt::nav::CRobot2NavInterface
{
    // fields

    mrpt::math::TPose2D pose {0, 0, 0};
    int changeSpeeds_call_count {0};
    int stop_call_count {0};
    double nav_time {0};

    // methods

    virtual std::optional<CurrentPoseAndSpeeds> getCurrentPoseAndSpeeds();
    virtual bool changeSpeeds(const mrpt::kinematics::CVehicleVelCmd& vel_cmd);
    virtual bool stop(mrpt::nav::StopType stopType);
    virtual mrpt::kinematics::CVehicleVelCmd::Ptr getEmergencyStopCmd();
    virtual mrpt::kinematics::CVehicleVelCmd::Ptr getStopCmd();
    virtual bool senseObstacles(mrpt::maps::CSimplePointsMap& obstacles, mrpt::system::TTimeStamp& timestamp);
    virtual double getNavigationTime();
    virtual void resetNavigationTimer();
};

Inherited Members

public:
    // structs

    struct TMsg;
    struct CurrentPoseAndSpeeds;

    // methods

    COutputLogger& operator = (const COutputLogger&);
    COutputLogger& operator = (COutputLogger&&);
    virtual void sendNavigationStartEvent();
    virtual void sendNavigationEndEvent();
    virtual void sendWaypointReachedEvent(int waypoint_index, bool reached_nSkipped);
    virtual void sendNewWaypointTargetEvent(int waypoint_index);
    virtual void sendNavigationEndDueToErrorEvent();
    virtual void sendWaySeemsBlockedEvent();
    virtual void sendApparentCollisionEvent();
    virtual void sendCannotGetCloserToBlockedTargetEvent();
    virtual std::optional<CurrentPoseAndSpeeds> getCurrentPoseAndSpeeds() = 0;
    virtual bool changeSpeeds(const mrpt::kinematics::CVehicleVelCmd& vel_cmd) = 0;
    virtual bool changeSpeedsNOP();
    virtual bool stop(StopType stopType = StopType::Emergency) = 0;
    bool stop(bool isEmergencyStop);
    virtual mrpt::kinematics::CVehicleVelCmd::Ptr getEmergencyStopCmd() = 0;
    virtual mrpt::kinematics::CVehicleVelCmd::Ptr getStopCmd() = 0;
    virtual mrpt::kinematics::CVehicleVelCmd::Ptr getAlignCmd(const double relative_heading_radians);
    virtual bool startWatchdog(float T_ms);
    virtual bool stopWatchdog();
    virtual bool senseObstacles(mrpt::maps::CSimplePointsMap& obstacles, mrpt::system::TTimeStamp& timestamp) = 0;
    virtual double getNavigationTime();
    virtual void resetNavigationTimer();

Methods

virtual std::optional<CurrentPoseAndSpeeds> getCurrentPoseAndSpeeds()

Get the current pose and velocity of the robot.

The implementation should not take too much time to return, so if it might take more than ~10ms to ask the robot for the instantaneous data, it may be good enough to return the latest values from a cache which is updated in a parallel thread.

Returns:

The current pose and speeds, or std::nullopt on error.

virtual bool changeSpeeds(const mrpt::kinematics::CVehicleVelCmd& vel_cmd)

Sends a velocity command to the robot.

The number components in each command depends on children classes of mrpt::kinematics::CVehicleVelCmd. One robot may accept one or more different CVehicleVelCmd classes. This method resets the watchdog timer (that may be or may be not implemented in a particular robotic platform) started with startWatchdog()

Returns:

false on any error.

See also:

startWatchdog

virtual bool stop(mrpt::nav::StopType stopType)

Stop the robot right now.

Parameters:

stopType

Whether this is a normal stop (e.g. target reached) or an emergency stop due to an unexpected error.

Returns:

false on any error.

virtual mrpt::kinematics::CVehicleVelCmd::Ptr getEmergencyStopCmd()

Gets the emergency stop command for the current robot.

Returns:

the emergency stop command

virtual mrpt::kinematics::CVehicleVelCmd::Ptr getStopCmd()

Gets the emergency stop command for the current robot.

Returns:

the emergency stop command

virtual bool senseObstacles(mrpt::maps::CSimplePointsMap& obstacles, mrpt::system::TTimeStamp& timestamp)

Return the current set of obstacle points, as seen from the local coordinate frame of the robot.

Parameters:

obstacles

A representation of obstacles in robot-centric coordinates.

timestamp

The timestamp for the read obstacles. Use mrpt::Clock::now() unless you have something more accurate.

Returns:

false on any error.

virtual double getNavigationTime()

Returns the number of seconds ellapsed since the constructor of this class was invoked, or since the last call of resetNavigationTimer().

This will be normally wall-clock time, except in simulators where this method will return simulation time.

virtual void resetNavigationTimer()

see getNavigationTime()