(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Writing a local path planner as plugin in ROS

Description: A tutorial to writing a custom local planner to work with the ROS1.This tutorial will be structured in a similar manner to ROS Global Path Planner

Keywords: local planner, move_base

Tutorial Level: BEGINNER

Note: The ROS Wiki is generally for ROS 1 only! If you have installed ROS 2 please use the ROS 2 documentation website.

Writing the Path Planner Class

Class Header

Before starting these tutorials please complete installation as described in the ROS installation instructions.

Class Implementation

The first step is to write a new class for the path planner that adheres to the nav_core::BaseLocalPlanner ROS Base Local Planner.For this, you need to create a header file, that we will call in our case, local_planner.h. I will present just the minimal code for adding a plugin, which are the necessary and common steps to add any local planner. The minimal header file is defined as follows:

   1  /** include the libraries you need in your planner here */
   2  /** for global path planner interface */
   3  #include <ros/ros.h>
   4  #include <nav_core/base_local_planner.h>
   6  #ifndef LOCAL_PLANNER_CPP
   7  #define LOCAL_PLANNER_CPP
   9  namespace local_planner {
  11  class LocalPlanner : public nav_core::BaseLocalPlanner {
  12  public:
  14   LocalPlanner();
  15   LocalPlanner(std::string name, costmap_2d::Costmap2DROS* costmap_ros);
  17   /** overridden classes from interface nav_core::BaseLocalPlanner **/
  18   void initialize(std::string name, costmap_2d::Costmap2DROS* costmap_ros);
  19   bool makePlan(const geometry_msgs::PoseStamped& start,
  20                 const geometry_msgs::PoseStamped& goal,
  21                 std::vector<geometry_msgs::PoseStamped>& plan
  22                );
  23   };
  24  };
  25  #endif


Writing your Plugin

Plugin Registration

Plugin Description File

Wiki: navigation/Tutorials/Writing a Local Path Planner As Plugin in ROS (last edited 2021-09-12 16:03:01 by den-globotix)