# 1. ROS2 Import and Drive TurtleBot3¶

Omniverse Isaac Sim have several tools to facilitate integration with ROS systems. We have both ROS and ROS2 bridges, an URDF importer, as well as connection to Gazebo/Ignition. This tutorial series gives examples of how to use these tools.

## 1.1. Learning Objectives¶

In this example, we will setup up a Turtlebot3 in Isaac Sim and enable it to drive around. We will

• Import the Turtlebot3 robot using the URDF importer

• Introduce the ROS2 bridge and ROS2 OmniGraph (OG) nodes

• Setup the robot to be driven by a ROS Twist message

## 1.2. Getting Started¶

Prerequisite

• Completed ROS & ROS 2 Installation so that ROS2 is available, ROS2 extension is enabled, and necessary environment variables are set.

• Basic understanding ROS workspace.

ROS2 Bridge

The ROS2 bridge comes with a few popular rostopics that are packaged for ease of use. More details are in the ROS2 Bridge page. Here we will focus on the procedures in using them.

To establish a ROS2 bridge for a specific topic, the steps can be generalized to the following:

• open an action graph

• add the OG nodes relevant to the desired rostopics

• modify any properties as needed

• connect the data pipeline

These steps can be done entirely in the UI, scripting inside the extension workflow, or scripting inside the standalone Python workflow. Refer to Isaac Sim Workflows for details of different workflows. For majority of the tutorials we will be demonstrating the UI method. Scripting inside the extension workflow is introduced in Joint Control: Extension Python Scripting. Scripting using the standalone Python workflow is introduced in Custom Message, and scripting OmniGraph nodes is introduced in OmniGraph: Python Scripting.

## 1.3. Importing TurtleBot3 URDF¶

git clone -b <distro>-devel https://github.com/ROBOTIS-GIT/turtlebot3.git turtlebot3

• Locate the URDF file for Turtlebot3 Burger in turtlebot3/turtlebot3_description/urdf/turtlebot3_burger.urdf

1. For the purpose of this tutorial series, we will use an Isaac environment, but you can import the robot into any environment of your choosing. Open the environment by going to the Content tab below the viewport, and find Isaac/Environments/Simple_Room/simple_room.usd. If you do not want to use the provided environment, just make sure there is a Ground Plane and a Physics Scene to your environment. Both can be found in Create -> Physics. You may also need some lighting, play with the various types of lighting in Create -> Light to get the desired effect.

2. On a new stage, drag the simple_room.usd onto the stage, and place it at the origin by zero out all the Translate components in the Transform Property. You many need to zoom in a bit to see the table inside the room.

3. Open the URDF importer Isaac Utils > Workflows > URDF Importer.

4. In the prompt window, inside Import Option section, uncheck clean stage to preserve the existing environment, uncheck Fix Base Link since this is a mobile robot, change Joint Drive Type to Velocity so that wheels can be properly driven later.

5. Inside Import section, first locate the URDF file you wish to import in the Input File. The Import button will only enable after you’ve selected the file.

6. Once the asset is imported into Omniverse Kit, a copy of the .usd version of the asset will be automatically saved. Specify the folder you wish to save the asset in Output Directory if it’s different than the folder that the .urdf file is located in. A folder name matching the .urdf file will be created in the specified directory, and the .usd file will be inside the newly created folder.

7. Make sure to unselect everything on the stage by click on an empty space inside the Stage tab, or select /World on the tree. Otherwise you might be importing the Turtlebot as a child of a random object on the tree.

8. Click Import.

9. When the Turtlebot is first imported, it will be on the table. Place it just above the floor of the room using the gizmo.

10. Press Play and you should see the Turtlebot fall onto the floor.

## 1.4. Drive the Robot¶

### 1.4.1. Build the Graph¶

All of the ROS2 bridges are in forms of OmniGraph nodes. Here we will demonstrate how to subscribe to a ROS2 twist message, and pipe the data to the controllers that can drive the robot around.

1. Open Visual Scripting: Window > Visual Scripting > Action Graph. An Action Graph window will appear on the bottom, you can dock it wherever that’s convenient.

2. Click on the New Action Graph Icon in middle of the Action Graph Window.

3. Inside the Action Graph window, there is a panel on the left hand side with all the OmniGraph Nodes (or OG nodes). All ROS2 related OG nodes are listed under Isaac Ros2. You can also search for nodes by name. To place node into the graph, simply drag it from the node list into the graph window. If all the ROS related nodes are labeled Ros1 not Ros2, it means you have ROS bridge enabled and not ROS2. Go to Windows > Extensions to disable ROS bridge and enabled ROS2 bridge.

