The basic value iteration [1] algorithm for searching shortest paths is implemented in the MRPT for occupancy grids, and circular robots, in the class CPathPlanningCircularRobot.
The method comprises two steps:
Note that this is a very simple method, not suitable for robots with shapes very different from circular and/or moving in cluttered environmnets. For those cases, see the obstacle avoidance methods.
The basic usage requires declaring the gridmap, the CPathPlanningCircularRobot object, setting the robot radius, and invoking CPathPlanningCircularRobot::computePath(). The following code fragment is taken from the example MRPT/samples/pathPlanning.
{syntaxhighlighter brush:cpp}
// Load,create,... the grid map:
COccupancyGridMap2D gridmap;
// ...
// Find path:
CPathPlanningCircularRobot pathPlanning;
pathPlanning.robotRadius = 0.30f;
std::deque
CPoint2D origin( 20, -110 );
CPoint2D target( 90, 40 );
pathPlanning.computePath( &gridmap, &origin, &target, thePath, notFound, 100.0f /* Max. distance */ );
// Process the output path in "thePath"
// ....
{/syntaxhighlighter}
Click on the thumb to see full-resolution image. This is the output from the example pathPlanning: