Skip to content

Commit

Permalink
refactor(aloha_ws): Remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
j3soon committed Sep 9, 2024
1 parent a26cf1a commit 855bdd6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 41 deletions.
5 changes: 4 additions & 1 deletion aloha_ws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ isaacsim omni.isaac.sim

Open pre-configured USD file with OmniGraph:

- `File > Open` and in `File name:` type `/home/ros2-essentials/aloha_ws/isaacsim/assets/vx300s_og.usd`
- `File > Open` and in `File name:` type:
```
/home/ros2-essentials/aloha_ws/isaacsim/assets/vx300s_og.usd
```
- Click `Window > Visual Scripting > Action Graph`
- In the `Action Graph` tab, click `Edit Action Graph` and select `/ActionGraph`
- Click `Play (SPACE)`
Expand Down
23 changes: 5 additions & 18 deletions aloha_ws/isaacsim/scripts/create_vx300s_from_urdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,19 @@

# Ref: https://docs.omniverse.nvidia.com/isaacsim/latest/advanced_tutorials/tutorial_advanced_import_urdf.html#importing-urdf-using-python

import asyncio
import logging
import os

import omni.kit.commands
import omni.usd
from omni.importer.urdf import _urdf
from omni.kit import ui_test
from pxr import UsdPhysics

# Ref: https://docs.omniverse.nvidia.com/kit/docs/kit-manual/latest/guide/logging.html
# `print(...)` outputs to Script Editor, while `logger.info(...)` outputs to console.
logger = logging.getLogger(__name__)


def log(msg):
# Print to console
# Ref: https://docs.omniverse.nvidia.com/kit/docs/kit-manual/latest/guide/logging.html
logger.info(msg)
# Print to Script Editor
print(msg)

async def create_new_stage_with_defaults():
menu_widget = ui_test.get_menubar()
await menu_widget.find_menu("File").click()
await menu_widget.find_menu("New").click()
log("Done!")
simulation_app.close()

def create_vx300s_from_urdf(urdf_path, usd_path):
# Set the settings in the import config
import_config = _urdf.ImportConfig()
Expand Down Expand Up @@ -61,8 +47,9 @@ def create_vx300s_from_urdf(urdf_path, usd_path):
omni.usd.get_context().save_stage()

if __name__ == '__main__':
print("Creating `vx300s.usd` from urdf...")
vx300s_urdf_path = f'{os.path.expanduser("~")}/interbotix_ws/src/interbotix_ros_manipulators/interbotix_ros_xsarms/interbotix_xsarm_descriptions/urdf/vx300s.urdf'
vx300s_usd_path = '/home/ros2-essentials/aloha_ws/isaacsim/assets/vx300s_urdf.usd'
create_vx300s_from_urdf(vx300s_urdf_path, vx300s_usd_path)
asyncio.ensure_future(create_new_stage_with_defaults())
print("Done")
logger.info("Done")
simulation_app.close()
28 changes: 6 additions & 22 deletions aloha_ws/isaacsim/scripts/create_vx300s_with_omnigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@
import omni.graph.core as og
import omni.kit.app
import omni.usd
from omni.isaac.core import World

# Ref: https://docs.omniverse.nvidia.com/kit/docs/kit-manual/latest/guide/logging.html
# `print(...)` outputs to Script Editor, while `logger.info(...)` outputs to console.
logger = logging.getLogger(__name__)


def log(msg):
# Print to console
# Ref: https://docs.omniverse.nvidia.com/kit/docs/kit-manual/latest/guide/logging.html
logger.info(msg)
# Print to Script Editor
print(msg)

def create_vx300s_with_omnigraph():
# Create vx300s
vx300s_prim_path = "/World/vx300s_urdf"
Expand Down Expand Up @@ -72,22 +66,12 @@ def create_vx300s_with_omnigraph():
if __name__ == '__main__':
# Ref: https://docs.omniverse.nvidia.com/dev-guide/latest/programmer_ref/extensions/enable-kit-extension.html
manager = omni.kit.app.get_app().get_extension_manager()
# enable immediately
manager.set_extension_enabled_immediate("omni.isaac.ros2_bridge", True)
log("ros2_bridge enabled: " + str(manager.is_extension_enabled("omni.isaac.ros2_bridge")))
print("ros2_bridge enabled: " + str(manager.is_extension_enabled("omni.isaac.ros2_bridge")))
logger.info("ros2_bridge enabled: " + str(manager.is_extension_enabled("omni.isaac.ros2_bridge")))
create_vx300s_with_omnigraph()
vx300s_og_usd_path = '/home/ros2-essentials/aloha_ws/isaacsim/assets/vx300s_og.usd'
omni.usd.get_context().save_as_stage(vx300s_og_usd_path)
log("Done!")
# # Ref: `~/.local/share/ov/pkg/isaac-sim-4.1.0/standalone_examples/api/omni.isaac.franka/follow_target_with_rmpflow.py`
# my_world = World(stage_units_in_meters=1.0)
# reset_needed = False
# while simulation_app.is_running():
# my_world.step(render=True)
# if my_world.is_stopped() and not reset_needed:
# reset_needed = True
# if my_world.is_playing():
# if reset_needed:
# my_world.reset()
# reset_needed = False
print("Done")
logger.info("Done")
simulation_app.close()

0 comments on commit 855bdd6

Please sign in to comment.