class mrpt::nav::CReactiveNavigationSystem

Overview

2-D PTG-based reactive navigation system for robots with a polygonal or circular footprint.

Implements CAbstractPTGBasedReactive for flat-terrain mobile robots. The robot shape is defined either as a polygon (changeRobotShape()) or as a circle radius (changeRobotCircularShapeRadius()). Obstacles are gathered from the CRobot2NavInterface callbacks and represented as a 2-D point cloud in the local robot frame before being projected into TP-Space.

Configuration is loaded from an INI-like file; a template can be generated with saveConfigFile() on a default-constructed object.

See base class CAbstractPTGBasedReactive for a description and instructions of use. This particular implementation assumes a 2D robot shape which can be polygonal or circular (depending on the selected PTGs).

Publications:

Class history:

  • 17/JUN/2004: First design.

  • 16/SEP/2004: Totally redesigned, according to document “MultiParametric Based Space Transformation for Reactive Navigation”

  • 29/SEP/2005: Totally rewritten again, for integration into MRPT library and according to the ICRA paper.

  • 17/OCT/2007: Whole code updated to accommodate to MRPT 0.5 and make it portable to Linux.

  • DEC/2013: Code refactoring between this class and CAbstractHolonomicReactiveMethod

  • FEB/2017: Refactoring of all parameters for a consistent organization in sections by class names (MRPT 1.5.0)

This class requires a number of parameters which are usually provided via an external config (“.ini”) file. Alternatively, a memory-only object can be used to avoid physical files, see mrpt::config::CConfigFileMemory.

A template config file can be generated at any moment by the user by calling saveConfigFile() with a default-constructed object.

Next we provide a self-documented template config file; or see it online: https://github.com/MRPT/mrpt/blob/master/share/mrpt/config_files/navigation-ptgs/reactive2d_config.ini

See also:

CAbstractNavigator, CParameterizedTrajectoryGenerator, CAbstractHolonomicReactiveMethod

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

class CReactiveNavigationSystem: public mrpt::nav::CAbstractPTGBasedReactive
{
public:
    // structs

    struct TReactiveNavigatorParams;

    // fields

    TReactiveNavigatorParams params_reactive_nav;

    // construction

    CReactiveNavigationSystem(
        CRobot2NavInterface& react_iterf_impl,
        bool enableConsoleOutput = true,
        bool enableLogFile = false,
        const std::string& logFileDirectory = std::string("./reactivenav.logs")
        );

    // methods

    void changeRobotShape(const mrpt::math::CPolygon& shape);
    void changeRobotCircularShapeRadius(const double R);
    virtual size_t getPTG_count() const;
    virtual CParameterizedTrajectoryGenerator* getPTG(size_t i);
    virtual const CParameterizedTrajectoryGenerator* getPTG(size_t i) const;
    virtual bool checkCollisionWithLatestObstacles(const mrpt::math::TPose2D& relative_robot_pose) const;
    virtual void loadConfigFile(const mrpt::config::CConfigFileBase& c);
    virtual void saveConfigFile(mrpt::config::CConfigFileBase& c) const;
};

Inherited Members

public:
    // enums

    enum TErrorCode;
    enum TState;

    // structs

    struct TMsg;
    struct TAbstractNavigatorParams;
    struct TErrorReason;
    struct TNavigationParams;
    struct TNavigationParamsBase;
    struct TRobotPoseVel;
    struct TargetInfo;
    struct TNavigationParamsWaypoints;
    struct TWaypointsNavigatorParams;
    struct PTGTarget;
    struct TAbstractPTGNavigatorParams;
    struct TInfoPerPTG;
    struct TNavigationParamsPTG;
    struct TSentVelCmd;

    // classes

    class WaypointsAccessGuard;

    // fields

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

    // methods

    COutputLogger& operator = (const COutputLogger&);
    COutputLogger& operator = (COutputLogger&&);
    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;
    virtual void loadConfigFile(const mrpt::config::CConfigFileBase& c);
    virtual void saveConfigFile(mrpt::config::CConfigFileBase& c) const;
    virtual void navigateWaypoints(const TWaypointSequence& nav_request);
    virtual void getWaypointNavStatus(TWaypointStatusSequence& out_nav_status) const;
    TWaypointStatusSequence getWaypointNavStatus() const;
    WaypointsAccessGuard getWaypointsAccessGuard();
    virtual void initialize();
    void setHolonomicMethod(const std::string& method, const mrpt::config::CConfigFileBase& cfgBase);
    void getLastLogRecord(CLogFileRecord& o);
    void enableKeepLogRecords(bool enable = true);
    void enableLogFile(bool enable);
    void setLogFileDirectory(const std::string& sDir);
    virtual void loadConfigFile(const mrpt::config::CConfigFileBase& c);
    virtual void saveConfigFile(mrpt::config::CConfigFileBase& c) const;
    void enableTimeLog(bool enable = true);
    const mrpt::system::CTimeLogger& getTimeLogger() const;
    virtual size_t getPTG_count() const = 0;
    virtual CParameterizedTrajectoryGenerator* getPTG(size_t i) = 0;
    virtual const CParameterizedTrajectoryGenerator* getPTG(size_t i) const = 0;
    const mrpt::kinematics::CVehicleVelCmd::TVelCmdParams& getCurrentRobotSpeedLimits() const;
    mrpt::kinematics::CVehicleVelCmd::TVelCmdParams& changeCurrentRobotSpeedLimits();
    void setTargetApproachSlowDownDistance(const double dist);
    double getTargetApproachSlowDownDistance() const;
    virtual void navigationStep();
    virtual void cancel();
    bool isRelativePointReachable(const mrpt::math::TPoint2D& wp_local_wrt_robot) const;

Construction

CReactiveNavigationSystem(
    CRobot2NavInterface& react_iterf_impl,
    bool enableConsoleOutput = true,
    bool enableLogFile = false,
    const std::string& logFileDirectory = std::string("./reactivenav.logs")
    )

Constructor.

Parameters:

react_iterf_impl

User-supplied robot interface (callbacks).

enableConsoleOutput

If true, log messages are echoed to stdout.

enableLogFile

If true, detailed per-step log files are written to logFileDirectory.

logFileDirectory

Directory for per-step log files.

Methods

void changeRobotShape(const mrpt::math::CPolygon& shape)

Sets the robot footprint as a 2-D polygon, used by PTGs for collision checking.

Parameters:

shape

The robot convex hull polygon (local robot frame).

void changeRobotCircularShapeRadius(const double R)

Sets the robot footprint as a circle, used by PTGs for collision checking.

Parameters:

R

Circle radius in meters.

virtual size_t getPTG_count() const

Returns the number of different PTGs that have been setup.

virtual CParameterizedTrajectoryGenerator* getPTG(size_t i)

Gets the i’th PTG.

virtual const CParameterizedTrajectoryGenerator* getPTG(size_t i) const

Gets the i’th PTG.

virtual bool checkCollisionWithLatestObstacles(const mrpt::math::TPose2D& relative_robot_pose) const

Checks whether the robot shape, when placed at the given pose (relative to the current pose), is colliding with any of the latest known obstacles.

Default implementation: always returns false.

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

Loads all navigator parameters from a config file.

Must be called before initialize(). Derived classes must call the parent implementation after loading their own parameters.

Parameters:

c

The configuration source to read from.

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

Saves all current navigator parameters to a config file.

Derived classes must call the parent implementation after saving their own parameters.

Parameters:

c

The configuration file to write to.