Back to Tutorial Home

Part 2: Intro to SlicerROS2

For this portion of the workshop we walk through examples from the SlicerROS2 read the docs. Available here: https://slicer-ros2.readthedocs.io/en/latest/index.html

We package standard ROS2 communication mechanisms as MRML nodes in 3D Slicer (https://slicer.readthedocs.io/en/latest/developer_guide/mrml_overview.html).

image

To get started with SlicerROS2, we’ll be using a simulated patient side manipulator (PSM) for the dVRK.

  1. Start by building the dVRK robot package in ROS2: https://github.com/jhu-dvrk/sawIntuitiveResearchKit/wiki/BuildROS2

  2. Once that’s built, launch the virtual PSM:

source ~/ros2_ws/install/setup.bash
cd ~/ros2_ws/src/dvrk/dvrk_config_jhu/jhu-dVRK-Si-demo
ros2 run dvrk_robot dvrk_console_json -j console-PSM3_SIMULATED.json
  1. Select “Power on” and press “Home” image

  2. In a seperate terminal, launch the robot_state_pubslisher (this is how we tell Slicer where the links are)

source ~/ros2_ws/install/setup.bash
ros2 launch dvrk_model dvrk_state_publisher.launch.py arm:=PSM3
  1. Finally, in a third terminal, navigate to your inner build folder (usually in Slicer-SuperBuild-xxx/Slicer-build/)
source ~/ros2_ws/install/setup.bash 
source ~/opt/ros/galactic/setup.bash
./Slicer
  1. Now you can visualize the robot by switching to the ROS2 module and entering “PSM3/robot_state_publisher” in the second selector: image

Note: you will need to zoom out to see the robot!

  1. Get your robot to do a little dance by running in a seperate terminal
ros2 run dvrk_python dvrk_arm_test.py -a PSM3

image