Package Summary

Tags No category tags.
Version 1.0.7
License Apache-2.0

Repository Summary

Checkout URI
VCS Type git
VCS Version galactic
Last Updated 2021-10-22
CI status No Continuous Integration
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

An importable library for writing mobile robot applications in python3

Additional Links

No additional links.


  • steve


No additional authors.

Nav2 Simple (Python3) Commander


The goal of this package is to provide a "navigation as a library" capability to Python3 users. We provide an API that handles all the ROS2-y and Action Server-y things for you such that you can focus on building an application leveraging the capabilities of Nav2. We also provide you with demos and examples of API usage to build common basic capabilities in autonomous mobile robotics.

This was built by Steve Macenski at Samsung Research, with initial prototypes being prepared for the Keynote at the 2021 ROS Developers Day conference (code can be found here).


The methods provided by the basic navigator are shown below, with inputs and expected returns. If a server fails, it may throw an exception or return a None object, so please be sure to properly wrap your navigation calls in try/catch and check results for None type.

Robot Navigator Method Description
setInitialPose(initial_pose) Sets the initial pose (PoseStamped) of the robot to localization.
goThroughPoses(poses) Requests the robot to drive through a set of poses (list of PoseStamped).
goToPose(pose) Requests the robot to drive to a pose (PoseStamped).
followWaypoints(poses) Requests the robot to follow a set of waypoints (list of PoseStamped). This will execute the specific TaskExecutor at each pose.
cancelNav() Cancel an ongoing goThroughPoses goToPose or followWaypoints request.
isNavComplete() Checks if navigation is complete yet, times out at 100ms. Returns True if completed and False if still going.
getFeedback() Gets feedback from navigation task, returns action server feedback object.
getResult() Gets final result of navigation task, to be called after isNavComplete returns True. Returns action server result object.
getPath(start, goal) Gets a path from a starting to a goal PoseStamped, nav_msgs/Path.
getPathThroughPoses(start, goals) Gets a path through a starting to a set of goals, a list of PoseStamped, nav_msgs/Path.
changeMap(map_filepath) Requests a change from the current map to map_filepath's yaml.
clearAllCostmaps() Clears both the global and local costmaps.
clearLocalCostmap() Clears the local costmap.
clearGlobalCostmap() Clears the global costmap.
getGlobalCostmap() Returns the global costmap, nav2_msgs/Costmap
getLocalCostmap() Returns the local costmap, nav2_msgs/Costmap
waitUntilNav2Active() Blocks until Nav2 is completely online and lifecycle nodes are in the active state. To be used in conjunction with autostart or external lifecycle bringup.
lifecycleStartup() Sends a request to all lifecycle management servers to bring them into the active state, to be used if autostart is false and you want this program to control Nav2's lifecycle.
lifecycleShutdown() Sends a request to all lifecycle management servers to shut them down.

A general template for building applications is as follows:

from nav2_simple_commander.robot_navigator import BasicNavigator
import rclpy


nav = BasicNavigator()
nav.waitUntilNav2Active() # if autostarted, else use `lifecycleStartup()`
while not nav.isNavComplete():
    feedback = nav.getFeedback()
    if feedback.navigation_duration > 600:
result = nav.getResult()
if result == NavigationResult.SUCCEEDED:
    print('Goal succeeded!')
elif result == NavigationResult.CANCELED:
    print('Goal was canceled!')
elif result == NavigationResult.FAILED:
    print('Goal failed!')

Usage of Demos and Examples

Make sure to install the aws_robomaker_small_warehouse_world package or build it in your local workspace alongside Nav2. It can be found here. The demonstrations, examples, and launch files assume you're working with this gazebo world (such that the hard-programmed shelf locations and routes highlighting the API are meaningful).

Make sure you have set the model directory of turtlebot3 simulation and aws warehouse world to the GAZEBO_MODEL_PATH. There are 2 main ways to run the demos of the nav2_simple_commander API.


The main benefit of this is automatically showing the above demonstrations in a single command for the default robot model and world. This will make use of Nav2's default robot and parameters set out in the main simulation launch file in nav2_bringup.

# Launch the launch file for the demo / example
ros2 launch nav2_simple_commander

This will bring up the robot in the AWS Warehouse in a reasonable position, launch the autonomy script, and complete some task to demonstrate the nav2_simple_commander API.


The main benefit of this is to be able to launch alternative robot models or different navigation configurations than the default for a specific technology demonstation. As long as Nav2 and the simulation (or physical robot) is running, the simple python commander examples / demos don't care what the robot is or how it got there. Since the examples / demos do contain hard-programmed item locations or routes, you should still utilize the AWS Warehouse. Obviously these are easy to update if you wish to adapt these examples / demos to another environment.

# Terminal 1: launch your robot navigation and simulation (or physical robot). For example
ros2 launch nav2_bringup world:=/path/to/aws_robomaker_small_warehouse_world/.world map:=/path/to/aws_robomaker_small_warehouse_world/.yaml

# Terminal 2: launch your autonomy / application demo or example. For example
ros2 run nav2_simple_commander demo_security

Then you should see the autonomy application running!


The nav2_simple_commander has a few examples to highlight the API functions available to you as a user:

  • - Demonstrates the navigate to pose capabilities of the navigator, as well as a number of auxiliary methods.
  • - Demonstrates the navigate through poses capabilities of the navigator, as well as a number of auxiliary methods.
  • - Demonstrates the waypoint following capabilities of the navigator, as well as a number of auxiliary methods required.


The nav2_simple_commander has a few demonstrations to highlight a couple of simple autonomy applications you can build using the nav2_simple_commander API:

  • - A simple security robot application, showing how to have a robot follow a security route using Navigate Through Poses to do a patrol route, indefinitely.
  • - A simple item picking application, showing how to have a robot drive to a specific shelf in a warehouse to either pick an item or have a person place an item into a basket and deliver it to a destination for shipping using Navigate To Pose.
  • - A simple shelf inspection application, showing how to use the Waypoint Follower and task executors to take pictures, RFID scans, etc of shelves to analyze the current shelf statuses and locate items in the warehouse.

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Launch files

No launch files found


No message files found.


No service files found


No plugins found.

Recent questions tagged nav2_simple_commander at