Skip to main content
Version: ROS 2 Jazzy

Launching Navigation

The Nav2 package provides open source navigation controllers, planners, and utilities. Regardless of whether you are using SLAM or Localization, you must launch Nav2.

note

When using the simulation, it is important to add use_sim_time:=true to the Nav2, SLAM, and Localization launch files. When using a physical robot, either omit use_sim_time or set it to false.

note

Clearpath's Nav2 demos are written to support 2D lidars. If your robot has a 3D lidar on it, you can use the 3d lidar's scan topic to provide the necessary 2d laserscan input by using the scan_topic argument, e.g. scan_topic:=/a300_0000/sensors/lidar3d_0/scan.

warning

Some lidars, especially 3D lidars, can have a minimum range that is larger than the robot's footprint. In this case it is possible for an obstacle to be so close to the robot that the lidar cannot detect it, potentially causing damage or injury. Always keep an eye on the robot and be ready to press the emergency stop if necessary.

Launching Nav2 and SLAM on a physical robot

The following commands can be run on the robot itself, or on an offboard computer. Running on the robot will result in less latency, but can also result in high CPU usage on the robot, depending what other nodes are running.

1. Ensure the clearpath-platform and clearpath-sensors services are running. Run ros2 topic list to make sure the robot's scan topic is visible

2. Start Nav2 by running

ros2 launch clearpath_nav2_demos nav2.launch.py

If your robot uses a 3D lidar instead of a 2D lidar, specify the scan_topic argument:

ros2 launch clearpath_nav2_demos nav2.launch.py scan_topic:=/a300_0000/sensors/lidar3d_0/scan

3. Start SLAM by running:

ros2 launch clearpath_nav2_demos slam.launch.py

If your robot uses a 3D lidar instead of a 2D lidar, specify the scan_topic argument:

ros2 launch clearpath_nav2_demos slam.launch.py scan_topic:=/a300_0000/sensors/lidar3d_0/scan

4. On your laptop, start Rviz to view the map by running

ros2 launch clearpath_viz view_navigation namespace:=/a300_0000

5. Drive the robot around manually, or by sending it Nav2 goals.

See SLAM for more information about interacting with SLAM.

See Nav2 Goals for more information about sending navigation goals.

Launching Nav2 and SLAM in simulation

1. Start the simulation by running

ros2 launch clearpath_gz simulation.launch setup_path:=/path/to/robot_setup

The setup_path should point to the folder you have your robot.yaml file, e.g. /home/username/clearpath or /etc/clearpath

2. Start Nav2 by running

ros2 launch clearpath_nav2_demos nav2.launch.py use_sim_time:=true setup_path:=/path/to/robot_setup

If your simulated robot uses a 3D lidar instead of a 2D lidar, specify the scan_topic argument:

ros2 launch clearpath_nav2_demos nav2.launch.py scan_topic:=/a300_0000/sensors/lidar3d_0/scan use_sim_time:=true setup_path:=/path/to/robot_setup

3. Start SLAM by running:

ros2 launch clearpath_nav2_demos slam.launch.py use_sim_time:=true setup_path:=/path/to/robot_setup

If your robot uses a 3D lidar instead of a 2D lidar, specify the scan_topic argument:

ros2 launch clearpath_nav2_demos slam.launch.py scan_topic:=/a300_0000/sensors/lidar3d_0/scan use_sim_time:=true setup_path:=/path/to/robot_setup

4. Start Rviz to view the map by running

ros2 launch clearpath_viz view_navigation namespace:=/a300_0000 use_sim_time:=true

5. Drive the robot around manually, or by sending it 2D nav goals.

See SLAM for more information about interacting with SLAM.

See Nav2 Goals for more information about sending navigation goals.

Launching Nav2 and Localization on a physical robot

The following commands can be run on the robot itself, or on an offboard computer. Running on the robot will result in less latency, but can also result in high CPU usage on the robot, depending what other nodes are running.

1. Ensure the clearpath-platform and clearpath-sensors services are running. Run ros2 topic list to make sure the robot's scan topic is visible

2. Start Nav2 by running

ros2 launch clearpath_nav2_demos nav2.launch.py

If your robot uses a 3D lidar instead of a 2D lidar, specify the scan_topic argument:

ros2 launch clearpath_nav2_demos nav2.launch.py scan_topic:=/a300_0000/sensors/lidar3d_0/scan

3. Start localization by running:

ros2 launch clearpath_nav2_demos localization.launch.py map:=/path/to/map.yaml

If your robot uses a 3D lidar instead of a 2D lidar, specify the scan_topic argument:

ros2 launch clearpath_nav2_demos localization.launch.py scan_topic:=/a300_0000/sensors/lidar3d_0/scan map:=/path/to/map.yaml

4. On your laptop, start Rviz to view the map by running

ros2 launch clearpath_viz view_navigation namespace:=/a300_0000

5. Use Rviz to set the 2D pose estimate.

6. Send 2D a nav goal to the robot using Rviz' 2D Nav Goal tool or the Navigation to Pose action.

Launching Nav2 and Localization in simulation

The following commands can be run on the robot itself, or on an offboard computer. Running on the robot will result in less latency, but can also result in high CPU usage on the robot, depending what other nodes are running.

1. Start the simulation by running

ros2 launch clearpath_gz simulation.launch setup_path:=/path/to/robot_setup

The setup_path should point to the folder you have your robot.yaml file, e.g. /home/username/clearpath or /etc/clearpath

2. Start Nav2 by running

ros2 launch clearpath_nav2_demos nav2.launch.py use_sim_time:=true

If your robot uses a 3D lidar instead of a 2D lidar, specify the scan_topic argument:

ros2 launch clearpath_nav2_demos nav2.launch.py scan_topic:=/a300_0000/sensors/lidar3d_0/scan use_sim_time:=true

3. Start localization by running:

ros2 launch clearpath_nav2_demos localization.launch.py map:=/path/to/map.yaml use_sim_time:=true

If your robot uses a 3D lidar instead of a 2D lidar, specify the scan_topic argument:

ros2 launch clearpath_nav2_demos localization.launch.py scan_topic:=/a300_0000/sensors/lidar3d_0/scan map:=/path/to/map.yaml use_sim_time:=true

4. On your laptop, start Rviz to view the map by running

ros2 launch clearpath_viz view_navigation namespace:=/a300_0000

5. Use Rviz to set the 2D pose estimate.

6. Send 2D a nav goal to the robot using Rviz' 2D Nav Goal tool or the Navigation to Pose action.