Skip to content

Commit 45acb1f

Browse files
authored
Update isaac_panda example for compatibility with Isaac Sim 4.0 (#908)
* Update isaac_panda example for compatibility with Isaac Sim 4.0 In addition, the header of the Isaac Sim launch script has been updated to indicate that it has been licensed (by NVIDIA) under BSD-3. * Fix formatting
1 parent 2ac49ce commit 45acb1f

File tree

2 files changed

+72
-29
lines changed

2 files changed

+72
-29
lines changed

doc/how_to_guides/isaac_panda/launch/isaac_moveit.py

Lines changed: 65 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
# -*- 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.
34
#
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.
929

1030
import sys
1131
import re
@@ -14,7 +34,13 @@
1434
import carb
1535
import numpy as np
1636
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
1844

1945
FRANKA_STAGE_PATH = "/Franka"
2046
FRANKA_USD_PATH = "/Isaac/Robots/Franka/franka_alt_fingers.usd"
@@ -26,10 +52,14 @@
2652

2753
CONFIG = {"renderer": "RayTracedLighting", "headless": False}
2854

29-
# Example ROS2 bridge sample demonstrating the manual loading of stages
30-
# and creation of ROS components
3155
simulation_app = SimulationApp(CONFIG)
3256

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
3363

3464
# More imports that need to compare after we create the app
3565
from omni.isaac.core import SimulationContext # noqa E402
@@ -123,8 +153,32 @@
123153
print("ROS_DOMAIN_ID environment variable is not set. Setting value to 0")
124154
ros_domain_id = 0
125155

126-
# Creating a action graph with ROS component nodes
156+
# Create an action graph with ROS component nodes
127157
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+
128182
og.Controller.edit(
129183
{"graph_path": GRAPH_PATH, "evaluator_name": "execution"},
130184
{
@@ -212,25 +266,7 @@
212266
"cameraHelperDepth.inputs:renderProductPath",
213267
),
214268
],
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,
234270
},
235271
)
236272
except Exception as e:

doc/how_to_guides/isaac_panda/launch/python.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ do
1818
fi
1919
done
2020

21+
# When installed from the Omniverse Launcher, recent versions of Isaac Sim have a dash
22+
# rather than underscore in their installation directory name (e.g., isaac-sim-4.0.0).
23+
for ISAAC_SCRIPT_DIR in $(ls -d -- $OV_PKG_DIR/isaac-sim-*);
24+
do
25+
ISAAC_SCRIPT_DIRS+=($ISAAC_SCRIPT_DIR)
26+
done
27+
2128
# Prepend the path to all arguments passed in
2229
CUR_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2330
NEW_ARGS=""

0 commit comments

Comments
 (0)