Skip to content

Commit

Permalink
Complete jazzy integration
Browse files Browse the repository at this point in the history
Also changes towards more robust and easy integration of future distributions
  • Loading branch information
gstavrinos committed Nov 1, 2024
1 parent 79f5848 commit 397bd90
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 15 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ TODO
- Introduced a the `kill-container` or `kc` flag to forcefully kill the `rosez*` container.
- Now sharing `/media` between host and container.
- Fixed a bug that occured when the output of the build command was too long.
- [For versions >= `v2.4.0`] Added support for ROS2 Jazzy. **NOTE**: The `ros2ez` command has now been disabled, since currently two ROS2 LTS versions are supported. ROS2 Humble can now been used with the `ros2ezh` command, following the typical `rosez*`/`ros2ez*` scheme. **WARNING**: This versions breaks humble installations. In order to migrate, your best bet is to rename `ros2ez-volume*` volumes to their equivalent `ros2ezh-volume*`.
1 change: 1 addition & 0 deletions includes/ros2j_ws.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/home/$USER/ros2_ws/
8 changes: 5 additions & 3 deletions internal/entrypoint.bash
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trap 'signal_handler' $signal_list
if [ "$rosversion" != "unknown" ]; then
# sudo touch $lockation/$lock_file
. /opt/ros/$rosversion/setup.bash
if [ "$rosversion" == "humble" ] || [ "$rosversion" == "foxy" ]; then
if [ "$rosversion" == "humble" ] || [ "$rosversion" == "foxy" ] || [ "$rosversion" == "jazzy" ]; then
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
fi
while read -r line; do
Expand All @@ -40,7 +40,7 @@ if [ "$rosversion" != "unknown" ]; then
script --flush --quiet --return /tmp/rosez-build-output.txt --command "rosdep install -ir --from-path src --rosdistro $rosversion -y" | tee /dev/fd/2
intermediate_error_handler $?
fi
if [ "$rosversion" == "humble" ] || [ "$rosversion" == "foxy" ]; then
if [ "$rosversion" == "humble" ] || [ "$rosversion" == "foxy" ] || [ "$rosversion" == "jazzy" ]; then
if [ $skip_compilation -ne 1 ]; then
script --flush --quiet --return /tmp/rosez-build-output.txt --command "colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo" | tee /dev/fd/2
intermediate_error_handler $?
Expand All @@ -59,7 +59,9 @@ if [ "$rosversion" != "unknown" ]; then
if [ "$rosversion" == "melodic" ]; then
. /usr/share/gazebo/setup.sh
else
. /usr/share/gazebo/setup.bash
if [ "$rosversion" != "jazzy" ]; then
. /usr/share/gazebo/setup.bash
fi
fi
intermediate_error_handler $?
echo -e "${colour_green}Unlocking my lock file ($lock_file) for other processes...$colour_end"
Expand Down
3 changes: 3 additions & 0 deletions internal/ros2-ezj/ros2ezj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
$SCRIPT_DIR/../rosez_exec.bash "5" $*
76 changes: 76 additions & 0 deletions internal/ros2_jazzy_Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
FROM nvidia/opengl:1.2-glvnd-devel-ubuntu24.04 AS nvidia

FROM osrf/ros:jazzy-desktop-full

COPY --from=nvidia /usr/local /usr/local

ENV NVIDIA_VISIBLE_DEVICES=all NVIDIA_DRIVER_CAPABILITIES=all

FROM osrf/ros:jazzy-desktop-full

LABEL maintainer="George Stavrinos <[email protected]>"

RUN mkdir -p /opt/ros/ros2_ws/src && apt-get update && apt-get full-upgrade -y && DEBIAN_FRONTEND=noninteractive apt-get install -y \
git \
gdb \
vim \
xterm \
libgl1 \
valgrind \
pre-commit \
pulseaudio \
mesa-utils \
libuvc-dev \
clang-tidy \
catkin-lint \
python3-pip \
libglx-mesa0 \
openssh-client \
clang-format-14 \
clang-format-18 \
ros-jazzy-ros-gz \
python3-catkin-pkg \
ros-jazzy-navigation2 \
ros-jazzy-nav2-bringup \
ros-jazzy-ros2-control \
ros-jazzy-slam-toolbox \
ros-jazzy-ros2controlcli \
ros-jazzy-gz-ros2-control \
ros-jazzy-control-toolbox \
ros-jazzy-gz-utils-vendor \
ros-jazzy-gz-plugin-vendor \
ros-jazzy-ros2-controllers \
ros-jazzy-gz-physics-vendor \
ros-jazzy-rmw-cyclonedds-cpp \
ros-jazzy-controller-manager \
ros-jazzy-effort-controllers \
ros-jazzy-robot-localization \
ros-jazzy-velocity-controllers \
ros-jazzy-position-controllers \
ros-jazzy-joint-state-publisher \
ros-jazzy-transmission-interface \
ros-jazzy-joint-state-publisher-gui

