From af51feb3e0f2631488c007e641898207a81b8471 Mon Sep 17 00:00:00 2001 From: Johnson Sun Date: Tue, 7 Jan 2025 00:50:52 +0800 Subject: [PATCH] feat(turtlebot3_ws): Publish camera rgb through OmniGraph Note that the `turtlebot3_burger_isaacsim.urdf.xacro` file is based on `turtlebot3_burger.urdf` Refs: - https://github.com/isaac-sim/urdf-importer-extension/blob/b161d55f4bcabe266b8db6707b5c2768aedcde21/source/extensions/omni.importer.urdf/data/urdf/tests/test_sensor.urdf#L52-L58 - https://github.com/isaac-sim/urdf-importer-extension/blob/b161d55f4bcabe266b8db6707b5c2768aedcde21/source/extensions/omni.importer.urdf/data/urdf/tests/test_advanced.urdf#L148-L154 --- docs/turtlebot3-ws/index.md | 1 + .../create_turtlebot3_burger_from_urdf.py | 2 +- ...create_turtlebot3_burger_with_omnigraph.py | 32 ++- .../scripts/create_urdf_from_xacro.sh | 5 + .../turtlebot3_burger_isaacsim.urdf.xacro | 204 ++++++++++++++++++ 5 files changed, 242 insertions(+), 2 deletions(-) create mode 100755 turtlebot3_ws/isaacsim/scripts/create_urdf_from_xacro.sh create mode 100644 turtlebot3_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_burger_isaacsim.urdf.xacro diff --git a/docs/turtlebot3-ws/index.md b/docs/turtlebot3-ws/index.md index 690bc23e..52003b4a 100644 --- a/docs/turtlebot3-ws/index.md +++ b/docs/turtlebot3-ws/index.md @@ -66,6 +66,7 @@ Convert URDF file to USD file and generate OmniGraph: ```sh cd /home/ros2-essentials/turtlebot3_ws/isaacsim/scripts +./create_urdf_from_xacro.sh python3 create_turtlebot3_burger_from_urdf.py python3 create_turtlebot3_burger_with_omnigraph.py ``` diff --git a/turtlebot3_ws/isaacsim/scripts/create_turtlebot3_burger_from_urdf.py b/turtlebot3_ws/isaacsim/scripts/create_turtlebot3_burger_from_urdf.py index ed7411cb..907398b9 100644 --- a/turtlebot3_ws/isaacsim/scripts/create_turtlebot3_burger_from_urdf.py +++ b/turtlebot3_ws/isaacsim/scripts/create_turtlebot3_burger_from_urdf.py @@ -48,7 +48,7 @@ def create_turtlebot3_burger_from_urdf(urdf_path, usd_path): omni.usd.get_context().save_stage() if __name__ == '__main__': - turtlebot3_burger_urdf_path = f'/home/ros2-essentials/turtlebot3_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_burger.urdf' + turtlebot3_burger_urdf_path = f'/home/ros2-essentials/turtlebot3_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_burger_isaacsim.urdf' turtlebot3_burger_usd_path = '/home/ros2-essentials/turtlebot3_ws/isaacsim/assets/turtlebot3_burger_urdf.usd' create_turtlebot3_burger_from_urdf(turtlebot3_burger_urdf_path, turtlebot3_burger_usd_path) print("Done") diff --git a/turtlebot3_ws/isaacsim/scripts/create_turtlebot3_burger_with_omnigraph.py b/turtlebot3_ws/isaacsim/scripts/create_turtlebot3_burger_with_omnigraph.py index 0ce173b3..4d75421b 100644 --- a/turtlebot3_ws/isaacsim/scripts/create_turtlebot3_burger_with_omnigraph.py +++ b/turtlebot3_ws/isaacsim/scripts/create_turtlebot3_burger_with_omnigraph.py @@ -1,3 +1,4 @@ +# By setting `debug` as True, this script can be executed in the `Script Editor` in Isaac Sim GUI debug = False if not debug: # Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/core_api_tutorials/tutorial_core_hello_world.html @@ -23,6 +24,8 @@ def create_turtlebot3_burger_with_omnigraph(): # Create turtlebot3_burger turtlebot3_burger_prim_path = "/World/turtlebot3_burger_urdf" + camera_prim_path = "/World/turtlebot3_burger_urdf/base_scan/camera" + camera_frame_id = "turtle" cmd_vel_topic = "/cmd_vel" joint_name_0 = "wheel_left_joint" joint_name_1 = "wheel_right_joint" @@ -101,6 +104,7 @@ def create_turtlebot3_burger_with_omnigraph(): og.Controller.Keys.SET_VALUES: [ ("ArticulationController.inputs:targetPrim", turtlebot3_burger_prim_path), ("SubscribeTwist.inputs:topicName", cmd_vel_topic), + # These three properties are hardcoded here, maybe it's better to infer them from the URDF/USD file. # Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/ros2_tutorials/tutorial_ros2_drive_turtlebot.html#graph-explained ("DifferentialController.inputs:maxLinearSpeed", 0.22), ("DifferentialController.inputs:wheelDistance", 0.16), @@ -114,7 +118,7 @@ def create_turtlebot3_burger_with_omnigraph(): ], }, ) - # OmniGraph for Clock + # OmniGraph for Publishing Clock # Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/ros2_tutorials/tutorial_ros2_clock.html og.Controller.edit( {"graph_path": "/ActionGraphClock", "evaluator_name": "execution"}, @@ -153,6 +157,32 @@ def create_turtlebot3_burger_with_omnigraph(): ], }, ) + # OmniGraph for Publishing Camera RGB + og.Controller.edit( + {"graph_path": "/ActionGraphPublishCameraRGB", "evaluator_name": "execution"}, + { + og.Controller.Keys.CREATE_NODES: [ + ("Context", "omni.isaac.ros2_bridge.ROS2Context"), + ("OnPlaybackTick", "omni.graph.action.OnPlaybackTick"), + ("RunOnce", "omni.isaac.core_nodes.OgnIsaacRunOneSimulationFrame"), + ("RenderProduct", "omni.isaac.core_nodes.IsaacCreateRenderProduct"), + ("RGBPublish", "omni.isaac.ros2_bridge.ROS2CameraHelper"), + ], + og.Controller.Keys.CONNECT: [ + ("OnPlaybackTick.outputs:tick", "RunOnce.inputs:execIn"), + ("RunOnce.outputs:step", "RenderProduct.inputs:execIn"), + ("RenderProduct.outputs:execOut", "RGBPublish.inputs:execIn"), + ("RenderProduct.outputs:renderProductPath", "RGBPublish.inputs:renderProductPath"), + ("Context.outputs:context", "RGBPublish.inputs:context"), + ], + og.Controller.Keys.SET_VALUES: [ + ("RenderProduct.inputs:cameraPrim", camera_prim_path), + ("RGBPublish.inputs:type", "rgb"), + ("RGBPublish.inputs:topicName", "rgb"), + ("RGBPublish.inputs:frameId", camera_frame_id), + ], + }, + ) if __name__ == '__main__': # Ref: https://docs.omniverse.nvidia.com/dev-guide/latest/programmer_ref/extensions/enable-kit-extension.html diff --git a/turtlebot3_ws/isaacsim/scripts/create_urdf_from_xacro.sh b/turtlebot3_ws/isaacsim/scripts/create_urdf_from_xacro.sh new file mode 100755 index 00000000..4c992ea8 --- /dev/null +++ b/turtlebot3_ws/isaacsim/scripts/create_urdf_from_xacro.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cd /home/ros2-essentials/turtlebot3_ws/src/turtlebot3/turtlebot3_description/urdf +# Ref: https://docs.ros.org/en/humble/Tutorials/Intermediate/URDF/Using-Xacro-to-Clean-Up-a-URDF-File.html +xacro turtlebot3_burger_isaacsim.urdf.xacro > /home/ros2-essentials/turtlebot3_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_burger_isaacsim.urdf diff --git a/turtlebot3_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_burger_isaacsim.urdf.xacro b/turtlebot3_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_burger_isaacsim.urdf.xacro new file mode 100644 index 00000000..7cd268a1 --- /dev/null +++ b/turtlebot3_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_burger_isaacsim.urdf.xacro @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +