.. _isaac_sim_app_tutorial_ros_python: =================================== ROS Bridge in Standalone Workflow =================================== Learning Objectives ================================ **Prerequisite** - Completed :ref:`isaac_sim_app_tutorial_intro_workflows` and :ref:`isaac_sim_app_tutorial_core_hello_world` to understand the two workflows (Standalone and Extension). Manually Stepping ROS Components =================================== One major usage for standalone scripting is to manually control the simulation steps. An `OnImpulseEvent` |omnigraph_short| node can be connected to any ROS |omnigraph_short| 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: .. code-block:: python 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: .. code-block:: python 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 . .. _isaac_sim_app_tutorial_ros_python_clock: 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: .. code-block:: bash ./python.sh standalone_examples/api/omni.isaac.ros_bridge/clock.py .. _isaac_sim_app_tutorial_ros_python_camera: ROS Camera *********** The following 2 samples demonstrates how to create a action graph with ROS1 Camera Helper |omnigraph_short| 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_short| 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: .. code-block:: bash ./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_short| nodes between each publisher node and their respective Isaac Simulation Gate |omnigraph_short| 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: .. code-block:: bash ./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_short| package directory and run the following command: .. code-block:: bash rviz -d /src/isaac_tutorials/rviz/camera_manual.rviz .. _isaac_sim_app_tutorial_ros_python_stereo: 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: .. code-block:: bash ./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 /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}}'`` .. raw:: html
.. raw:: html
.. _isaac_sim_app_tutorial_ros_python_multi_navigation: Multiple Robot ROS Navigation ********************************* This sample shows how to run an existing USD stage. To visualize the output see the :ref:`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: .. code-block:: bash ./python.sh standalone_examples/api/omni.isaac.ros_bridge/carter_multiple_robot_navigation.py hospital OR .. code-block:: bash ./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`` .. _isaac_sim_app_tutorial_ros_python_moveit: 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 :ref:`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: .. code-block:: bash ./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, :ref:`isaac_sim_app_tutorial_ros_apriltag` to learn how to detect April Tags.