This guide will walk you through installing the sara_shield library in a separate directory and then setting up and building your ROS 2 (Jazzy) workspace for the safety_demo package.
The sara_shield library must be built and installed into /opt/safety_shield (or a directory of your choosing) outside of your ROS workspace.
Choose your setup method: You can either build natively on your machine or use the provided Docker scripts. Both paths are described below.
-
Open a terminal.
-
Clone the repository into a separate location:
git clone --recurse-submodules git@github.com:JulianBalletshofer/sara-shield-pacs.git
cd sara_shield- Build and install the safety shield:
cd ../ && mkdir build && cd build
export EIGEN3_INCLUDE_DIR="/usr/include/eigen3/eigen-3.4.0"
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/safety_shield -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
sudo make installNote: You can change
/opt/safety_shieldto any other prefix, but you must exportCMAKE_PREFIX_PATHaccordingly in Step 3 of the ROS workspace setup.
The repository ships with Docker scripts that provide a fully configured ROS 2 Humble environment with sara_shield pre-built into a persistent volume. This is the recommended path if you want an isolated, reproducible setup.
Prerequisites: Docker Engine installed and running.
- Install Docker dependencies (run once on a fresh machine):
./docker/install- Build
sara_shieldinto a persistent Docker volume:
./docker/build_safety_shieldThis compiles sara_shield and caches the result in two named Docker volumes:
safety_demo_safety_shield_install— the install prefix (equivalent to/opt/safety_shield)
These volumes persist across container restarts, so sara_shield does not need to be recompiled on every run.
- Build the ROS 2 workspace:
./docker/run -w /workspace/ros2_ws colcon build./docker/run executes commands inside the container directly. The repository is mounted at /workspace. The container runs as the non-root user sara with ROS_DOMAIN_ID=37 pre-configured for ROS networking.
If you need to rebuild sara_shield from scratch, remove the cached volumes first:
docker volume rm safety_demo_safety_shield_installThen rebuild:
safety_demo_safety_shield_install— the install prefix (equivalent to/opt/safety_shield)
./docker/build_safety_shield
./docker/run -w /workspace/ros2_ws colcon buildNote: When using Docker, the
sara_shieldinstall prefix is handled automatically via the persistent volume. TheCMAKE_PREFIX_PATHis pre-set inside the container, so no manual export is needed for the ROS workspace build.
Next, create a new ROS 2 workspace and clone in your safety_demo package.
-
Source your ROS 2 Jazzy installation (add to your
.bashrcif needed):source /opt/ros/jazzy/setup.bash -
Clone your
safety_demopackage:git clone -b safety_shield_PACS git@gitlab.lrz.de:jballetshofer/safety_demo.git cd safety_demo -
add prefix to the installed lib
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH #only in case robostack is used export LD_LIBRARY_PATH=/opt/safety_shield/lib:$LD_LIBRARY_PATH export CMAKE_PREFIX_PATH=/opt/safety_shield:$CMAKE_PREFIX_PATH
-
Install ROS dependencies:
rosdep update rosdep install --from-paths src --ignore-src -r -y
-
Build the workspace with Colcon:
colcon build
-
Source your overlay before running:
source install/setup.bash
ros2 launch safety_shield_node combined.launch.py robot_name:=<robot_name> sync_robot_position:=<bool> use_ik:=<bool> -
robot_name
Choose the robot model (e.g.,panda,schunk,ur3,robco). -
sync_robot_position (bool)
- If
true, the robot initializes its position from the current joint states received on the/joint_statestopic. - If
false, the robot initializes with the init_q values specified in thesafety_shield_paramsconfiguration file.
- If
ros2 run human_motion_tracker human_motion_trackerros2 run simple_goal_publisher simple_goal_publisherros2 topic pub /goal_joint_states sensor_msgs/msg/JointState "{
header: { stamp: { sec: 0, nanosec: 0 }, frame_id: '' },
name: [ 'joint1', 'joint2', 'joint3', 'joint4', 'joint5', 'joint6' ],
position: [ 0.5, -0.2, 0.1, 1.0, -0.5, 0.3 ]
}" --once