Skip to content

Commit 337d8f3

Browse files
mocsharpSachidanandAllemingxin-zheng
authored
Update Instructions for Telesurgery Workflow (#167)
### Description - Offer Dockerized environments for running Telesurgery apps in both simulated and real-world settings, complete with step-by-step guides for each. --------- Signed-off-by: Victor Chang <[email protected]> Signed-off-by: Sachidanand Alle <[email protected]> Co-authored-by: Sachidanand Alle <[email protected]> Co-authored-by: Mingxin Zheng <[email protected]>
1 parent a5542d6 commit 337d8f3

File tree

42 files changed

+1267
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1267
-263
lines changed

.github/markdown-link-check.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
},
1010
{
1111
"pattern": "^#%EF%B8%8F.*"
12+
},
13+
{
14+
"pattern": "https://developer.nvidia.com/cuda-downloads"
1215
}
1316
],
1417
"timeout": "20s",

workflows/robotic_surgery/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
- 16GB RAM minimum
2424

2525
### Software Requirements
26-
- NVIDIA Driver Version >= 555
26+
- [NVIDIA Driver Version >= 555](https://www.nvidia.com/en-us/drivers/)
2727
- Python 3.10
2828

2929
## Quick Start

workflows/robotic_ultrasound/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
- 50GB of disk space
2222

2323
### Software Requirements
24-
- NVIDIA Driver Version >= 555
25-
- CUDA Version >= 12.6
24+
- [NVIDIA Driver Version >= 555](https://www.nvidia.com/en-us/drivers/)
25+
- [CUDA Version >= 12.6]((https://developer.nvidia.com/cuda-downloads))
2626
- Python 3.10
27-
- RTI DDS License
27+
- [RTI DDS License](https://www.rti.com/free-trial)
2828

2929
## Quick Start
3030

workflows/telesurgery/README.md

Lines changed: 180 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -2,161 +2,193 @@
22

33
![Telesurgery Workflow](../../docs/source/telesurgery_workflow.jpg)
44

5-
## Table of Contents
6-
- [System Requirements](#system-requirements)
7-
- [Quick Start](#quick-start)
8-
- [Running the Workflow](#running-the-workflow)
9-
- [Licensing](#licensing)
105

11-
## System Requirements
6+
- [Telesurgery Workflow](#telesurgery-workflow)
7+
- [Prerequisites](#prerequisites)
8+
- [System Requirements](#system-requirements)
9+
- [Common Setup](#common-setup)
10+
- [Running the System](#running-the-system)
11+
- [Real World Environment](#real-world-environment)
12+
- [Simulation Environment](#simulation-environment)
13+
- [Advanced Configuration](#advanced-configuration)
14+
- [NTP Server Setup](#ntp-server-setup)
15+
- [NVIDIA Video Codec Configuration](#advanced-nvidia-video-codec-configuration)
16+
- [Troubleshooting](#troubleshooting)
17+
- [Common Issues](#common-issues)
18+
- [Licensing](#licensing)
1219

13-
### Hardware Requirements
14-
- Ubuntu 22.04
15-
- NVIDIA GPU with compute capability 8.6 and 32GB of memory
16-
- GPUs without RT Cores, such as A100 and H100, are not supported
17-
- 50GB of disk space
1820

19-
### Software Requirements
20-
- NVIDIA Driver Version >= 555
21-
- CUDA Version >= 12.6
22-
- Python 3.10
23-
- RTI DDS License
21+
## Prerequisites
2422

25-
## Quick Start
23+
### System Requirements
2624

27-
### x86 & AARCH64 (IGX) Setup
25+
#### Hardware Requirements
26+
- Ubuntu >= 22.04
27+
- NVIDIA GPU with compute capability 8.6 and 8GB of memory
28+
- GPUs without RT Cores, such as A100 and H100, are not supported
29+
- 50GB of disk space
30+
- XBOX Controller or Haply Inverse 3.
2831

29-
1. **Set up a Docker environment with CUDA enabled (IGX only):**
30-
```bash
31-
cd <path-to-i4h-workflows>
32-
xhost +
33-
workflows/telesurgery/docker/setup.sh run
3432

35-
# Inside Docker
36-
workflows/telesurgery/docker/setup.sh init
37-
```
33+
#### Software Requirements
34+
- [NVIDIA Driver Version >= 570](https://developer.nvidia.com/cuda-downloads)
35+
- [CUDA Version >= 12.8](https://developer.nvidia.com/cuda-downloads)
36+
- Python 3.10
37+
- [RTI DDS License](https://www.rti.com/free-trial)
38+
- [Docker](https://docs.docker.com/engine/install/) 28.0.4+
39+
- [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) 1.17.5+
3840

39-
2. **Set up the x86 environment with CUDA enabled:**
40-
```bash
41-
cd <path-to-i4h-workflows>
42-
xhost +
43-
workflows/telesurgery/docker/setup.sh init
44-
```
41+
### Common Setup
4542

46-
3. **Create and activate a [conda](https://www.anaconda.com/docs/getting-started/miniconda/install#quickstart-install-instructions) environment:**
47-
```bash
48-
source ~/miniconda3/bin/activate
49-
conda create -n telesurgery python=3.10 -y
50-
conda activate telesurgery
51-
```
43+
#### 1. RTI DDS License Setup
44+
```bash
45+
export RTI_LICENSE_FILE=<full-path-to-rti-license-file>
46+
# for example
47+
export RTI_LICENSE_FILE=/home/username/rti/rti_license.dat
48+
```
5249

53-
4. **Run the setup script:**
54-
```bash
55-
cd <path-to-i4h-workflows>
56-
bash tools/env_setup_telesurgery.sh
57-
```
50+
> [!Note]
51+
> RTI DDS is the common communication package for all scripts. Please refer to [DDS website](https://www.rti.com/products) for registration. You will need to obtain a license file and set the `RTI_LICENSE_FILE` environment variable to its path.
5852
59-
> Make sure your public key is added to the github account if the git authentication fails.
53+
#### 2. Environment Configuration
54+
When running the Patient and the Surgeon applications on separate systems, export the following environment variables:
6055

61-
### Obtain RTI DDS License
56+
```bash
57+
export PATIENT_IP="<IP Address of the system running the Patient application>"
58+
export SURGEON_IP="<IP Address of the system running the Surgeon application>"
6259

63-
RTI DDS is the communication package used by all scripts. Please refer to the [DDS website](https://www.rti.com/products) for registration. You will need to obtain a license file and set the `RTI_LICENSE_FILE` environment variable to its path.
60+
# Export the following for NTP Server (Optional)
61+
export NTP_SERVER_HOST="<IP Address of the NTP Server>"
62+
export NTP_SERVER_PORT="123"
63+
```
6464

65-
### NTP Server (Optional)
65+
> [!Note]
66+
> For NTP settings and variables, refer to the [NTP (Network Time Protocol) Server](#ntp-server-setup) section for additional details.
6667
67-
An NTP (Network Time Protocol) server provides accurate time information to clients over a computer network. NTP is designed to synchronize the clocks of computers to a reference time source, ensuring all devices on the network maintain the same time.
68+
## Running the System
69+
70+
### Real World Environment
6871

72+
#### 1. Build Environment
6973
```bash
70-
# Run your own NTP server in the background
71-
docker run -d --name ntp-server --restart=always -p 123:123/udp cturra/ntp
74+
cd <path-to-i4h-workflows>
75+
workflows/telesurgery/docker/real.sh build
76+
```
7277

73-
# Check if it's running
74-
docker logs ntp-server
78+
#### 2. Running Applications
7579

76-
# fix server ip in env.sh for NTP Server
77-
export NTP_SERVER_HOST=<NTP server address>
80+
##### Patient Application
81+
```bash
82+
# Start the Docker Container
83+
workflows/telesurgery/docker/real.sh run
7884

79-
# To stop the server
80-
# docker stop ntp-server && docker rm ntp-server
81-
```
85+
# Using RealSense Camera with NVIDIA H.264 Encoder
86+
python patient/physical/camera.py --camera realsense --name room --width 1280 --height 720
8287

83-
### Environment Variables
88+
# Using CV2 Camera with NVIDIA H.264 Encoder
89+
python patient/physical/camera.py --camera cv2 --name robot --width 1920 --height 1080
8490

85-
Before running any scripts, set up the following environment variables:
91+
# Using RealSense Camera with NVJPEG Encoder
92+
python patient/physical/camera.py --camera realsense --name room --width 1280 --height 720 --encoder nvjpeg
8693

87-
1. **PYTHONPATH**: Set this to point to the **scripts** directory:
88-
```bash
89-
export PYTHONPATH=<path-to-i4h-workflows>/workflows/telesurgery/scripts
90-
```
91-
This ensures Python can find the modules under the [`scripts`](./scripts) directory.
94+
# Using CV2 Camera with NVJPEG Encoder
95+
python patient/physical/camera.py --camera cv2 --name robot --width 1920 --height 1080 --encoder nvjpeg
96+
```
9297

93-
2. **RTI_LICENSE_FILE**: Set this to point to your RTI DDS license file:
94-
```bash
95-
export RTI_LICENSE_FILE=<path-to-rti-license-file>
96-
```
97-
This is required for the DDS communication package to function properly.
98+
##### Surgeon Application
99+
```bash
100+
# Start the Docker Container
101+
workflows/telesurgery/docker/real.sh run
98102

99-
3. **NDDS_DISCOVERY_PEERS**: Set this to the IP address receiving camera data:
100-
```bash
101-
export NDDS_DISCOVERY_PEERS="surgeon IP address"
102-
```
103-
More recommended variables can be found in [env.sh](./scripts/env.sh).
103+
# Start the Surgeon Application with NVIDIA H.264 Decoder
104+
python surgeon/camera.py --name [robot|room] --width 1280 --height 720 2> /dev/null
104105

105-
## Running the Workflow
106+
# Run the Surgeon Application with NVJPEG Decoder
107+
python surgeon/camera.py --name [robot|room] --width 1280 --height 720 --decoder nvjpeg
108+
```
106109

110+
##### Gamepad Controller Application
107111
```bash
108-
cd <path-to-i4h-workflows>/workflows/telesurgery/scripts
109-
source env.sh # Make sure all env variables are correctly set in env.sh
112+
# Start the Docker Container
113+
workflows/telesurgery/docker/real.sh run
110114

111-
export PATIENT_IP=<patient IP address>
112-
export SURGEON_IP=<surgeon IP address>
115+
# Run the Gamepad Controller Application
116+
python surgeon/gamepad.py --api_host ${PATIENT_IP} --api_port 8081
113117
```
114-
> Make sure the MIRA API Server is up and running (port: 8081) in the case of a physical world setup.
115118

116-
### [Option 1] Patient in Physical World _(x86 / aarch64)_
117-
118-
When running on IGX (aarch64), ensure you are in the Docker environment set up previously.
119+
### Simulation Environment
119120

121+
#### 1. Build Environment
120122
```bash
121-
# Stream camera output
122-
python patient/physical/camera.py --camera realsense --name room --width 1280 --height 720
123-
python patient/physical/camera.py --camera cv2 --name robot --width 1920 --height 1080
123+
cd <path-to-i4h-workflows>
124+
workflows/telesurgery/docker/sim.sh build
124125
```
125126

126-
### [Option 2] Patient in Simulation World _(x86)_
127+
#### 2. Running Applications
127128

129+
##### Patient Application
128130
```bash
129-
# Download the assets
130-
i4h-asset-retrieve
131+
# Start the Docker Container
132+
workflows/telesurgery/docker/sim.sh run
131133

132-
python patient/simulation/main.py [--encoder nvc]
134+
# Start the Patient Application with NVIDIA H.264 Encoder
135+
python patient/simulation/main.py
136+
137+
# Start the Patient Application with NVJPEG Encoder
138+
python patient/simulation/main.py --encoder nvjpeg
133139
```
134140

135-
### Surgeon Connecting to Patient _(x86 / aarch64)_
141+
##### Surgeon Application
142+
```bash
143+
# Start the Docker Container
144+
workflows/telesurgery/docker/sim.sh run
136145

137-
# capture robot camera stream
138-
NDDS_DISCOVERY_PEERS=${PATIENT_IP} python surgeon/camera.py --name robot --width 1280 --height 720 [--decoder nvc]
146+
# Start the Surgeon Application with NVIDIA H.264 Decoder
147+
python surgeon/camera.py --name robot --width 1280 --height 720 2> /dev/null
139148

140-
# capture room camera stream (optional)
141-
NDDS_DISCOVERY_PEERS=${PATIENT_IP} python surgeon/camera.py --name room --width 1280 --height 720 [--decoder nvc]
149+
# Run the Surgeon Application with NVJPEG Decoder
150+
python surgeon/camera.py --name robot --width 1280 --height 720 --decoder nvjpeg
151+
```
152+
153+
##### Gamepad Controller Application
154+
```bash
155+
# Start the Docker Container
156+
workflows/telesurgery/docker/sim.sh run
142157

143-
# Connect to gamepad controller and send commands to API Server
158+
# Run the Gamepad Controller Application
144159
python surgeon/gamepad.py --api_host ${PATIENT_IP} --api_port 8081
145160
```
146161

147-
### Using H.264/HEVC Encoder/Decoder from NVIDIA Video Codec
162+
## Advanced Configuration
163+
164+
### NTP Server Setup
165+
An NTP (Network Time Protocol) server provides accurate time information to clients over a computer network. NTP is designed to synchronize the clocks of computers to a reference time source, ensuring all devices on the network maintain the same time.
166+
167+
```bash
168+
# Run your own NTP server in the background
169+
docker run -d --name ntp-server --restart=always -p 123:123/udp cturra/ntp
148170

149-
Camera data can be streamed using either the H.264 or HEVC (H.265) codecs. To enable this for the Patient and Surgeon applications, use the `--encoder nvc` or `--decoder nvc` argument, respectively.
171+
# Check if it's running
172+
docker logs ntp-server
150173

151-
Encoding parameters can be customized in the Patient application using the `--encoder_params` argument, as shown below:
174+
# fix server ip in env.sh for NTP Server
175+
export NTP_SERVER_HOST=<NTP server address>
176+
177+
# To stop the server
178+
docker stop ntp-server && docker rm ntp-server
179+
```
180+
181+
### Advanced NVIDIA Video Codec Configuration
182+
183+
The applications streams H.264 by default using NVIDIA Video Codec. Additional encoding parameters can be customized in the Patient application using the `--encoder_params` argument:
152184

153185
```bash
154186
python patient/simulation/main.py --encoder nvc --encoder_params patient/nvc_encoder_params.json
155187
```
156188

157-
#### Sample Encoding Parameters for the NVIDIA Video Codec
189+
#### Sample Encoding Parameters
158190

159-
Heres an example of encoding parameters in JSON format:
191+
Here's an example of encoding parameters in JSON format:
160192

161193
```json
162194
{
@@ -169,16 +201,55 @@ Here’s an example of encoding parameters in JSON format:
169201
}
170202
```
171203

172-
> [!NOTE]
173-
> H.264 or HEVC (H.265) codecs are available on x86 platform only.
204+
### Advanced NVJPEG Configuration
205+
206+
Adjust the quality of encoded frames using the NVJPEG encoder by editing the [nvjpeg_encoder_params.json](./scripts/patient/nvjpeg_encoder_params.json) file. Simply change the quality parameter to a value between 1 and 100:
174207

175-
### Important Notes
176-
1. You may need to run multiple scripts simultaneously in different terminals or run in background (in case of docker)
177-
2. A typical setup requires multiple terminals running:
178-
- Patient: Camera1, Camera2, Controller, etc.
179-
- Surgeon: Camera1, Camera2, Controller, etc.
208+
```json
209+
{
210+
"quality": 90
211+
}
212+
```
180213

181-
If you encounter issues not covered in the notes above, please check the documentation for each component or open a new issue on GitHub.
214+
## Troubleshooting
215+
216+
### Common Issues
217+
218+
#### Docker Build Error
219+
Q: I get the following error when building the Docker image:
220+
```bash
221+
ERROR: invalid empty ssh agent socket: make sure SSH_AUTH_SOCK is set
222+
```
223+
224+
A: Start the ssh-agent
225+
```bash
226+
eval "$(ssh-agent -s)" && ssh-add
227+
```
228+
#### Unable to launch the applications when using NVIDIA Video Codec
229+
230+
Q: I'm getting an error when I start the application with the NVIDIA Video Codec.
231+
232+
```BASH
233+
[error] [nv_video_encoder.cpp:101] Failed to create encoder: LoadNvEncApi : Current Driver Version does not support this NvEncodeAPI version, please upgrade driver at /workspace/holohub/build/nvidia_video_codec/_deps/nvc_sdk/NvEncoder/NvEncoder.cpp:82
234+
```
235+
236+
**A:** NVIDIA Video Codec requires CUDA version 12 (driver version 570.0) or later. Check out the [NVIDIA Video Codec System Requirements](https://developer.nvidia.com/nvidia-video-codec-sdk/download) section for more details. **
237+
238+
239+
#### Update CUDA Driver on IGX
240+
```bash
241+
# ssh to igx-host to run the following commands
242+
sudo systemctl isolate multi-user
243+
244+
sudo apt purge nvidia-kernel-*
245+
sudo add-apt-repository ppa:graphics-drivers/ppa
246+
sudo apt update
247+
248+
sudo apt-get -y install linux-headers-nvidia-tegra aptitude
249+
sudo aptitude install nvidia-driver-570-open # Resolve any conflicts
250+
251+
# hard reboot igx (soft reboot may not work)
252+
```
182253

183254
## Licensing
184255

0 commit comments

Comments
 (0)