README.md

June 19, 2026 ยท View on GitHub

Scripts Package

This folder contains the Python package used to control and evaluate the simulation.

Installation

Install the package in editable mode so it is importable from other locations.

Optional: create and activate a virtual environment.

cd ~
python3 -m venv venv_src --system-site-packages
source ~/venv_src/bin/activate

Note: Activate the virtual environment in each terminal that needs these scripts. You can also add the source command to your .bashrc if you want it loaded automatically.

Then install the package:

cd ~/surgical_robotics_challenge/scripts
python3 -m pip install -e .

Control Options

After launching one of the environments as described in the main README, you can control the simulated PSMs/ECM and read scene state in two ways:

  1. CRTK method API (import-based) Import and use psm_arm.py, ecm_arm.py, and scene.py directly in your application.

  2. CRTK-ROS interface Run launch_crtk_interface.py to expose CRTK-compatible ROS topics backed by the same wrappers.

The examples folder demonstrates both approaches.

Control via Meta Quest

After launching the simulation:

  1. Enable the CRTK interface:
cd ~/surgical_robotics_challenge/scripts/surgical_robotics_challenge
python3 launch_crtk_interface.py --scene False

The scene argument is relevant for suturing environments with entry/exit holes. Set it to False for other environments, including the pegboard challenge.

  1. Open the teleoperation directory:
cd ~/surgical_robotics_challenge/scripts/surgical_robotics_challenge/teleoperation
  1. Run the UDP bridge:
python3 udp_crtk_bridge.py --quest-ip <ip-address> --offset-rpy 180 0 180 --swap --home

Replace <ip-address> with the master device IP (for example, Quest 3).

This bridge converts CRTK-compatible UDP JSON commands to CRTK-compatible ROS 2 topics used by AMBF.

1. Wrappers for Simulation Components

#Script NameDescription
1psm_arm.pyWraps simulated PSMs through ROS topics.
2ecm_arm.pyWraps the simulated ECM through ROS topics.
3scene.pyWraps the simulated needle, entry, and exit holes through ROS topics.
4launch_crtk_interface.pyPublishes CRTK-compatible ROS topics for PSMs, ECM, and scene objects.
5camera.pyProvides access to the kinematic frame used as parent for the simulated ECM (currently not used).

2. Kinematics

#Script NameDescription
1psmKinematics.pyPSM forward/inverse kinematics implementation.
2ecmFK.pyECM forward kinematics implementation.
3DH.pyDH convention helper implementation.

3. Examples

#Script NameDescription
1gui_based_control.pyGUI sliders for Cartesian control of PSMs.
2depth_sub.pyExample ROS subscriber for camera depth messages.
3image_sub.pyExample ROS subscriber for camera image messages.
4crtk_ros_based_control.pyPSM control via the CRTK-ROS interface.
5ecm_control.pyECM control via the CRTK method API.
6ik_test.pyRandom-trajectory test for PSM kinematics.
7interface_via_method_api.pyMinimal method-API control example.
8interface_via_crtk_ros_api.pyMinimal CRTK-ROS API control example.

4. Teleoperation

#Script NameDescription
1mtm_multi_psm_control.pyBinds one MTM to multiple PSMs; switch active arm by double-tapping clutch pedal.
2geomagic_multi_psm_control.pyBinds one Geomagic to multiple PSMs; switch active arm by double-tapping the device button.
3hydra_multi_psm_control.pyBinds one Razer Hydra to multiple PSMs.

4a. Input Devices (teleoperation/input_devices)

#Script NameDescription
1mtm_device_crtk.pyWraps MTM using CRTK-based ROS topics (for sawIntuitiveResearchKit >= 2.0).
2geomagic_device.pyWraps Geomagic using ROS topics.
3hydra_device.pyWraps Razer Hydra using ROS topics.

5. Utils

Helper scripts used across this package.

#Script NameDescription
1utils/approx_sync_data.pyExample for collecting ROS messages with an approximate time synchronizer.