Skip to content
Merged
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ wandb/

# Third party
third_party/
third-party/

# third-party files
**/clarius_cast/include
Expand Down
48 changes: 24 additions & 24 deletions tools/env_setup_robot_us.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ if ! nvidia-smi &> /dev/null; then
exit 1
fi

# Check if the third_party directory exists, if yes, then exit
if [ -d "$PROJECT_ROOT/third_party" ]; then
echo "Error: third_party directory already exists"
echo "Please remove the third_party directory before running this script"
# Check if the third-party directory exists, if yes, then exit
if [ -d "$PROJECT_ROOT/third-party" ]; then
echo "Error: third-party directory already exists"
echo "Please remove the third-party directory before running this script"
exit 1
fi

Expand All @@ -52,21 +52,20 @@ fi

# ---- Install IsaacSim and necessary dependencies ----
echo "Installing IsaacSim..."
pip install isaacsim==4.2.0.2 isaacsim-extscache-physics==4.2.0.2 \
isaacsim-extscache-kit==4.2.0.2 isaacsim-extscache-kit-sdk==4.2.0.2 \
pip install 'isaacsim[all,extscache]==4.5.0' \
rti.connext==7.3.0 pyrealsense2==2.55.1.6486 toml==0.10.2 dearpygui==2.0.0 \
git+ssh://[email protected]/isaac-for-healthcare/[email protected] \
git+ssh://[email protected]/isaac-for-healthcare/i4h-asset-catalog.git@mz/isaacsim45 \
setuptools==75.8.0 pydantic==2.10.6 \
--extra-index-url https://pypi.nvidia.com


# ---- Install IsaacLab ----
echo "Installing IsaacLab..."
# CLONING REPOSITORIES INTO PROJECT_ROOT/third_party
echo "Cloning repositories into $PROJECT_ROOT/third_party..."
mkdir $PROJECT_ROOT/third_party
git clone -b v1.4.1 [email protected]:isaac-sim/IsaacLab.git $PROJECT_ROOT/third_party/IsaacLab
pushd $PROJECT_ROOT/third_party/IsaacLab
sed -i "s/rsl-rl/rsl-rl-lib/g" source/extensions/omni.isaac.lab_tasks/setup.py
# CLONING REPOSITORIES INTO PROJECT_ROOT/third-party
echo "Cloning repositories into $PROJECT_ROOT/third-party..."
mkdir $PROJECT_ROOT/third-party
git clone -b v2.0.2 [email protected]:isaac-sim/IsaacLab.git $PROJECT_ROOT/third-party/IsaacLab
pushd $PROJECT_ROOT/third-party/IsaacLab
yes Yes | ./isaaclab.sh --install
popd

Expand All @@ -77,23 +76,24 @@ pushd $PROJECT_ROOT/workflows/robotic_ultrasound/scripts/simulation
pip install -e exts/robotic_us_ext
popd

# exit 0

# ---- Install OpenPI with IsaacSim 4.2 ----
echo "Installing OpenPI..."
# Clone the openpi repository
git clone [email protected]:Physical-Intelligence/openpi.git $PROJECT_ROOT/third_party/openpi
pushd $PROJECT_ROOT/third_party/openpi
git clone [email protected]:Physical-Intelligence/openpi.git $PROJECT_ROOT/third-party/openpi
pushd $PROJECT_ROOT/third-party/openpi
git checkout 581e07d73af36d336cef1ec9d7172553b2332193

# Update python version in pyproject.toml
pyproject_path="$PROJECT_ROOT/third_party/openpi/pyproject.toml"
pyproject_path="$PROJECT_ROOT/third-party/openpi/pyproject.toml"
sed -i.bak \
-e 's/requires-python = ">=3.11"/requires-python = ">=3.10"/' \
-e 's/"s3fs>=2024.9.0"/"s3fs==2024.9.0"/' \
"$pyproject_path"

# Apply temporary workaround for openpi/src/openpi/shared/download.py
file_path="$PROJECT_ROOT/third_party/openpi/src/openpi/shared/download.py"
file_path="$PROJECT_ROOT/third-party/openpi/src/openpi/shared/download.py"

# Comment out specific import lines
sed -i.bak \
Expand All @@ -109,7 +109,7 @@ sed -i.bak -e 's/)[[:space:]]*-> s3_transfer\.TransferManager[[:space:]]*:/):/'
sed -i.bak -e 's/datetime\.UTC/datetime.timezone.utc/' "$file_path"

