Skip to content

Commit

Permalink
Merge pull request #78 from gstavrinos/road-to-jazzy
Browse files Browse the repository at this point in the history
Road to jazzy
  • Loading branch information
gstavrinos authored Nov 2, 2024
2 parents 040f575 + 397bd90 commit 5b6e789
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 77 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*`.
File renamed without changes.
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/
80 changes: 38 additions & 42 deletions installer.bash
Original file line number Diff line number Diff line change
@@ -1,64 +1,60 @@
#!/bin/bash
original_dir=$(pwd)
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
source $SCRIPT_DIR/internal/helpers.bash
image_name=""
dockerfile=""
executable_folder_name=""
get_supported_versions
selected_version=$1
if [[ -z "$1" ]] || [ "$1" == "--interactive" ]; then
if ! type "dialog" > /dev/null 2>&1; then
echo "'dialog' (https://linux.die.net/man/1/dialog) is not installed, please install it and run the script again!"
echo "You can alternatively use the non-interactive version by running the installer with one of the following parameters depending on the ROS version you need:"
for i in $(seq 0 $(( ${#distros[@]}-1 )) ); do
echo "${rosezv[$i]} for ${distros[$i]}"
done
exit -1
else
echo "going interactive"
for i in $(seq 0 $(( ${#distros[@]}-1 )) ); do
choices="$choices\"${rosezv[$i]}\" \"${distros[$i]}\" \"on\" "
done
run_dialog_command "--radiolist" "Select a rosez version to install" ${#distros[@]} "$choices"
clear
selected_version=$choice
fi
if ! type "dialog" >/dev/null 2>&1; then
echo "'dialog' (https://linux.die.net/man/1/dialog) is not installed, please install it and run the script again!"
echo "You can alternatively use the non-interactive version by running the installer with one of the following parameters depending on the ROS version you need:"
for i in $(seq 0 $((${#distros[@]} - 1))); do
echo "${rosezv[$i]} for ${distros[$i]}"
done
exit 123
else
echo "going interactive"
for i in $(seq 0 $((${#distros[@]} - 1))); do
choices="$choices\"${rosezv[$i]}\" \"${distros[$i]}\" \"on\" "
done
run_dialog_command "--radiolist" "Select a rosez version to install" ${#distros[@]} "$choices"
clear
selected_version=$choice
fi
fi
for i in $(seq 0 $(( ${#distros[@]}-1 )) ); do
if [ "$selected_version" == "${rosezv[$i]}" ]; then
image_name="${image_names[$i]}"
dockerfile="${dockerfiles[$i]}"
executable_folder_name="${executable_folder_names[$i]}"
break
fi
for i in $(seq 0 $((${#distros[@]} - 1))); do
if [ "$selected_version" == "${rosezv[$i]}" ]; then
image_name="${image_names[$i]}"
dockerfile="${dockerfiles[$i]}"
executable_folder_name="${executable_folder_names[$i]}"
break
fi
done
if [[ -z "$image_name" ]]; then
echo "Invalid argument passed. You can run the interactive version by using the --interactive flag (or no flags at all)."
echo "You can alternatively use the non-interactive version by running the installer with one of the following parameters depending on the ROS version you need:"
for i in $(seq 0 $(( ${#distros[@]}-1 )) ); do
echo "${rosezv[$i]} for ${distros[$i]}"
done
exit -1
echo "Invalid argument passed. You can run the interactive version by using the --interactive flag (or no flags at all)."
echo "You can alternatively use the non-interactive version by running the installer with one of the following parameters depending on the ROS version you need:"
for i in $(seq 0 $((${#distros[@]} - 1))); do
echo "${rosezv[$i]} for ${distros[$i]}"
done
exit 234
fi
cd $SCRIPT_DIR
need_rr=0
if ! id -nGz "$USER" | grep -qzxF "docker"
then
sudo usermod -aG docker $USER
need_rr=1
if ! id -nGz "$USER" | grep -qzxF "docker"; then
sudo usermod -aG docker $USER
need_rr=1
fi
sudo docker build --no-cache --pull -t $image_name -f $SCRIPT_DIR/internal/$dockerfile . --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)
string_for_bashrc='export PATH="$PATH:'$SCRIPT_DIR/internal/"${executable_folder_name}"'"'

if ! $( grep -Fx "$string_for_bashrc" ~/.bashrc )
then
echo $string_for_bashrc >> ~/.bashrc
. ~/.bashrc
if ! $(grep -Fx "$string_for_bashrc" ~/.bashrc); then
echo $string_for_bashrc >>~/.bashrc
. ~/.bashrc
fi
if [[ $need_rr -gt 0 ]]
then
echo "Please reboot your system, and then try using ros-ez!"
if [[ $need_rr -gt 0 ]]; then
echo "Please reboot your system, and then try using ros-ez!"
fi
cd $original_dir

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
File renamed without changes.
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" $*
File renamed without changes.
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
43 changes: 12 additions & 31 deletions internal/rosez_exec.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
cwd=$(pwd)
cd $cwd
source $SCRIPT_DIR/helpers.bash
get_supported_versions
now="$(date +'%Y-%m-%d_%H_%M_%S_%N')"
uptime_date="$(uptime -s | sed "s/[: ]/_/g")"
# Using uptime_date I can see if a lock file is older
Expand All @@ -12,47 +13,29 @@ earliest_possible_read_lock_file="$read_lock_prefix$uptime_date$read_lock_suffix
earliest_possible_exec_lock_file="$exec_lock_prefix$uptime_date$exec_lock_suffix"
read_lock_file="$read_lock_prefix$now$read_lock_suffix"
exec_lock_file="$exec_lock_prefix$now$exec_lock_suffix"
# TODO: investigate all parameters and how they are affected with exec VS run
rosws_file="ros2_ws.txt"
rosez_vol="ros2ez-volume"
ros="humble"
ros_image="ros2_ez"
gpu_string=$(lspci | grep VGA)
gpu_param=""
clear_locks=0
skip_compilation=0
non_interactive=0
no_sound=0
kill_container=0
lockdir=""
userid=$(id -u)
if [ "$1" == "1" ]; then
rosws_file="ros_ws.txt"
rosez_vol="rosez-volume"
ros="noetic"
ros_image="ros_ez"
elif [ "$1" == "3" ]; then
rosws_file="rosm_ws.txt"
rosez_vol="rosezm-volume"
ros="melodic"
ros_image="ros_ezm"
elif [ "$1" == "4" ]; then
rosws_file="ros2f_ws.txt"
rosez_vol="ros2ezf-volume"
ros="foxy"
ros_image="ros2_ezf"
fi
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
volumes=""
rosez_volumes=""
lockation=""
while read -r line; do
wsdir=$(eval echo -e "$line")
if [ ! -d "$wsdir" ]; then
echo "$wsdir not found, creating it"
mkdir -p $wsdir/src
fi
volumes=$volumes"--volume $wsdir:/opt/ros/$(basename $wsdir) "
rosez_volumes=$rosez_volumes"--volume $wsdir:/opt/ros/$(basename $wsdir) "
if [[ -z "$lockation" ]]; then
lockation=$wsdir
fi
Expand Down Expand Up @@ -87,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 @@ -101,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 @@ -112,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 @@ -158,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
3 changes: 2 additions & 1 deletion internal/supported_versions.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// command, workspace file, volume, ros distro, image name, executable folder name, dockerfile
rosez,ros_ws.txt,rosez-volume,noetic,ros_ez,ros-ez,ros_Dockerfile
ros2ez,ros2_ws.txt,ros2ez-volume,humble,ros2_ez,ros2-ez,ros2_Dockerfile
ros2ezh,ros2h_ws.txt,ros2ezh-volume,humble,ros2_ezh,ros2-ezh,ros2_humble_Dockerfile
rosezm,rosm_ws.txt,rosezm-volume,melodic,ros_ezm,ros-ezm,ros_melodic_Dockerfile
ros2ezf,ros2f_ws.txt,ros2ezf-volume,foxy,ros2_ezf,ros2-ezf,ros2_foxy_Dockerfile
ros2ezj,ros2j_ws.txt,ros2ezj-volume,jazzy,ros2_ezj,ros2-ezj,ros2_jazzy_Dockerfile

0 comments on commit 5b6e789

Please sign in to comment.