class mrpt::nav::CAbstractNavigator

This is the base class for any reactive/planned navigation system.

See derived classes.

How to use:

  • A class derived from CRobot2NavInterface with callbacks must be defined by the user and provided to the constructor.

  • navigationStep() must be called periodically in order to effectively run the navigation. This method will internally call the callbacks to gather sensor data and robot positioning data.

It implements the following state machine (see CAbstractNavigator::getCurrentState()), taking into account the extensions described in CWaypointsNavigator digraph CAbstractNavigator_States {

IDLE; NAVIGATING; SUSPENDED; NAV_ERROR; IDLE -> NAVIGATING [ label=”CAbstractNavigator::navigate()”]; IDLE -> NAVIGATING [ label=”CWaypointsNavigator::navigateWaypoints()” ]; NAVIGATING -> IDLE [ label=”Final target reached” ]; NAVIGATING -> IDLE [ label=”CAbstractNavigator::cancel()” ]; NAVIGATING -> NAV_ERROR [ label=”Upon sensor errors, timeout,…” ]; NAVIGATING -> SUSPENDED [ label=”CAbstractNavigator::suspend()” ]; SUSPENDED -> NAVIGATING [ label=”CAbstractNavigator::resume()” ]; NAV_ERROR -> IDLE [ label=”CAbstractNavigator::resetNavError()” ];

}

See also:

CWaypointsNavigator, CReactiveNavigationSystem, CRobot2NavInterface, all children classes

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

class CAbstractNavigator: public mrpt::system::COutputLogger
{
public:
    // enums

    enum TErrorCode;
    enum TState;

    // structs

    struct TAbstractNavigatorParams;
    struct TErrorReason;
    struct TNavigationParams;
    struct TNavigationParamsBase;
    struct TRobotPoseVel;
    struct TargetInfo;

    //
fields

    mrpt::system::CTimeLogger m_navProfiler {        false, "mrpt::nav::CAbstractNavigator"};

    // construction

    CAbstractNavigator(CRobot2NavInterface& robot_interface_impl);

    //
methods

    virtual void loadConfigFile(const mrpt::config::CConfigFileBase& c);
    virtual void saveConfigFile(mrpt::config::CConfigFileBase& c) const;
    virtual void initialize() = 0;
    virtual void navigationStep();
    virtual void navigate(const TNavigationParams* params);
    virtual void cancel();
    virtual void resume();
    virtual void suspend();
    virtual void resetNavError();
    TState getCurrentState() const;
    const TErrorReason& getErrorReason() const;
    void setFrameTF(const std::weak_ptr<mrpt::poses::FrameTransformer<2>>& frame_tf);
    std::weak_ptr<mrpt::poses::FrameTransformer<2>> getFrameTF() const;
    void enableRethrowNavExceptions(const bool enable);
    const mrpt::system::CTimeLogger& getDelaysTimeLogger() const;
};

// direct descendants

class CNavigatorManualSequence;
class CWaypointsNavigator;

Inherited Members

public:
    // structs

    struct TMsg;

Fields

mrpt::system::CTimeLogger m_navProfiler {       false, "mrpt::nav::CAbstractNavigator"}

Publicly available time profiling object.

Default: disabled

Construction

CAbstractNavigator(CRobot2NavInterface& robot_interface_impl)

ctor

Methods

virtual void loadConfigFile(const mrpt::config::CConfigFileBase& c)

Loads all params from a file.

To be called before initialize(). Each derived class MUST load its own parameters, and then call ITS PARENT’S overriden method to ensure all params are loaded.

virtual void saveConfigFile(mrpt::config::CConfigFileBase& c) const

Saves all current options to a config file.

Each derived class MUST save its own parameters, and then call ITS PARENT’S overriden method to ensure all params are saved.

virtual void initialize() = 0

Must be called before any other navigation command.

virtual void navigationStep()

This method must be called periodically in order to effectively run the navigation.

virtual void navigate(const TNavigationParams* params)

Navigation request to a single target location.

It starts a new navigation. A pointer is used so the passed object can be polymorphic with derived types.

Parameters:

params

Pointer to structure with navigation info (its contents will be copied, so the original can be freely destroyed upon return if it was dynamically allocated.)

virtual void cancel()

Cancel current navegation.

virtual void resume()

Continues with suspended navigation.

See also:

suspend

virtual void suspend()

Suspend current navegation.

See also:

resume

virtual void resetNavError()

Resets a NAV_ERROR state back to IDLE

TState getCurrentState() const

Returns the current navigator state.

const TErrorReason& getErrorReason() const

In case of state=NAV_ERROR, this returns the reason for the error.

Error state is reseted every time a new navigation starts with a call to navigate(), or when resetNavError() is called.

void setFrameTF(const std::weak_ptr<mrpt::poses::FrameTransformer<2>>& frame_tf)

Sets a user-provided frame transformer object; used only if providing targets in a frame ID different than the one in which robot odometry is given (both IDs default to "map").

std::weak_ptr<mrpt::poses::FrameTransformer<2>> getFrameTF() const

Get the current frame tf object (defaults to nullptr)

See also:

setFrameTF

void enableRethrowNavExceptions(const bool enable)

By default, error exceptions on navigationStep() will dump an error message to the output logger interface.

If rethrow is enabled (default=false), the error message will be reported as well, but exceptions will be re-thrown.

const mrpt::system::CTimeLogger& getDelaysTimeLogger() const

Gives access to a const-ref to the internal time logger used to estimate delays.

See also:

getTimeLogger() in derived classes