In this ROS2 sample, we are demonstrating Omniverse Isaac Sim integrated with the ROS2 Nav2 project.

Warning

This ROS2 Navigation sample is only supported on ROS2 Foxy Fitzroy or later. See the ROS2 website for requirements and installation instructions: https://docs.ros.org/en/foxy/Releases/Release-Foxy-Fitzroy.html

For this sample, we use the carter_navigation ROS2 package which contains the required launch file and navigation parameters.

The carter_description ROS2 package is also used for displaying the NVIDIA Carter robot model in RViz2.

Both ROS2 packages are located under the directory ros2_samples/navigation/. If not already done, include both packages into your ROS2 workspace. Build and source your workspace before proceeding.

First go to Isaac Examples -> Communicating -> ROS -> Navigation to load the warehouse scenario.

Press Play to begin simulation.

## The Nav2 Setup¶

This block diagram shows the ROS2 messages required for Nav2.

As described above, the following topics and message types being published to Nav2 in this scenario are:

ROS2 Topic

ROS2 Message Type

/tf

tf2_msgs/TFMessage

/odom

nav_msgs/Odometry

/map

nav_msgs/OccupancyGrid

/scan

sensor_msgs/LaserScan

### Omniverse Isaac Sim TF broadcasting in more detail:¶

ROS_DifferentialBase subscribes to the /cmd_vel topic and is responsible for controlling the movement of the robot. It also publishes the transform between the odom frame and base_link frame.

ROS_Carter_Broadcaster is responsible for publishing the static transform between the base_link frame and chassis_link frame. Keep in mind that since the target prim is set as Carter_ROS, the entire transform tree of the Carter robot (with chassis_link as root) will be published alongside the base_link frame.

ROS_Carter_Lidar_Broadcaster is responsible for publishing the static transform between the chassis_link frame and carter_lidar frame.

Finally, to ensure all ROS2 nodes reference simulation time, a ROS_Clock prim has been added which publishes the simulation time to the /clock ROS2 topic.

## Occupancy Map¶

In this scenario we will use an occupancy map.

## Running Nav2¶

Click on Play to begin simulation.

RViz2 will open and begin loading the occupancy map. If a map does not appear, repeat the previous step.

In a new terminal, run the ROS2 launch file to begin Nav2.

ros2 launch carter_navigation carter_navigation.launch.py


RViz2 will open and begin loading the occupancy map. If a map does not appear, repeat the previous step.

Load the the URDF model into the RViz2 window by clicking on RobotModel -> Description File and navigate to the location of the Carter URDF model which can be found at the urdf directory in the sample carter_description ROS2 package (carter_description/urdf/carter.urdf).

It is mostly likely after launching carter_navigation.launch.py, that the local costmap will not match the occupancy map. This means the robot is not correctly localized. To mitigate this, click on the 2D Pose Estimate button near the top of the RViz2 window and set the initial estimated pose by clicking and dragging at a point on the map where you think the robot is located.

To get a better idea of where the robot is located, you may wish to change camera views by clicking at the top left of the viewport in the Omniverse Isaac Sim window.

In RViz2, the robot model will immediately jump to the indicated pose. The local costmap should now be similarly aligned to the occupancy map.

Note

The local and occupancy maps don’t have to perfectly align yet. However if their alignment is quite different, you may repeat the previous step until getting a closer alignment.

To make both the local and global maps properly align, manually drive around the robot (rotating in place works the fastest in most cases). For manually controlling the robot, run the teleop_twist_keyboard ROS2 node using the following command in a new terminal.

ros2 run teleop_twist_keyboard teleop_twist_keyboard


Use the keyboard to move the robot until the local costmap has properly aligned with the occupancy map.

Now the robot has been properly localized! You may now stop the teleop_twist_keyboard node as it is not required anymore.

Click on the 2D Goal Pose button and then click and drag at the desired location point in the map. Nav2 will now generate a trajectory and the robot will start moving towards its destination!

## Troubleshooting¶

Only perform the following steps if the occupancy map does not properly load in RViz2:

Open the carter_navigation launch file found under: carter_navigation/launch/carter_navigation.launch.py

Disable the RViz2 Node from starting automatically by removing or commenting the following section:

Node(
package='rviz2',
executable='rviz2',
name='rviz2',
output='screen',
parameters=[{'use_sim_time': use_sim_time, 'autostart': autostart}],
arguments=['-d', rviz_config_dir]
),


Open the carter_visualization launch file found under: carter_navigation/launch/carter_visualization.launch.py and ensure the file path to the RViz2 config file is correct.

Important

Before running the carter_navigation launch file as outlined in the Running Nav2 section, make sure to first run the carter_visualization launch file in a new terminal.

ros2 launch carter_navigation carter_visualization.launch.py