# Modify the type hints in training/utils.py to use Any instead of optax types
utils_path="$PROJECT_ROOT/third_party/openpi/src/openpi/training/utils.py"
utils_path="$PROJECT_ROOT/third-party/openpi/src/openpi/training/utils.py"
sed -i.bak \
-e 's/opt_state: optax\.OptState/opt_state: Any/' \
"$utils_path"
Expand All @@ -120,19 +120,19 @@ rm "$file_path.bak"
rm "$utils_path.bak"

# Add training script to openpi module
if [ ! -f $PROJECT_ROOT/third_party/openpi/src/openpi/train.py ]; then
cp $PROJECT_ROOT/third_party/openpi/scripts/train.py $PROJECT_ROOT/third_party/openpi/src/openpi/train.py
if [ ! -f $PROJECT_ROOT/third-party/openpi/src/openpi/train.py ]; then
cp $PROJECT_ROOT/third-party/openpi/scripts/train.py $PROJECT_ROOT/third-party/openpi/src/openpi/train.py
fi

# Add norm stats generator script to openpi module
if [ ! -f $PROJECT_ROOT/third_party/openpi/src/openpi/compute_norm_stats.py ]; then
cp $PROJECT_ROOT/third_party/openpi/scripts/compute_norm_stats.py $PROJECT_ROOT/third_party/openpi/src/openpi/compute_norm_stats.py
if [ ! -f $PROJECT_ROOT/third-party/openpi/src/openpi/compute_norm_stats.py ]; then
cp $PROJECT_ROOT/third-party/openpi/scripts/compute_norm_stats.py $PROJECT_ROOT/third-party/openpi/src/openpi/compute_norm_stats.py
fi

# Install the dependencies
pip install git+https://github.com/huggingface/lerobot@6674e368249472c91382eb54bb8501c94c7f0c56
pip install -e $PROJECT_ROOT/third_party/openpi/packages/openpi-client/
pip install -e $PROJECT_ROOT/third_party/openpi/
pip install -e $PROJECT_ROOT/third-party/openpi/packages/openpi-client/
pip install -e $PROJECT_ROOT/third-party/openpi/

# Revert the "import changes of "$file_path after installation to prevent errors
sed -i \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import omni.usd
from dds.publisher import Publisher
from dds.subscriber import Subscriber
from omni.isaac.core import World
from isaacsim.core.api.world import World
from simulation.utils.ratelimit import add_physx_step_callback, remove_physx_callback

