7.2.7. ROS2 Transform Trees and Odometry

7.2.7.1. Learning Objectives

In this example, we will learn to

  • Add a TF publisher to publish the camera positions as part of the TF tree.

  • Publish pose of objects relative to the camera

7.2.7.2. Getting Started

Important

Make sure to source your ROS 2 installation from the terminal before running Isaac Sim. If sourcing ROS 2 is a part of your bashrc then Isaac Sim can be run directly.

Prerequisite

7.2.7.3. TF Tree Publisher

7.2.7.3.1. TF Publisher

Assuming you’ve already gone through the ROS2 camera tutorial and have two cameras on stage already, let’s add those cameras to a TF tree, so that we can track the camera’s position in the global frame.

  1. In a new or existing Action Graph window, add a ROS2 Publish Transform Tree node, and connect it up with On Playback Tick and Isaac Read Simulation Time, like the image below.

  2. In the Property tab for the ROS2 Publish Transform Tree node, add both Camera_1 and Camera_2 to the targetPrims field.

  3. Examine the transform tree in a ROS2-enabled terminal: ros2 topic echo /tf. You should find both cameras on the TF tree. Move the camera around inside the viewport and see how the camera’s pose changes.

Turtlebot TF Graph

7.2.7.3.2. Articulation Transforms

To get the transforms of each linkage on an articulated robot, add the robot’s articulation root to the targetPrims field. All the linkages subsequent to the articulation root will be published automatically. Add /World/turtlebot3_burger to the targetPrims field, and see that the transforms of all the links of the robot, fixed or articulated, will be published on the /tf topic.

Important

If you find that the generated tf tree for an articulated robot chose the wrong link as the root link, use the following step to manually select the articulation root link. This is commonly seen when importing robots using the URDF Importer with “Merge Fixed Link” checked, as well as for mobile robots.

  • Select the robot’s root prim on the Stage Tree, in its “Raw USD Properties” tab, find the “Articulation Root” Section. Delete it by click on the “X” on the right upper corner inside the section.

  • Select the desired link on the Stage Tree, inside its “Raw USD Properties” Tab, click on the +ADD button, and add Physics > Articulation Root.

7.2.7.3.3. Publish Relative Transforms

By default, the transforms are in reference to the world frame. You can check that the /base_link transform of the Turtlebot is published relative to the /World. If you wish to get the transforms relative to something else, such as a camera, make sure to indicate that in the parentPrim field. Add Camera_1 in the parentPrim field, Stop and Play the simulation between property changes, and you can see that the /base_link transform is now relative to Camera_1.

7.2.7.4. Setting up Odometry

To setup odometry for a robot, we would need to publish the odometry ROS message as well as its corresponding transforms.

  1. To setup up the odometry publisher, compose an Action Graph that matches the following image.

    ../_images/isaac_tutorial_ros2_odometry_graph.png
    • In the Property tab for the Isaac Compute Odometry Node:

      • Add the Turtlebot prim (ie. /World/turtlebot3_burger) to its Chassis Prim input field. This node calculates the position of the robot relative to its start location. Its output will be fed into both a publisher for the /odom Rostopic, and a TF publisher that publishes the singular transform from /odom frame to /base_link frame.

    • In the Property tab for the ROS2 Publish Raw Transform Tree node:

      • Set the childFrameId input field to base_link.

      • Set the parentFrameId input field to odom. This will now enable publishing odom -> base_link frames in the TF tree.

    • In the Property tab for the ROS2 Publish Odometry node:

      • Set the chassisFrameId input field to base_link.

      • Set the odomFrameId input field to odom. This will now enable publishing odom -> base_link frames in the TF tree.

  2. At this point we are publishing odometry data and our TF tree only consists of odom -> base_link. We would also like to add the robot articulations under base_link to the TF tree. To do this, add a ROS2 Publish Transform Tree node to the graph and attach the Exec In, Context, and Timestamp fields similarly to previous nodes above.

    • In the Property tab for the ROS2 Publish Transform Tree node:

      • Set the targetPrims input field to the path to your Turtlebot Prim (ie. /World/turtlebot3_burger).

      • Set the parentPrim input field to the path to your base_link inside your Turtlebot Prim (ie. /World/turtlebot3_burger/base_link).

  3. Now we should be publishing a TF tree that consists of odom -> base_link -> <other robot links>. This next step is only required when you want to have ground truth localization of the robot. Usually, a ROS package for localization such as Nav2 AMCL would be responsible for setting the transform between a global frame and the odom frame. To setup ground truth localization, add in another ROS2 Publish Raw Transform Tree node to the graph and attach the Exec In, Context, and Timestamp fields similarly to previous nodes above.

    • In the Property tab for the recently added ROS2 Publish Raw Transform Tree node:

      • Set the childFrameId input field to odom.

      • Set the parentFrameId input field to world. This will now enable publishing world -> odom frames in the TF tree.

      • Leave Translation and Rotation fields detached as this will use the defaults of (0.0, 0.0, 0.0) translation vector (XYZ) and (1.0, 0.0, 0.0, 0.0) rotation quaternion (IJKR). This rotation and translation corresponds to the robot’s Start pose. If the robot starts in a different position, these fields would have to be updated accordingly to match that pose.

Your finally graph should look similar to the following:

../_images/isaac_tutorial_ros2_odometry_graph_final.png


Hit Play and in a new ROS-sourced terminal run the command ros2 run tf2_tools view_frames. Open the generated pdf file to see the TF tree that we are publishing from Isaac Sim. It should look similar to the one below.

../_images/isaac_tutorial_ros2_odometry_graph_tf_tree_view.png


For an example of all the publishers and subscribers setup in the Turtlebot ROS2 tutorials, open Isaac/Samples/ROS2/Scenario/turtlebot_tutorial.usd.

7.2.7.5. Summary

This tutorial covered

  • TF publisher to publish sensors and full articulation trees

  • Raw TF publisher to publish individual transforms

  • Odometry publisher and TF publishers setup for Turtlebot

7.2.7.5.1. Next Steps

Continue on to the next tutorial in our ROS2 Tutorials series, ROS2 Navigation to learn to use ROS2 Nav2 with Omniverse Isaac Sim.