diff --git a/.github/workflows/ros-docker-image.yaml b/.github/workflows/ros-docker-image.yaml index 53d3439..e4b86ee 100644 --- a/.github/workflows/ros-docker-image.yaml +++ b/.github/workflows/ros-docker-image.yaml @@ -45,19 +45,11 @@ jobs: - dockerfile: Dockerfile.hardware repo_name: '' platforms: linux/amd64, linux/arm64 - ros_distro: humble + ros_distro: jazzy - dockerfile: Dockerfile.gazebo repo_name: rosbot-gazebo platforms: linux/amd64 - ros_distro: humble - - dockerfile: Dockerfile.hardware - repo_name: '' - platforms: linux/amd64, linux/arm64 - ros_distro: iron - # - dockerfile: Dockerfile.gazebo - # repo_name: rosbot-gazebo - # platforms: linux/amd64 - # ros_distro: iron + ros_distro: jazzy steps: diff --git a/Dockerfile.gazebo b/Dockerfile.gazebo index eadc536..72e1efc 100644 --- a/Dockerfile.gazebo +++ b/Dockerfile.gazebo @@ -32,7 +32,7 @@ RUN MYDISTRO=${PREFIX:-ros}; MYDISTRO=${MYDISTRO//-/} && \ rm -rf build log src ## =========================== ROS builder =============================== -FROM husarnet/ros:${PREFIX}${ROS_DISTRO}-ros-base AS ros_builder +FROM husarnet/ros:${PREFIX}${ROS_DISTRO}-ros-base AS ros_builder ARG PREFIX @@ -52,12 +52,11 @@ RUN apt-get update --fix-missing && apt-get install -y \ ros-dev-tools && \ apt-get upgrade -y && \ # Clone source - git clone --depth 1 -b humble https://github.com/husarion/rosbot_ros.git src && \ + git clone --depth 1 -b jazzy-devel https://github.com/husarion/rosbot_ros.git src && \ vcs import src < src/rosbot/rosbot_hardware.repos && \ vcs import src < src/rosbot/rosbot_simulation.repos && \ - cp -r src/ros2_controllers/diff_drive_controller src/ && \ - cp -r src/ros2_controllers/imu_sensor_broadcaster src/ && \ - rm -rf src/ros2_controllers && \ + # it is necessary to remove simulation - otherwise rosdep tries to install dependencies + rm -r src/rosbot_utils && \ # Install dependencies rm -rf /etc/ros/rosdep/sources.list.d/20-default.list && \ rosdep init && \ @@ -66,7 +65,7 @@ RUN apt-get update --fix-missing && apt-get install -y \ RUN MYDISTRO=${PREFIX:-ros}; MYDISTRO=${MYDISTRO//-/} && \ source /opt/$MYDISTRO/$ROS_DISTRO/setup.bash && \ - colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release && \ + colcon build --packages-up-to rosbot --cmake-args -DCMAKE_BUILD_TYPE=Release && \ rm -rf build log ## =========================== Final Stage =============================== diff --git a/Dockerfile.hardware b/Dockerfile.hardware index 7f1e1ba..84c920a 100644 --- a/Dockerfile.hardware +++ b/Dockerfile.hardware @@ -1,4 +1,5 @@ -ARG ROS_DISTRO=humble +ARG ROS_DISTRO=jazzy +ARG MYDISTRO=ros ARG PREFIX= ## =========================== Healthcheck builder =============================== @@ -7,6 +8,8 @@ FROM husarnet/ros:${PREFIX}${ROS_DISTRO}-ros-base AS healthcheck_builder ARG ROS_DISTRO ARG PREFIX +ARG MYDISTRO +ENV HUSARION_ROS_BUILD=hardware SHELL ["/bin/bash", "-c"] @@ -36,6 +39,8 @@ FROM husarnet/ros:${PREFIX}${ROS_DISTRO}-ros-base AS ros_builder ARG ROS_DISTRO ARG PREFIX +ARG MYDISTRO +ENV HUSARION_ROS_BUILD=hardware SHELL ["/bin/bash", "-c"] @@ -47,11 +52,8 @@ COPY ./healthcheck.cpp / RUN apt-get update && apt-get install -y \ python3-pip -RUN git clone --depth 1 -b humble https://github.com/husarion/rosbot_ros.git src && \ +RUN git clone --depth 1 -b jazzy https://github.com/husarion/rosbot_ros.git src && \ vcs import src < src/rosbot/rosbot_hardware.repos && \ - cp -r src/ros2_controllers/diff_drive_controller src/ && \ - cp -r src/ros2_controllers/imu_sensor_broadcaster src/ && \ - rm -rf src/ros2_controllers && \ # it is necessary to remove simulation - otherwise rosdep tries to install dependencies rm -r src/rosbot_gazebo && \ # without this line (using vulcanexus base image) rosdep init throws error: "ERROR: default sources list file already exists:" @@ -61,7 +63,7 @@ RUN git clone --depth 1 -b humble https://github.com/husarion/rosbot_ros.git src rosdep install --from-paths src --ignore-src -y && \ MYDISTRO=${PREFIX:-ros}; MYDISTRO=${MYDISTRO//-/} && \ source /opt/$MYDISTRO/$ROS_DISTRO/setup.bash && \ - colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release && \ + colcon build --packages-up-to rosbot --cmake-args -DCMAKE_BUILD_TYPE=Release && \ echo $(cat /ros2_ws/src/rosbot/package.xml | grep '' | sed -r 's/.*([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt && \ rm -rf build log @@ -70,6 +72,8 @@ FROM husarnet/ros:${PREFIX}${ROS_DISTRO}-ros-core ARG ROS_DISTRO ARG PREFIX +ARG MYDISTRO +ENV HUSARION_ROS_BUILD=hardware SHELL ["/bin/bash", "-c"] @@ -86,11 +90,12 @@ RUN cp src/rosbot_utils/rosbot_utils/flash-firmware.py /usr/bin/ && \ RUN apt-get update && apt-get install -y \ python3-pip \ + python3-periphery \ + python3-ftdi \ python3-rosdep \ stm32flash \ gosu \ ros-$ROS_DISTRO-teleop-twist-keyboard && \ - pip3 install pyftdi && \ rm -rf /etc/ros/rosdep/sources.list.d/20-default.list && \ rosdep init && \ rosdep update --rosdistro $ROS_DISTRO && \ diff --git a/run_healthcheck_node.sh b/run_healthcheck_node.sh index 5ed31ae..84504b4 100644 --- a/run_healthcheck_node.sh +++ b/run_healthcheck_node.sh @@ -1,2 +1,15 @@ -source "/ros2_ws_healthcheck/install/setup.bash" -gosu $USER bash -c "ros2 run healthcheck_pkg healthcheck_node &" +if [ ! -z "$USER" ] && [ "$USER" != "root" ] && [ "$USER" != "$(whoami)" ]; then + # Check if the user already exists; if not, create the user + if ! id "$USER" &>/dev/null; then + useradd -ms /bin/bash "$USER" + echo "[ \"\$(whoami)\" != \"$USER\" ] && su - \"$USER\"" >> /etc/bash.bashrc + fi + + source "/ros2_ws_healthcheck/install/setup.bash" + + exec gosu $USER /bin/bash -c "ros2 run healthcheck_pkg healthcheck_node &" + +else + source "/ros2_ws_healthcheck/install/setup.bash" + ros2 run healthcheck_pkg healthcheck_node & +fi