How to run franka_description visualize_franka.sh with ROS2 Jazzy

At the time of writing this (2025-01-12), the visualize_franka.sh script from the franka_description, version 0.4.0, the script is based on a Docker image and ros2 Humble.

Since I’m using Jazzy and want to avoid any incompatibilities, here’s how to update the script to Jazzy.

You can directly clone my fork of the repository:

git clone -b jazzy https://github.com/ulikoehler/franka_description.git

Now you can run the script as usual:

cd franka_description
./scripts/visualize_franka.sh arm_id:=fr3

The changes are based on the fact the in the humble Docker image UID 1000 was unused whereas in Jazzy it is used by the ubuntu user. Therefore, if the executing user’s UID is 1000, the script needs to re-use the existing UID & GID since trying to create a user/group with the same UID/GID is doomed to fail. For details on the method how this has been fixed, see Shell logic: How to create user/group if no user/group with that UID/GID exists

If you want to modify it yourself, the only change you need to make is to change .docker/Dockerfile:

FROM osrf/ros:jazzy-desktop

ARG DEBIAN_FRONTEND=noninteractive

ARG USER_UID=1001
ARG USER_GID=1001
ARG USERNAME=user

WORKDIR /workspaces

# Create user/group only of no such user/group exists
RUN (getent group $USER_GID || groupadd --gid $USER_GID $USERNAME) \
    && (getent passwd $USER_UID || useradd --uid $USER_UID --gid $USER_GID -m $USERNAME) \
    && mkdir -p -m 0700 /run/user/"${USER_UID}" \
    && mkdir -p -m 0700 /run/user/"${USER_UID}"/gdm \
    && chown $USER_UID:$USER_GID /run/user/"${USER_UID}" \
    && chown $USER_UID:$USER_GID /workspaces \
    && chown $USER_UID:$USER_GID /run/user/"${USER_UID}"/gdm 

RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
    ros-jazzy-xacro \
    ros-jazzy-joint-state-publisher-gui \
    && rm -rf /var/lib/apt/lists/*

ENV XDG_RUNTIME_DIR=/run/user/"${USER_UID}"

# Specify user by UID & GID so this script doesn't
# depend on the exact username
USER $USER_UID:$USER_GID

RUN echo "source /ros_entrypoint.sh" >>~/.bashrc
ARG MAX_ROS_DOMAIN_ID=232
RUN echo "export ROS_DOMAIN_ID=100" >>~/.bashrc
RUN echo "set +e" >>~/.bashrc