11. ROS Bridge in Standalone Workflow

11.1. Learning Objectives

Prerequisite

11.2. Manually Stepping ROS Components

One major usage for standalone scripting is to manually control the simulation steps. Here we show how to manually step the ROS components so that the frequency of the publishers and subscribers can be carefully controlled.

First we need to disable the ROS components that are automatically publishing on every frame. If creating a new component you can set the commands enabled flag to false:

result, prim = omni.kit.commands.execute(
    "ROSBridgeCreateClock", path="/ROS_Clock_Manual", clock_topic="/manual_time", sim_time=True, enabled=False
)

If the component already exists in the stage you can set its enabled parameter to false via:

omni.kit.commands.execute("ChangeProperty", prop_path=Sdf.Path("/ROS_Clock_Manual.enabled"), value=False, prev=None)

Once the component is disabled, it can be ticked on any frame using:

omni.kit.commands.execute("RosBridgeTickComponent", path="/ROS_Clock_Manual")

Note

Its recommended to run omni.kit.commands.execute("RosBridgeTickComponent", path="...") during the scene setup and run a few update steps so that all of the ROS topics are initialized.

11.3. ROS Component APIs

For list of ROS Python APIs Isaac Sim API Documentation -> Isaac Sim Extensions -> Other Extensions.

11.4. Examples

We converted a few of the tutorial examples into standalone python examples. Here are the instructions for running them.

Note

Make sure to run roscore and ros_workspace is sourced before these executing the samples below .

11.4.1. ROS clock

This sample demonstrates how to create a ROS bridge component using the command API and then tick them at different rates.

The sample can be executed by running the following:

./python.sh standalone_examples/api/omni.isaac.ros_bridge/clock.py

11.4.2. Carter Stereo

This sample demonstrates how to take an existing USD stage with ROS bridge components and run it in manual stepping mode. Similar to the instructions above, all of the ROS components are disabled and ticked once to initialize. Additionally the stereo camera pair is automatically enabled and the second viewport window is docked in the UI.

  • On each frame:

    • The ROS clock component is published

  • Every Two Frames:

    • Lidar message is published

    • Differential base is published and subscribers are spun

    • TF messages are published

  • Every Second (60 frames):

    • Left and right cameras are published

The sample can be executed by running the following:

./python.sh standalone_examples/api/omni.isaac.ros_bridge/carter_stereo.py

To exit the sample you can terminate via the terminal with CTRL-C

To visualize the result:

In a new terminal, run rviz -d ros_workspace/src/isaac_tutorials/rviz/carter_stereo.rviz to load Rviz. Make sure Left Camera - Depth, Right Camera - Depth, Right Camera - RGB and Left Camera - RGB within the Displays are enabled to visualize RGB and Depth images.

RViz UI Window

Note

If some of the images don’t show up on RViz, press Stop and Play in the simulator for the images to show up.

In addition, a twist message can also be published to /cmd_vel topic to control the differential base robot. For example, to rotate in-place, send the following command rostopic pub /cmd_vel geometry_msgs/Twist '{linear:  {x: 0.0, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.2}}'

11.4.3. MoveIt

This sample shows how to add multiple USD stages. It also demonstrates how to manually create ROS bridge components and run it in manual stepping mode. Similar to the instructions above, all of the ROS components are disabled and ticked once to initialize.

To visualize the output see the interactive version of the sample:

  • On each frame:

    • The ROS clock component is published

    • Joint state messages are published

    • TF messages are published

The sample can be executed by running the following:

./python.sh standalone_examples/api/omni.isaac.ros_bridge/moveit.py

To exit the sample you can terminate via the terminal with CTRL-C

11.4.4. Multiple Robot ROS Navigation

This sample shows how to add multiple USD stages and run ROS bridge components under different namespaces in manual stepping mode. Similar to the instructions above, all of the ROS components are disabled and ticked once to initialize.

To visualize the output see the interactive version of the sample:

  • On each frame:

    • The ROS clock component is published

    • Lidar messages are published

    • Differential base is published and subscribers are spun

    • Left cameras are published

    • TF messages are published

The sample can be executed with both the hospital and office environments. Run either of the following commands to run the sample with the specified environment:

./python.sh standalone_examples/api/omni.isaac.ros_bridge/carter_multiple_robot_navigation.py hospital

OR

./python.sh standalone_examples/api/omni.isaac.ros_bridge/carter_multiple_robot_navigation.py office

To exit the sample you can terminate via the terminal with CTRL-C