class mrpt::nav::CRobot2NavInterfaceForSimulator_DiffDriven

Overview

CRobot2NavInterface implemented for a simulator object based on mrpt::kinematics::CVehicleSimul_DiffDriven Only senseObstacles() remains virtual for the user to implement it.

See also:

CReactiveNavigationSystem, CAbstractNavigator, mrpt::kinematics::CVehicleSimulVirtualBase

#include <mrpt/nav/reactive/CRobot2NavInterfaceForSimulator.h>

class CRobot2NavInterfaceForSimulator_DiffDriven: public mrpt::nav::CRobot2NavInterface
{
public:
    // construction

    CRobot2NavInterfaceForSimulator_DiffDriven(mrpt::kinematics::CVehicleSimul_DiffDriven& simul);

    // methods

    virtual std::optional<CurrentPoseAndSpeeds> getCurrentPoseAndSpeeds();
    virtual bool changeSpeeds(const mrpt::kinematics::CVehicleVelCmd& vel_cmd);
    virtual bool stop(StopType stopType);
    virtual mrpt::kinematics::CVehicleVelCmd::Ptr getStopCmd();
    virtual mrpt::kinematics::CVehicleVelCmd::Ptr getEmergencyStopCmd();
    virtual double getNavigationTime();
    virtual void resetNavigationTimer();
};

Inherited Members

public:
    // structs

    struct TMsg;
    struct CurrentPoseAndSpeeds;

    // fields

    bool logging_enable_console_output {true};
    bool logging_enable_keep_record {false};

    // methods

    void logStr(const VerbosityLevel level, std::string_view msg_str) const;
    void logFmt(const VerbosityLevel level, const char* fmt, ...) const;
    void void logCond(const VerbosityLevel level, bool cond, const std::string& msg_str) const;
    void setLoggerName(const std::string& name);
    std::string getLoggerName() const;
    void setVerbosityLevel(const VerbosityLevel level);
    void setVerbosityLevelForCallbacks(const VerbosityLevel level);
    void setMinLoggingLevel(const VerbosityLevel level);
    VerbosityLevel getMinLoggingLevel() const;
    VerbosityLevel getMinLoggingLevelForCallbacks() const;
    bool isLoggingLevelVisible(VerbosityLevel level) const;
    void getLogAsString(std::string& log_contents) const;
    std::string getLogAsString() const;
    void writeLogToFile(const std::optional<std::string>& fname_in = std::nullopt) const;
    void dumpLogToConsole() const;
    std::string getLoggerLastMsg() const;
    void getLoggerLastMsg(std::string& msg_str) const;
    void loggerReset();
    void logRegisterCallback(output_logger_callback_t userFunc);
    bool logDeregisterCallback(output_logger_callback_t userFunc);
    COutputLogger& operator = (const COutputLogger&);
    COutputLogger& operator = (COutputLogger&&);
    static std::array<mrpt::system::ConsoleForegroundColor, NUMBER_OF_VERBOSITY_LEVELS>& logging_levels_to_colors();
    static const std::array<const char*, NUMBER_OF_VERBOSITY_LEVELS>& logging_levels_to_names();
    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(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 getStopCmd()

Gets the emergency stop command for the current robot.

Returns:

the emergency stop command

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

Gets the emergency stop command for the current robot.

Returns:

the emergency stop command

virtual double getNavigationTime()

See CRobot2NavInterface::getNavigationTime().

In this class, simulation time is returned instead of wall-clock time.

virtual void resetNavigationTimer()

See CRobot2NavInterface::resetNavigationTimer()