__all__ = ["Annotator"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
from dds.schemas.franka_ctrl import FrankaCtrlInput
from dds.schemas.franka_info import FrankaInfo
from dds.subscriber import Subscriber
from omni.isaac.core.robots import Robot
from omni.isaac.core.utils.types import ArticulationAction
from omni.isaac.franka import KinematicsSolver
from omni.isaac.franka.controllers.rmpflow_controller import RMPFlowController
from isaacsim.franka import KinematicsSolver
from isaacsim.franka.controllers.rmpflow_controller import RMPFlowController
from isaacsim.utils.types import ArticulationAction
from simulation.configs.config import FrankaConfig


Expand All @@ -44,7 +43,7 @@ class FrankaPublisher(Publisher):
domain_id: DDS domain identifier
"""

def __init__(self, franka: Robot, ik: bool, prim_path: str, topic: str, period: float, domain_id):
def __init__(self, franka, ik: bool, prim_path: str, topic: str, period: float, domain_id):
"""Initialize the Franka publisher."""
super().__init__(topic, FrankaInfo, period, domain_id)

Expand Down Expand Up @@ -73,7 +72,7 @@ def produce(self, dt: float, sim_time: float) -> Any:
return output

@staticmethod
def new_instance(config: FrankaConfig, franka: Robot):
def new_instance(config: FrankaConfig, franka):
"""Create a new FrankaPublisher instance from configuration.

Args:
Expand Down Expand Up @@ -108,7 +107,7 @@ class FrankaSubscriber(Subscriber):
domain_id: DDS domain identifier
"""

def __init__(self, franka: Robot, ik: bool, prim_path: str, topic: str, period: float, domain_id):
def __init__(self, franka, ik: bool, prim_path: str, topic: str, period: float, domain_id):
"""Initialize the Franka subscriber."""
super().__init__(topic, FrankaCtrlInput, period, domain_id)

Expand Down Expand Up @@ -163,7 +162,7 @@ def consume(self, input: FrankaCtrlInput) -> None:
self.franka_articulation_controller.apply_action(actions)

@staticmethod
def new_instance(config: FrankaConfig, franka: Robot):
def new_instance(config: FrankaConfig, franka):
"""Create a new FrankaSubscriber instance from configuration.

Args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from dds.schemas.target_ctrl import TargetCtrlInput
from dds.schemas.target_info import TargetInfo
from dds.subscriber import Subscriber
from omni.isaac.core.prims import XFormPrim
from isaacsim.core.prims import XFormPrim
from simulation.configs.config import TargetConfig


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from dds.publisher import Publisher
from dds.schemas.usp_info import UltraSoundProbeInfo
from omni.isaac.core.prims import XFormPrim
from isaacsim.core.prims import XFormPrim
from simulation.configs.config import UltraSoundConfig


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from dds.publisher import Publisher
from dds.schemas.camera_info import CameraInfo
from omni.isaac.lab.app import AppLauncher
from isaaclab.app import AppLauncher

# add argparse arguments
parser = argparse.ArgumentParser(description="This script demonstrates a single-arm manipulator.")
Expand Down Expand Up @@ -101,8 +101,8 @@
"""Import remaining modules."""
import gymnasium as gym # noqa: F401
import torch # noqa: F401
from isaaclab_tasks.utils.parse_cfg import parse_env_cfg # noqa: F401
from meta_state_machine.ultrasound_state_machine import UltrasoundStateMachine # noqa: F401
from omni.isaac.lab_tasks.utils.parse_cfg import parse_env_cfg # noqa: F401
from robotic_us_ext import tasks # noqa: F401
from simulation.environments.state_machine.data_collection import DataCollectionManager # noqa: F401
from simulation.environments.state_machine.modules.force_module import ForceControlModule # noqa: F401
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from typing import Dict

import torch
from omni.isaac.core.prims import RigidPrimView
from isaacsim.core.prims import RigidPrimView
from simulation.environments.state_machine.modules.base_module import BaseControlModule
from simulation.environments.state_machine.utils import SMState, compute_relative_action

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

import torch
from omni.isaac.lab.utils.math import euler_xyz_from_quat, quat_from_euler_xyz
from isaaclab.utils.math import euler_xyz_from_quat, quat_from_euler_xyz
from simulation.environments.state_machine.utils import RobotQuaternions, SMState, UltrasoundState

from .base_module import BaseControlModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

import torch
from omni.isaac.lab.utils.math import quat_apply_yaw
from isaaclab.utils.math import quat_apply_yaw
from simulation.environments.state_machine.modules.base_module import BaseControlModule
from simulation.environments.state_machine.utils import PhantomScanPositions, SMState, UltrasoundState

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import gymnasium as gym
import numpy as np
import torch
from omni.isaac.lab.app import AppLauncher
from isaaclab.app import AppLauncher
from policy_runner import PI0PolicyRunner
from simulation.environments.state_machine.utils import (
RobotPositions,
Expand All @@ -37,14 +37,16 @@
"--disable_fabric", action="store_true", default=False, help="Disable fabric and use USD I/O operations."
)
parser.add_argument("--num_envs", type=int, default=1, help="Number of environments to spawn.")
parser.add_argument("--task", type=str, default=None, help="Name of the task.")
parser.add_argument("--task", type=str, default="Isaac-Teleop-Torso-FrankaUsRs-IK-RL-Rel-v0", help="Name of the task.")
parser.add_argument(
"--ckpt_path",
type=str,
default=robot_us_assets.policy_ckpt,
help="checkpoint path. Default to use policy checkpoint in the latest assets.",
)
parser.add_argument("--repo_id", type=str, help="the LeRobot repo id for the dataset norm.")
parser.add_argument(
"--repo_id", type=str, default="i4h/sim_liver_scan", help="the LeRobot repo id for the dataset norm."
)

# append AppLauncher cli argr
AppLauncher.add_app_launcher_args(parser)
Expand All @@ -57,7 +59,7 @@
reset_flag = False

# isort: off
from omni.isaac.lab_tasks.utils.parse_cfg import parse_env_cfg
from isaaclab_tasks.utils.parse_cfg import parse_env_cfg

# Import extensions to set up environment tasks
from robotic_us_ext import tasks # noqa: F401
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
from enum import Enum
from typing import Sequence

import isaaclab.utils.math as math_utils # noqa: F401
import numpy as np
import omni.isaac.lab.utils.math as math_utils # noqa: F401
import onnxruntime as ort
import torch
from omni.isaac.lab.utils.math import compute_pose_error, quat_from_euler_xyz


# MARK: - State Machine Enums + Dataclasses
Expand Down Expand Up @@ -65,7 +64,7 @@ class RobotQuaternions:
DOWN_EULER_DEG = (180.0, 0.0, 180)
# Convert to radians and then to quaternion
DOWN: tuple[float, float, float, float] = tuple(
quat_from_euler_xyz(
math_utils.quat_from_euler_xyz(
torch.tensor(math.radians(DOWN_EULER_DEG[0])), # X rotation (rad)
torch.tensor(math.radians(DOWN_EULER_DEG[1])), # Y rotation (rad)
torch.tensor(math.radians(DOWN_EULER_DEG[2])), # Z rotation (rad)
Expand Down Expand Up @@ -113,7 +112,7 @@ def compute_relative_action(action: torch.Tensor, robot_obs: torch.Tensor, retur
"""Compute the relative action from the robot observation."""
pos_sm = action[:, :3]
rot_sm = action[:, 3:]
delta_pos, delta_angle = compute_pose_error(
delta_pos, delta_angle = math_utils.compute_pose_error(
robot_obs[0, :, :3], robot_obs[0, :, 3:], pos_sm, rot_sm, rot_error_type="axis_angle"
)
rel_action = torch.cat([delta_pos, delta_angle], dim=-1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import argparse
import os

from omni.isaac.lab.app import AppLauncher
from isaaclab.app import AppLauncher

# add argparse arguments
parser = argparse.ArgumentParser(description="Keyboard teleoperation for Isaac Lab environments.")
Expand Down Expand Up @@ -109,19 +109,19 @@
import time # noqa: F401

import gymnasium as gym # noqa: F401
import omni.isaac.lab.utils.math as math_utils # noqa: F401
import omni.isaac.lab_tasks # noqa: F401
import isaaclab.utils.math as math_utils # noqa: F401
import isaaclab_tasks # noqa: F401
import omni.log # noqa: F401
import torch # noqa: F401
from dds.publisher import Publisher # noqa: F401
from dds.schemas.camera_info import CameraInfo # noqa: F401
from dds.schemas.franka_info import FrankaInfo # noqa: F401
from dds.schemas.usp_info import UltraSoundProbeInfo # noqa: F401
from omni.isaac.lab.devices import Se3Keyboard, Se3SpaceMouse # noqa: F401
from omni.isaac.lab.managers import SceneEntityCfg # noqa: F401
from omni.isaac.lab.managers import TerminationTermCfg as DoneTerm # noqa: F401
from omni.isaac.lab_tasks.manager_based.manipulation.lift import mdp # noqa: F401
from omni.isaac.lab_tasks.utils import parse_env_cfg # noqa: F401
from isaaclab.devices import Se3Keyboard, Se3SpaceMouse # noqa: F401
from isaaclab.managers import SceneEntityCfg # noqa: F401
from isaaclab.managers import TerminationTermCfg as DoneTerm # noqa: F401
from isaaclab_tasks.manager_based.manipulation.lift import mdp # noqa: F401
from isaaclab_tasks.utils import parse_env_cfg # noqa: F401

# Import extensions to set up environment tasks
from robotic_us_ext import tasks # noqa: F401
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from dds.schemas.franka_info import FrankaInfo
from dds.schemas.usp_info import UltraSoundProbeInfo
from dds.subscriber import SubscriberWithQueue
from omni.isaac.lab.app import AppLauncher
from isaaclab.app import AppLauncher
from simulation.environments.state_machine.utils import (
RobotPositions,
RobotQuaternions,
Expand Down Expand Up @@ -115,7 +115,7 @@
reset_flag = False

# isort: off
from omni.isaac.lab_tasks.utils.parse_cfg import parse_env_cfg
from isaaclab_tasks.utils.parse_cfg import parse_env_cfg

# Import extensions to set up environment tasks
from robotic_us_ext import tasks # noqa: F401
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

"""

import omni.isaac.lab.sim as sim_utils
from omni.isaac.lab.actuators import ImplicitActuatorCfg
from omni.isaac.lab.assets.articulation import ArticulationCfg
from omni.isaac.lab.utils.assets import ISAACLAB_NUCLEUS_DIR
import isaaclab.sim as sim_utils
from isaaclab.actuators import ImplicitActuatorCfg
from isaaclab.assets.articulation import ArticulationCfg
from isaaclab.utils.assets import ISAACLAB_NUCLEUS_DIR
from simulation.utils.assets import robotic_ultrasound_assets as robot_us_assets

##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

"""Package containing task implementations for various robotic environments."""

from omni.isaac.lab_tasks.utils import import_packages
from isaaclab_tasks.utils import import_packages

##
# Register Gym environments.
Expand Down
Loading
Loading