|
1 | 1 | # -*- coding: utf-8 -*-
|
2 |
| -# Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved. |
| 2 | +# Copyright (c) 2020-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 3 | +# Copyright (c) 2023 PickNik, LLC. All rights reserved. |
3 | 4 | #
|
4 |
| -# NVIDIA CORPORATION and its licensors retain all intellectual property |
5 |
| -# and proprietary rights in and to this software, related documentation |
6 |
| -# and any modifications thereto. Any use, reproduction, disclosure or |
7 |
| -# distribution of this software and related documentation without an express |
8 |
| -# license agreement from NVIDIA CORPORATION is strictly prohibited. |
| 5 | +# Redistribution and use in source and binary forms, with or without |
| 6 | +# modification, are permitted provided that the following conditions are met: |
| 7 | +# |
| 8 | +# * Redistributions of source code must retain the above copyright notice, this |
| 9 | +# list of conditions and the following disclaimer. |
| 10 | +# |
| 11 | +# * Redistributions in binary form must reproduce the above copyright notice, |
| 12 | +# this list of conditions and the following disclaimer in the documentation |
| 13 | +# and/or other materials provided with the distribution. |
| 14 | +# |
| 15 | +# * Neither the name of the copyright holder nor the names of its |
| 16 | +# contributors may be used to endorse or promote products derived from |
| 17 | +# this software without specific prior written permission. |
| 18 | +# |
| 19 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 | +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 22 | +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 23 | +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 24 | +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 25 | +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 26 | +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 27 | +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 | +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
9 | 29 |
|
10 | 30 | import sys
|
11 | 31 | import re
|
|
14 | 34 | import carb
|
15 | 35 | import numpy as np
|
16 | 36 | from pathlib import Path
|
17 |
| -from omni.isaac.kit import SimulationApp |
| 37 | + |
| 38 | +# In older versions of Isaac Sim (prior to 4.0), SimulationApp is imported from |
| 39 | +# omni.isaac.kit rather than isaacsim. |
| 40 | +try: |
| 41 | + from isaacsim import SimulationApp |
| 42 | +except: |
| 43 | + from omni.isaac.kit import SimulationApp |
18 | 44 |
|
19 | 45 | FRANKA_STAGE_PATH = "/Franka"
|
20 | 46 | FRANKA_USD_PATH = "/Isaac/Robots/Franka/franka_alt_fingers.usd"
|
|
26 | 52 |
|
27 | 53 | CONFIG = {"renderer": "RayTracedLighting", "headless": False}
|
28 | 54 |
|
29 |
| -# Example ROS2 bridge sample demonstrating the manual loading of stages |
30 |
| -# and creation of ROS components |
31 | 55 | simulation_app = SimulationApp(CONFIG)
|
32 | 56 |
|
| 57 | +from omni.isaac.version import get_version |
| 58 | + |
| 59 | +# Check the major version number of Isaac Sim to see if it's four digits, corresponding |
| 60 | +# to Isaac Sim 2023.1.1 or older. The version numbering scheme changed with the |
| 61 | +# Isaac Sim 4.0 release in 2024. |
| 62 | +is_legacy_isaacsim = len(get_version()[2]) == 4 |
33 | 63 |
|
34 | 64 | # More imports that need to compare after we create the app
|
35 | 65 | from omni.isaac.core import SimulationContext # noqa E402
|
|
123 | 153 | print("ROS_DOMAIN_ID environment variable is not set. Setting value to 0")
|
124 | 154 | ros_domain_id = 0
|
125 | 155 |
|
126 |
| -# Creating a action graph with ROS component nodes |
| 156 | +# Create an action graph with ROS component nodes |
127 | 157 | try:
|
| 158 | + og_keys_set_values = [ |
| 159 | + ("Context.inputs:domain_id", ros_domain_id), |
| 160 | + # Set the /Franka target prim to Articulation Controller node |
| 161 | + ("ArticulationController.inputs:robotPath", FRANKA_STAGE_PATH), |
| 162 | + ("PublishJointState.inputs:topicName", "isaac_joint_states"), |
| 163 | + ("SubscribeJointState.inputs:topicName", "isaac_joint_commands"), |
| 164 | + ("createViewport.inputs:name", REALSENSE_VIEWPORT_NAME), |
| 165 | + ("createViewport.inputs:viewportId", 1), |
| 166 | + ("cameraHelperRgb.inputs:frameId", "sim_camera"), |
| 167 | + ("cameraHelperRgb.inputs:topicName", "rgb"), |
| 168 | + ("cameraHelperRgb.inputs:type", "rgb"), |
| 169 | + ("cameraHelperInfo.inputs:frameId", "sim_camera"), |
| 170 | + ("cameraHelperInfo.inputs:topicName", "camera_info"), |
| 171 | + ("cameraHelperInfo.inputs:type", "camera_info"), |
| 172 | + ("cameraHelperDepth.inputs:frameId", "sim_camera"), |
| 173 | + ("cameraHelperDepth.inputs:topicName", "depth"), |
| 174 | + ("cameraHelperDepth.inputs:type", "depth"), |
| 175 | + ] |
| 176 | + |
| 177 | + # In older versions of Isaac Sim, the articulation controller node contained a |
| 178 | + # "usePath" checkbox input that should be enabled. |
| 179 | + if is_legacy_isaacsim: |
| 180 | + og_keys_set_values.insert(1, ("ArticulationController.inputs:usePath", True)) |
| 181 | + |
128 | 182 | og.Controller.edit(
|
129 | 183 | {"graph_path": GRAPH_PATH, "evaluator_name": "execution"},
|
130 | 184 | {
|
|
212 | 266 | "cameraHelperDepth.inputs:renderProductPath",
|
213 | 267 | ),
|
214 | 268 | ],
|
215 |
| - og.Controller.Keys.SET_VALUES: [ |
216 |
| - ("Context.inputs:domain_id", ros_domain_id), |
217 |
| - # Setting the /Franka target prim to Articulation Controller node |
218 |
| - ("ArticulationController.inputs:usePath", True), |
219 |
| - ("ArticulationController.inputs:robotPath", FRANKA_STAGE_PATH), |
220 |
| - ("PublishJointState.inputs:topicName", "isaac_joint_states"), |
221 |
| - ("SubscribeJointState.inputs:topicName", "isaac_joint_commands"), |
222 |
| - ("createViewport.inputs:name", REALSENSE_VIEWPORT_NAME), |
223 |
| - ("createViewport.inputs:viewportId", 1), |
224 |
| - ("cameraHelperRgb.inputs:frameId", "sim_camera"), |
225 |
| - ("cameraHelperRgb.inputs:topicName", "rgb"), |
226 |
| - ("cameraHelperRgb.inputs:type", "rgb"), |
227 |
| - ("cameraHelperInfo.inputs:frameId", "sim_camera"), |
228 |
| - ("cameraHelperInfo.inputs:topicName", "camera_info"), |
229 |
| - ("cameraHelperInfo.inputs:type", "camera_info"), |
230 |
| - ("cameraHelperDepth.inputs:frameId", "sim_camera"), |
231 |
| - ("cameraHelperDepth.inputs:topicName", "depth"), |
232 |
| - ("cameraHelperDepth.inputs:type", "depth"), |
233 |
| - ], |
| 269 | + og.Controller.Keys.SET_VALUES: og_keys_set_values, |
234 | 270 | },
|
235 | 271 | )
|
236 | 272 | except Exception as e:
|
|
0 commit comments