class mrpt::nav::PlannerSimple2D

Overview

Searches for collision-free path in 2D occupancy grids for holonomic circular robots.

The implementation first enlargest obstacles with robot radius, then applies a wavefront algorithm to find the shortest free path between origin and target 2D points.

Notice that this simple planner does not take into account robot kinematic constraints.

#include <mrpt/nav/planners/PlannerSimple2D.h>

class PlannerSimple2D
{
public:
    // fields

    float occupancyThreshold {0.5f};
    float minStepInReturnedPath {0.4f};
    float robotRadius {0.35f};

    // construction

    PlannerSimple2D();

    // methods

    std::optional<std::deque<mrpt::math::TPoint2D>> computePath(
        const mrpt::maps::COccupancyGridMap2D& theMap,
        const mrpt::poses::CPose2D& origin,
        const mrpt::poses::CPose2D& target,
        float maxSearchPathLength = -1
        ) const;

    void computePath(
        const mrpt::maps::COccupancyGridMap2D& theMap,
        const mrpt::poses::CPose2D& origin,
        const mrpt::poses::CPose2D& target,
        std::deque<mrpt::math::TPoint2D>& path,
        bool& notFound,
        float maxSearchPathLength = -1
        ) const;
};

Fields

float occupancyThreshold {0.5f}

The maximum occupancy probability to consider a cell as an obstacle, default=0.5

float minStepInReturnedPath {0.4f}

The minimum distance between points in the returned found path (default=0.4); Notice that full grid resolution is used in path finding, this is only a way to reduce the amount of redundant information to be returned.

float robotRadius {0.35f}

The aproximate robot radius used in the planification.

Default is 0.35m

Methods

std::optional<std::deque<mrpt::math::TPoint2D>> computePath(
    const mrpt::maps::COccupancyGridMap2D& theMap,
    const mrpt::poses::CPose2D& origin,
    const mrpt::poses::CPose2D& target,
    float maxSearchPathLength = -1
    ) const

Computes the optimal path for a circular robot, in the given occupancy grid map, from the origin location to a target point.

Additional parameters are the public member variables of this class.

Parameters:

theMap

The occupancy gridmap used for the planning.

origin

The starting pose of the robot, in “map” coordinates.

target

The desired target pose, in “map” coordinates.

maxSearchPathLength

The maximum path length to search for, in meters (-1 = no limit)

std::exception

On any error

Returns:

The found path, in global coordinates relative to “map”, or std::nullopt if no path exists (which includes either endpoint falling outside the gridmap).

See also:

robotRadius

void computePath(
    const mrpt::maps::COccupancyGridMap2D& theMap,
    const mrpt::poses::CPose2D& origin,
    const mrpt::poses::CPose2D& target,
    std::deque<mrpt::math::TPoint2D>& path,
    bool& notFound,
    float maxSearchPathLength = -1
    ) const

Deprecated Use the std::optional-returning overload.