ROS Bridge in Standalone Workflow#

Learning Objectives#

  • Run standalone ROS python examples

  • Manually step ROS components

Getting Started#

Prerequisite

Manually Stepping ROS Components#

One major usage for standalone scripting is to manually control the simulation steps. An OnImpulseEvent OmniGraph node can be connected to any ROS OmniGraph node so that the frequency of the publishers and subscribers can be carefully controlled.

An example of how a new action graph with a ROS1 Publish Clock node can be setup to be precisely controlled:

import omni.graph.core as og
# Create a new graph with the path /ActionGraph
og.Controller.edit(
    {"graph_path": "/ActionGraph", "evaluator_name": "execution"},
    {
        og.Controller.Keys.CREATE_NODES: [
            ("ReadSimTime", "omni.isaac.core_nodes.IsaacReadSimulationTime"),
            ("PublishClock", "omni.isaac.ros_bridge.ROS1PublishClock"),
            ("OnImpulseEvent", "omni.graph.action.OnImpulseEvent"),
        ],
        og.Controller.Keys.CONNECT: [
            # Connecting execution of OnImpulseEvent node to PublishClock so it will only publish when an impulse event is triggered
            ("OnImpulseEvent.outputs:execOut", "PublishClock.inputs:execIn"),
            # Connecting simulationTime data of ReadSimTime to the clock publisher node
            ("ReadSimTime.outputs:simulationTime", "PublishClock.inputs:timeStamp"),
        ],
        og.Controller.Keys.SET_VALUES: [
            # Assigning topic name to clock publisher
            ("PublishClock.inputs:topicName", "/clock"),
        ],
    },
)

On any frame, run the following to set an impulse event which will tick the clock publisher once:

og.Controller.set(og.Controller.attribute("/ActionGraph/OnImpulseEvent.state:enableImpulse"), True)

Note

Due to the explicit control of rendering and physics simulation steps in standalone scripting, the time it takes to complete each step will depend on the computation load and will likely not match real time. This may cause discrepancy in observed speed of action when running the same application via standalone scripting versus using the GUI. When that occurs, use the simulation clock as reference.

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 noetic_ws is sourced before these executing the samples below .

ROS Clock#

This sample demonstrates how to create an action graph with ROS component nodes 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

Echo the following topics to see messages being published:

rostopic echo /sim_time
rostopic echo /manual_time

To create and set up a ROS Clock publisher using the Isaac Sim UI, see the ROS Clock tutorial.

ROS Camera#

The following 2 samples demonstrates how to create a action graph with ROS1 Camera Helper OmniGraph nodes which are used to setup ROS RGB image, depth image and camera info publishers. Both samples accomplish the same outcome of publishing ROS image data at different rates but use different solutions.

  • On each frame:

    • Camera Info is published

  • Every 5 frames:

    • RGB image is published

  • Every 60 frames:

    • Depth image is published

Periodic Image Publishing#

The execution rate (every N frames) for each of the ROS image and camera info publishers are set by modifying their respective Isaac Simulation Gate OmniGraph nodes in the SDGPipeline graph. By setting the execution rate, an image publisher will automatically be ticked every N rendered frames.

The sample can be executed by running the following:

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

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

Manual Image Publishing#

The ROS image and camera info publishers are manually controlled by injecting Branch OmniGraph nodes between each publisher node and their respective Isaac Simulation Gate OmniGraph node. The Branch nodes act like a custom gate and can be enabled/disabled at any time. Whenever a Branch node is enabled, the connected ROS publisher node will be ticked.

The sample can be executed by running the following:

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

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

Visualizing Results#

To visualize the result of either sample in RViz, in a new ROS-sourced terminal navigate to the Isaac Sim package directory and run the following command:

rviz -d <noetic_ws>/src/isaac_tutorials/rviz/camera_manual.rviz

Carter Stereo#

This sample demonstrates how to take an existing USD stage with an action graph containing ROS component nodes and modifying the default settings. The stereo camera pair is automatically enabled and the second viewport window is docked in the UI.

  • On each frame:

    • The ROS clock is published

    • Lidar message is published

    • Odometry is published

    • The Twist subscriber is spun

    • TF messages are published

    • Left and right cameras are published

  • Every Two Frames:

    • The Twist command message is 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 <noetic_ws>/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.

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 externally 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}}'

Multiple Robot ROS Navigation#

This sample shows how to run an existing USD stage.

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

  • On each frame:

    • The ROS clock component is published

    • Lidar messages are published

    • Odometry is published

    • The Twist subscriber is spun

    • 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 --environment hospital

OR

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

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

MoveIt#

This sample shows how to add multiple USD stages. It also demonstrates how to manually create a action graph with ROS component nodes and then manually tick them.

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

  • On each frame:

    • The ROS clock is published

    • Joint State messages are published

    • Joint State subscriber is spun

    • 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

Summary#

In this tutorial we learned how to manually step ROS components and run standalone ROS python examples.

Next Steps#

Continue on to the next tutorial in our ROS Tutorials series, April Tags to learn how to detect April Tags.