-
Notifications
You must be signed in to change notification settings - Fork 6
Docker build for robotic surgery to enable webrtc streaming #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a51d9b7
Docker build for robotic surgery to enable webrtc streaming
mingxin-zheng 5d7697c
fix format
mingxin-zheng 5ed128f
fix link
mingxin-zheng 8889c33
add licenses
mingxin-zheng c06a614
Merge branch 'main' into mz/docker_surgery
mingxin-zheng f3d612b
Merge branch 'main' into mz/docker_surgery
mingxin-zheng 0a7aaed
increase time for a10
mingxin-zheng 0852152
address comment
mingxin-zheng a8fd43c
autofix
mingxin-zheng 28f1b50
license
mingxin-zheng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ INCLUDE_PATTERNS=( | |
| "*.hpp" | ||
| "*.cu" | ||
| "*.cpp" | ||
| "Dockerfile*" | ||
| ) | ||
|
|
||
| # Directories to explicitly exclude | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #!/bin/bash | ||
|
|
||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
|
|
||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| set -e | ||
|
|
||
| # Get the parent directory of the current script | ||
| PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd ../.. && pwd)" | ||
|
|
||
| # Check if running in a conda environment | ||
| if [ -z "$CONDA_DEFAULT_ENV" ]; then | ||
| echo "Error: No active conda environment detected" | ||
| echo "Please activate a conda environment before running this script" | ||
| exit 1 | ||
| fi | ||
| echo "Using conda environment: $CONDA_DEFAULT_ENV" | ||
|
|
||
| # Check if NVIDIA GPU is available | ||
| if ! nvidia-smi &> /dev/null; then | ||
| echo "Error: NVIDIA GPU not found or driver not installed" | ||
| 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" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # ---- Clone IsaacLab ---- | ||
| echo "Cloning IsaacLab..." | ||
| # 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 | ||
|
|
||
| # ---- Install IsaacSim and necessary dependencies ---- | ||
| echo "Installing IsaacSim..." | ||
| pip install 'isaacsim[all,extscache]==4.5.0' \ | ||
| git+ssh://[email protected]/isaac-for-healthcare/[email protected] \ | ||
| --extra-index-url https://pypi.nvidia.com | ||
|
|
||
| echo "Installing IsaacLab ..." | ||
| yes Yes | ./isaaclab.sh --install | ||
| popd | ||
|
|
||
| # ---- Install libstdcxx-ng for mesa ---- | ||
| echo "Installing libstdcxx-ng..." | ||
| conda install -c conda-forge libstdcxx-ng=13.2.0 -y | ||
|
|
||
| echo "IsaacSim and dependencies installed successfully!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #!/bin/bash | ||
|
|
||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
|
|
||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| set -e | ||
|
|
||
| # Get the parent directory of the current script | ||
| PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd ../.. && pwd)" | ||
|
|
||
| # Can take EXTS_DIR from input, default to $PROJECT_ROOT/workflows/robotic_surgery/scripts/simulation/exts | ||
| EXTS_DIR=${1:-$PROJECT_ROOT/workflows/robotic_surgery/scripts/simulation/exts} | ||
|
|
||
| # Allow setting the python in PYTHON_EXECUTABLE | ||
| PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-python} | ||
|
|
||
| # ---- Install robotic.surgery.assets and robotic.surgery.tasks ---- | ||
| echo "Installing robotic.surgery.assets and robotic.surgery.tasks..." | ||
| $PYTHON_EXECUTABLE -m pip install --no-build-isolation -e $EXTS_DIR/robotic.surgery.assets | ||
| $PYTHON_EXECUTABLE -m pip install --no-build-isolation -e $EXTS_DIR/robotic.surgery.tasks | ||
|
|
||
| echo "Extensions installed successfully!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ | |
| set -e | ||
|
|
||
| # Get the parent directory of the current script | ||
| PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. && pwd)" | ||
| PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
|
||
| # Check if running in a conda environment | ||
| if [ -z "$CONDA_DEFAULT_ENV" ]; then | ||
|
|
@@ -41,36 +41,11 @@ if [ -d "$PROJECT_ROOT/third_party" ]; then | |
| exit 1 | ||
| fi | ||
|
|
||
| # Run the installation scripts | ||
| echo "Installing IsaacSim and dependencies..." | ||
| bash $PROJECT_ROOT/env_setup/install_isaac.sh | ||
|
|
||
| # ---- Clone IsaacLab ---- | ||
| echo "Cloning IsaacLab..." | ||
| # 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 | ||
| echo "Installing extensions..." | ||
| bash $PROJECT_ROOT/env_setup/install_robotic_surgery_extensions.sh | ||
|
|
||
|
|
||
| # ---- Install IsaacSim and necessary dependencies ---- | ||
| echo "Installing IsaacSim..." | ||
| pip install 'isaacsim[all,extscache]==4.5.0' \ | ||
| git+ssh://[email protected]/isaac-for-healthcare/[email protected] \ | ||
| --extra-index-url https://pypi.nvidia.com | ||
|
|
||
|
|
||
| echo "Installing IsaacLab ..." | ||
| yes Yes | ./isaaclab.sh --install | ||
| popd | ||
|
|
||
|
|
||
| # ---- Install robotic.surgery.assets and robotic.surgery.tasks ---- | ||
| echo "Installing robotic.surgery.assets and robotic.surgery.tasks..." | ||
| pip install -e $PROJECT_ROOT/workflows/robotic_surgery/scripts/simulation/exts/robotic.surgery.assets | ||
| pip install -e $PROJECT_ROOT/workflows/robotic_surgery/scripts/simulation/exts/robotic.surgery.tasks | ||
|
|
||
|
|
||
| # ---- Install libstdcxx-ng for mesa ---- | ||
| echo "Installing libstdcxx-ng..." | ||
| conda install -c conda-forge libstdcxx-ng=13.2.0 -y | ||
|
|
||
| echo "Dependencies installed successfully!" | ||
| echo "All dependencies installed successfully!" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # syntax=docker/dockerfile:1.4 | ||
mingxin-zheng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
|
|
||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| FROM nvcr.io/nvidia/isaac-lab:2.0.2 | ||
|
|
||
| # This line enables SSH access for the following RUN command | ||
| RUN apt-get update && apt-get install -y git openssh-client | ||
|
|
||
| # Add GitHub to known hosts to avoid "host key verification failed" | ||
| RUN mkdir -p ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts | ||
|
|
||
| WORKDIR /workspace/robotic_surgery/scripts | ||
|
|
||
| # Fix livestream public endpoint address issue in 2.0.2/2.1.0 | ||
| RUN sed -i '/--\/app\/livestream\/publicEndpointAddress=/d' /workspace/isaaclab/source/isaaclab/isaaclab/app/app_launcher.py | ||
|
|
||
| COPY workflows/robotic_surgery/scripts . | ||
|
|
||
| COPY tools/env_setup/install_robotic_surgery_extensions.sh /tmp/install_robotic_surgery_extensions.sh | ||
|
|
||
| ENV PYTHONPATH=/workspace/robotic_surgery/scripts | ||
|
|
||
| ENV PYTHON_EXECUTABLE=/workspace/isaaclab/_isaac_sim/python.sh | ||
|
|
||
| RUN --mount=type=ssh $PYTHON_EXECUTABLE -m pip install --no-deps git+ssh://[email protected]/isaac-for-healthcare/[email protected] | ||
|
|
||
| # Install the robotic surgery extensions | ||
| # Extension installation also needs to know which python to use via the PYTHON_EXECUTABLE environment variable | ||
| RUN /tmp/install_robotic_surgery_extensions.sh simulation/exts | ||
|
|
||
| # Clean up the install script | ||
| RUN rm /tmp/install_robotic_surgery_extensions.sh | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Simulation LiveStream from Remote Docker Container | ||
|
|
||
| This document describes how to run the simulation in a remote docker container and stream the simulation to a local machine. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Please refer to [Livestream Clients Guide in Isaac Sim](https://docs.isaacsim.omniverse.nvidia.com/latest/installation/manual_livestream_clients.html#isaac-sim-short-webrtc-streaming-client) and download [Isaac Sim WebRTC Streamiing Client](https://docs.isaacsim.omniverse.nvidia.com/latest/installation/download.html#isaac-sim-latest-release) | ||
|
|
||
| ## Build Docker Image | ||
|
|
||
| To build the docker image, you will need to set up the SSH agent and add your SSH key to the agent, so that the docker build process can access the private repository. | ||
|
|
||
| ```bash | ||
| export DOCKER_BUILDKIT=1 | ||
| eval "$(ssh-agent -s)" | ||
| ssh-add ~/.ssh/id_ed25519 # Replace with your SSH key | ||
| docker build --ssh default -f workflows/robotic_surgery/docker/Dockerfile -t robotic_surgery:latest . | ||
| ``` | ||
|
|
||
| ## Prepare the I4H Asset Locally | ||
|
|
||
| Please refer to the [Environment Setup](../README.md#environment-setup) for instructions to prepare the I4H assets locally. | ||
|
|
||
| This will create a directory `~/.cache/i4h-assets/<sha256>` containing the I4H assets, which will be mounted to the docker container. | ||
|
|
||
| ## Run the Container | ||
|
|
||
| ```bash | ||
| docker run --name isaac-sim --entrypoint bash -it --runtime=nvidia --gpus all -e "ACCEPT_EULA=Y" --rm --network=host \ | ||
| -e "PRIVACY_CONSENT=Y" \ | ||
| -v ~/docker/isaac-sim/cache/kit:/isaac-sim/kit/cache:rw \ | ||
| -v ~/docker/isaac-sim/cache/ov:/root/.cache/ov:rw \ | ||
| -v ~/docker/isaac-sim/cache/pip:/root/.cache/pip:rw \ | ||
| -v ~/docker/isaac-sim/cache/glcache:/root/.cache/nvidia/GLCache:rw \ | ||
| -v ~/docker/isaac-sim/cache/computecache:/root/.nv/ComputeCache:rw \ | ||
| -v ~/docker/isaac-sim/logs:/root/.nvidia-omniverse/logs:rw \ | ||
| -v ~/docker/isaac-sim/data:/root/.local/share/ov/data:rw \ | ||
| -v ~/docker/isaac-sim/documents:/root/Documents:rw \ | ||
| -v ~/.cache/i4h-assets:/root/.cache/i4h-assets:rw \ | ||
| robotic_surgery:latest | ||
| ``` | ||
|
|
||
| ### Run the Simulation | ||
|
|
||
| In the container, run the simulation with `--livestream 2` to stream the simulation to the local machine. For example, to run the `reach_psm_sm.py` script, run the following command: | ||
|
|
||
| ```bash | ||
| python simulation/scripts/environments/state_machine/reach_psm_sm.py --livestream 2 | ||
| ``` | ||
|
|
||
| Please refer to the [simulation README](../scripts/simulation/README.md) for other examples. | ||
|
|
||
|
|
||
| ### Open the WebRTC Client | ||
|
|
||
| Wait for the simulation to start (you should see the message "Resetting the state machine" when the simulation is ready), and open the WebRTC client to view the simulation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.