Skip to content

Custom Planners

You can write a custom global planner plugin for Nav2 by implementing the nav2_core::GlobalPlanner interface.

Plugin Interface

cpp
#include "nav2_core/global_planner.hpp"

class MyPlanner : public nav2_core::GlobalPlanner {
public:
  void configure(/* ... */) override;
  nav_msgs::msg::Path createPlan(
    const geometry_msgs::msg::PoseStamped & start,
    const geometry_msgs::msg::PoseStamped & goal) override;
};

Register as Plugin

In CMakeLists.txt:

cmake
pluginlib_export_plugin_description_file(nav2_core my_planner_plugin.xml)

In my_planner_plugin.xml:

xml
<library path="my_planner">
  <class name="my_pkg/MyPlanner" type="my_pkg::MyPlanner"
         base_class_type="nav2_core::GlobalPlanner">
    <description>My custom global planner</description>
  </class>
</library>

TIP

Start from the nav2_straightline_planner as a minimal reference implementation.

Released under the MIT License.