4. Build a graph that matches the one below.

### 1.4.2. Graph Explained¶

• On Playback Tick Node: Producing a tick when simulation is “Playing”. Nodes that receives ticks from this node will execute their compute functions every simulation step.

• ROS2 Context Node: ROS2 uses DDS for its middleware communication. DDS uses Domain ID to allow for different logical networks operate independently even though they share a physical network. ROS 2 nodes on the same domain can freely discover and send messages to each other, while ROS 2 nodes on different domains cannot. ROS2 context node creates a context with a given Domain ID. It is set to 0 by default.

• ROS2 Subscribe Twist Node: Subscribing to a Twist message. Specify the Ros Topic’s name /cmd_vel in the topicName field in its Property Tab.

• Note the subscriber nodes often have a Exec Out field. This act similar to a tick and will send a signal when a message is received by the subscriber. In this case, we want to only calculate the differential commands when a new twist message arrives. Therefore the Differential Node’s Exec In is ticked by the output of the subscriber node and not by On Playback Tick.

• Scale To/From Stage Unit Node: Convert assets or inputs to stage unit.

• Break 3-Vector Node: The output of the Twist subscriber node is linear and angular velocities, both 3-dimensional vectors. But the input of the differential controller node only takes a forward velocity and rotation velocity in z-axis, therefore we need to decompose the array and extract the corresponding elements before feeding them into the differential controller node.

• Differential Controller Node: This node receives desired vehicle speed and calculates the wheel speed of the robot. It needs the wheel radius and distance between the wheels to make that calculation. It can also receive optional speed limit parameters to cap off wheel speed. Type in the property tab the wheel radius, the distance between the wheels, and the maximum linear speed for the vehicle as seen in table below to match the Turtlebot.

Field

Value

Max Linear Speed

0.22

Wheel Distance

0.16

0.025

• Articulation Controller Node: This node is assigned to a target robot, then takes in the names or the indices of the joints that needs to be moved, and move them by the commands given in either Position Commands, Velocity Commands, or Effort Commands.

• Note the Articulation Controller node is ticked by On Playback Tick. So that if no new Twist message arrives, it will continue to execute whatever command it had received before.

• To assign the Articulation Controller node’s target to be the Turtlebot. In the property tab, unselect Use Path, and click on Target for the Prim, and find Turtlebot prim in the popup box. Make sure the robot prim you select is also where the Articulation Root API is applied. For some robots, the Articulation Root API is applied to a specific link of the robot and not the parent robot prim. More about Articulation API can be found in Add Articulation.

• To put the names of the wheel joints in an array format, type in the names of the wheel joints inside each of the Constant Token nodes, and feed the array of the names into the Make Array Node. The names of the joints for the Turtlebot are wheel_left_joint and wheel_right_joint.

• If you are wondering why not put the names in Constant String node, it’s because OmniGraph does not have string-array data type, therefore if strings needed to be put in an array format to be used by a node, it needs to be token type instead.

### 1.4.3. Verify ROS connections¶

1. Press Play to start ticking the graph and the physics simulation.

2. In a separate ROS-sourced terminal, check that the associated rostopics exist with ros2 topic list. /cmd_vel should be listed in addition to /rosout and /parameter_events.

3. Now that a differential base topic is setup, a twist message can be published to /cmd_vel topic to control the robot. Let’s drive it forward with the command:

ros2 topic pub /cmd_vel geometry_msgs/Twist '{linear:  {x: 0.2, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'

4. To make it easier for us to move the Turtlebot around, install the teleop_twist_keyboard by running the following command:

sudo apt-get install ros-\$ROS_DISTRO-teleop-twist-keyboard


Enable driving using the keyboard by running:

ros2 run teleop_twist_keyboard teleop_twist_keyboard


### 1.4.4. Troubleshooting¶

Make sure your robot is on the ground. The table has a different property therefore making it hard for the robot to move on it. To change properties of either the ground or the wheels, go to Assemble a Simple Robot.

## 1.5. Summary¶

This tutorial covered the following topics:

1. URDF import

2. Subscribing to a ROS2 Twist message

3. Drive the robot using the Differential Controller and the Articulation Controller

### 1.5.1. Next Steps¶

Continue on to the next tutorial in our ROS2 Tutorials series, ROS2 Cameras, to learn how to add cameras and receive ground truth synthetic perception data through rostopics.