ARG USER_ID=16661
ARG GROUP_ID=16661

RUN getent group $GROUP_ID | cut -d: -f1 | xargs -r groupdel >/dev/null 2>&1 && getent passwd $USER_ID | cut -d: -f1 | xargs -r userdel -r >/dev/null 2>&1 && addgroup --gid $GROUP_ID rosez_user && useradd --create-home --password '' --comment '' --uid $USER_ID --gid $GROUP_ID rosez_user && usermod -aG sudo rosez_user && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && touch /home/rosez_user/.sudo_as_admin_successful

USER rosez_user
RUN sudo chown -R rosez_user:rosez_user /home/rosez_user && rosdep update && pip3 install bloom --break-system-packages

VOLUME /opt/ros/jazzy\
/bin\
/etc\
/home\
/lib\
/lib64\
/mnt\
/opt\
/root\
/run\
/sbin\
/srv\
/sys\
/usr\
/var
22 changes: 10 additions & 12 deletions internal/rosez_exec.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ clear_locks=0
skip_compilation=0
non_interactive=0
no_sound=0
# lockdir=""
kill_container=0
userid=$(id -u)
rosws_file=${workspaces[$($1-1)]}
rosez_vol="${volumes[$($1-1)]}"
ros="${distros[$($1-1)]}"
ros_image="${image_names[$($1-1)]}"
rosws_file=${workspaces[$(($1 - 1))]}
rosez_vol=${volumes[$(($1 - 1))]}
ros=${distros[$(($1 - 1))]}
ros_image=${image_names[$(($1 - 1))]}
shift
trap 'signal_handler' $signal_list
rosez_volumes=""
Expand Down Expand Up @@ -70,10 +70,8 @@ done
if [ -z "$gpu_param" ]; then
if grep -q "nvidia" <<<"$gpu_string" || grep -q "Nvidia" <<<"$gpu_string" || grep -q "NVIDIA" <<<"$gpu_string"; then
gpu_param="--gpus all"
elif grep -q "intel" <<<"$gpu_string" || grep -q "Intel" <<<"$gpu_string" || grep -q "INTEL" <<<"$gpu_string"; then
gpu_param="--device /dev/dri/card0"
else
echo "No Nvidia or Intel GPU found. This case has not been investigated yet. GUI integration might be broken. (Good luck!)"
gpu_param="--device /dev/dri/card0"
fi
fi
if [ $clear_locks -gt 0 ]; then
Expand All @@ -84,7 +82,6 @@ if [ $kill_container -gt 0 ]; then
echo -e "${colour_orange}I was passed the kill-container flag. Killing (and deleting) my container ($ros_image)...$colour_end"
docker rm -f $ros_image >/dev/null 2>&1
fi
echo $gpu_param
touch $lockation/$read_lock_file
locked=1
while [ $locked -gt 0 ]; do
Expand All @@ -95,7 +92,6 @@ while [ $locked -gt 0 ]; do
# ---
# A new lock_file is created, since the other rosez
# process will instantly get priority with the cl flag.
echo $found_lock
if [[ -z "$found_lock" ]]; then
now="$(date +'%Y-%m-%d_%H_%M_%S_%N')"
read_lock_file="$read_lock_prefix$now$read_lock_suffix"
Expand Down Expand Up @@ -141,20 +137,22 @@ touch $xauthf
intermediate_error_handler $?
/bin/bash -c "xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $xauthf nmerge -"
intermediate_error_handler $?
x="docker run --ulimit nofile=1024:524288 --rm $it -u $userid --ipc=host --privileged --network host $gpu_param $sound --group-add dialout --group-add video --group-add audio -v $rosez_vol-bin:/bin -v $rosez_vol-etc:/etc/ -v $rosez_vol-home:/home/ -v $rosez_vol-lib:/lib/ -v $rosez_vol-lib64:/lib64/ -v /media:/media -v /mnt:/mnt -v $rosez_vol-opt:/opt/ -v $rosez_vol-root:/root/ -v /run:/run -v $rosez_vol-sbin:/sbin/ -v $rosez_vol-srv:/srv/ -v $rosez_vol-usr:/usr -v $rosez_vol-var:/var -v $rosez_vol:/opt/ros/$ros -v $SCRIPT_DIR/../includes/$rosws_file:/opt/ros/$rosws_file $volumes -v $SCRIPT_DIR/entrypoint.bash:/home/rosez_user/.bashrc -v /sys:/sys -v /proc:/proc -v /dev:/dev -v $bloom_file:/home/rosez_user/.config/bloom -v $gitconfig_file:/home/rosez_user/.gitconfig -v $ssh_folder:/home/rosez_user/.ssh -v $SCRIPT_DIR/supported_versions.txt:/home/rosez_user/supported_versions.txt -v $SCRIPT_DIR/helpers.bash:/home/rosez_user/helpers.bash -v /:$HOME/.$rosez_vol -e DISPLAY -e TERM -e QT_X11_NO_MITSHM=1 -e XAUTHORITY=$xauthf -v $xauthf:$xauthf -v /tmp/.X11-unix:/tmp/.X11-unix -v /etc/localtime:/etc/localtime:ro $ros_image:latest"
container_id=$(docker ps -q --filter "name=$ros_image")
found_lock="$(find $lockation -maxdepth 1 -name "$exec_lock_prefix*$exec_lock_suffix" -print | sort | head -1)"
fl="$(basename "$found_lock")"
if [[ -z "$container_id" || "$fl" < "$earliest_possible_exec_lock_file" ]]; then
docker rm -f $ros_image >/dev/null 2>&1
intermediate_error_handler $?
x="docker run --name $ros_image --ulimit nofile=1024:524288 -d -u $userid --ipc=host --privileged --network host $gpu_param $sound --group-add dialout --group-add video --group-add audio -v $rosez_vol-bin:/bin -v $rosez_vol-etc:/etc/ -v $rosez_vol-home:/home/ -v $rosez_vol-lib:/lib/ -v $rosez_vol-lib64:/lib64/ -v /media:/media -v /mnt:/mnt -v $rosez_vol-opt:/opt/ -v $rosez_vol-root:/root/ -v /run:/run -v $rosez_vol-sbin:/sbin/ -v $rosez_vol-srv:/srv/ -v $rosez_vol-usr:/usr -v $rosez_vol-var:/var -v $rosez_vol:/opt/ros/$ros -v $SCRIPT_DIR/../includes/$rosws_file:/opt/ros/$rosws_file $volumes -v $SCRIPT_DIR/entrypoint.bash:/home/rosez_user/.bashrc -v /sys:/sys -v /dev:/dev -v $bloom_file:/home/rosez_user/.config/bloom -v $gitconfig_file:/home/rosez_user/.gitconfig -v $ssh_folder:/home/rosez_user/.ssh -v $SCRIPT_DIR/supported_versions.txt:/home/rosez_user/supported_versions.txt -v $SCRIPT_DIR/helpers.bash:/home/rosez_user/helpers.bash -v /:$HOME/.$rosez_vol -e DISPLAY -e TERM -e QT_X11_NO_MITSHM=1 -e XAUTHORITY=$xauthf -v $xauthf:$xauthf -v /tmp/.X11-unix:/tmp/.X11-unix -v /etc/localtime:/etc/localtime:ro $ros_image:latest tail -f /dev/null"
x="docker run --name $ros_image --ulimit nofile=1024:524288 -d -u $userid --ipc=host --privileged --network host $gpu_param $sound --group-add dialout --group-add video --group-add audio -v $rosez_vol-bin:/bin -v $rosez_vol-etc:/etc/ -v $rosez_vol-home:/home/ -v $rosez_vol-lib:/lib/ -v $rosez_vol-lib64:/lib64/ -v /media:/media -v /mnt:/mnt -v $rosez_vol-opt:/opt/ -v $rosez_vol-root:/root/ -v /run:/run -v $rosez_vol-sbin:/sbin/ -v $rosez_vol-srv:/srv/ -v $rosez_vol-usr:/usr -v $rosez_vol-var:/var -v $rosez_vol:/opt/ros/$ros -v $SCRIPT_DIR/../includes/$rosws_file:/opt/ros/$rosws_file $rosez_volumes -v $SCRIPT_DIR/entrypoint.bash:/home/rosez_user/.bashrc -v /sys:/sys -v /dev:/dev -v $bloom_file:/home/rosez_user/.config/bloom -v $gitconfig_file:/home/rosez_user/.gitconfig -v $ssh_folder:/home/rosez_user/.ssh -v $SCRIPT_DIR/supported_versions.txt:/home/rosez_user/supported_versions.txt -v $SCRIPT_DIR/helpers.bash:/home/rosez_user/helpers.bash -v /:$HOME/.$rosez_vol -e DISPLAY -e TERM -e QT_X11_NO_MITSHM=1 -e XAUTHORITY=$xauthf -v $xauthf:$xauthf -v /tmp/.X11-unix:/tmp/.X11-unix -v /etc/localtime:/etc/localtime:ro $ros_image:latest tail -f /dev/null"
intermediate_error_handler $?
echo -e "${colour_blue}$ros_image daemon not found.${colour_end}\nExecuting:\n---\n$x\n---"
eval "$x"
container_id=$(docker ps -q --filter "name=$ros_image")
intermediate_error_handler $?
fi
if [[ -z "$container_id" ]]; then
intermediate_error_handler 1
fi
x="docker exec $it $container_id"
intermediate_error_handler $?
extras="env $ENV LOCKFILE=$read_lock_file SKIPCOMPILATION=$skip_compilation /bin/bash"
Expand Down

0 comments on commit 397bd90

Please sign in to comment.