Skip to main content
Version: ROS 2 Humble

Nav2

The Nav2 package provides open source navigation controllers, planners, and utilities. The clearpath_nav2_demos package provides default configurations for supported robots, but these can be customized for your use case. This tutorial will use the Clearpath simulator, but will work on a physical robot too. We will be using a J100 with a Hokuyo UST10 attached to the front of the robot.

J100 YAML

serial_number: j100-0001
version: 0
system:
username: administrator
hosts:
- hostname: cpr-j100-0001
ip: 192.168.131.1
ros2:
namespace: j100_0001
domain_id: 0
middleware:
implementation: rmw_fastrtps_cpp
extras:
ros_parameters:
linear.x.max_velocity": 2.0
linear.x.min_velocity": -2.0
linear.x.max_acceleration": 20.0
linear.x.min_acceleration": -20.0
angular.z.max_velocity": 4.0
angular.z.min_velocity": -4.0
angular.z.max_acceleration": 25.0
angular.z.min_acceleration": -25.0
platform:
controller: ps4
decorations:
front_bumper:
enabled: true
model: default
xyz: [0.0, 0.0, 0.0]
rpy: [0.0, 0.0, 0.0]
extension: 0.0
rear_bumper:
enabled: true
model: default
xyz: [0.0, 0.0, 0.0]
rpy: [0.0, 0.0, 0.0]
extension: 0.0
top_plate:
enabled: true
model: default
xyz: [0.0, 0.0, 0.0]
rpy: [0.0, 0.0, 0.0]
sensors:
lidar2d:
- model: hokuyo_ust
urdf_enabled: true
launch_enabled: true
parent: front_mount
xyz: [0.0, 0.0, 0.0]
rpy: [0.0, 0.0, 0.0]
ros_parameters:
urg_node:
angle_min: -1.5707
angle_max: 1.5707

tip

Make sure you have installed the simulator before starting this tutorial. Take a look at the installation guide for details.

Launching the simulation and Nav2

1. Move the robot.yaml file to your setup folder ($HOME/clearpath by default).

2. Launch the simulation

ros2 launch clearpath_gz simulation.launch.py

Click on the orange play button in the bottom left corner to start the simulation.

3. In another terminal, launch RViz

ros2 launch clearpath_viz view_navigation.launch.py namespace:=j100_0001

4. In another terminal, launch localization

ros2 launch clearpath_nav2_demos localization.launch.py setup_path:=$HOME/clearpath/ use_sim_time:=true

The default map used by localization.launch.py is a map of the simulated warehouse world. If you are using a custom map, pass it in with the map launch argument:

ros2 launch clearpath_nav2_demos localization.launch.py setup_path:=$HOME/clearpath/ use_sim_time:=true map:=/path/to/my/map.yaml

5. In another terminal, launch Nav2

ros2 launch clearpath_nav2_demos nav2.launch.py setup_path:=$HOME/clearpath/ use_sim_time:=true

6. Set the initial pose of the robot

Use the 2D Pose Estimate tool in RViz to set the initial pose of the robot.

  1. Give the robot a navigation goal

Use the Nav2 Goal tool in RViz to set a navigation goal pose.

Navigation in simulation