From 48429fdbc65f2b020bf463093f9a13aa7a175dda Mon Sep 17 00:00:00 2001 From: rafal-gorecki Date: Mon, 4 Mar 2024 16:20:01 +0100 Subject: [PATCH] Fix Realtime --- .github/workflows/ros-docker-image.yaml | 2 +- Dockerfile.hardware | 4 ++-- demo/compose.rviz.yaml | 23 +++++++++++++++++++++++ demo/compose.simulation.yaml | 13 ++----------- demo/compose.yaml | 25 ++++++++++++------------- ros_entrypoint.sh | 14 -------------- 6 files changed, 40 insertions(+), 41 deletions(-) create mode 100644 demo/compose.rviz.yaml delete mode 100755 ros_entrypoint.sh diff --git a/.github/workflows/ros-docker-image.yaml b/.github/workflows/ros-docker-image.yaml index 8d46ff7..ac85297 100644 --- a/.github/workflows/ros-docker-image.yaml +++ b/.github/workflows/ros-docker-image.yaml @@ -60,7 +60,7 @@ jobs: with: dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} - main_branch_name: ros2-devel + main_branch_name: ros2 dockerfile: ${{ matrix.dockerfile }} repo_name: ${{ matrix.repo_name }} build_type: ${{ inputs.build_type }} diff --git a/Dockerfile.hardware b/Dockerfile.hardware index 0e6625e..72f2640 100644 --- a/Dockerfile.hardware +++ b/Dockerfile.hardware @@ -31,7 +31,6 @@ RUN apt-get update && \ # Get version echo $(cat /ros2_ws/src/panther_ros/panther/package.xml | grep '' | sed -r 's/.*([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt && \ # Size optimalization - rm -rf build log src && \ export SUDO_FORCE_REMOVE=yes && \ apt-get remove -y \ ros-dev-tools && \ @@ -39,5 +38,6 @@ RUN apt-get update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -COPY ./ros_entrypoint.sh / +# Setup envs from eeprom +RUN sed -i "/# /i set -e -a && source /run/husarion/panther_config.env" /*_entrypoint.sh ENTRYPOINT ["/ros_entrypoint.sh"] diff --git a/demo/compose.rviz.yaml b/demo/compose.rviz.yaml new file mode 100644 index 0000000..308f7f5 --- /dev/null +++ b/demo/compose.rviz.yaml @@ -0,0 +1,23 @@ +x-common-config: + &common-config + network_mode: host + ipc: host + restart: always + +x-cpu-config: + &cpu-config + env_file: .env.cpu + +x-gpu-config: + &gpu-config + runtime: nvidia + env_file: .env.gpu + + rviz: + image: husarion/rviz2:humble + <<: + - *common-config + - *cpu-config + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix:rw + - ./panther.rviz:/root/.rviz2/default.rviz diff --git a/demo/compose.simulation.yaml b/demo/compose.simulation.yaml index 2c81ecc..0a4912f 100644 --- a/demo/compose.simulation.yaml +++ b/demo/compose.simulation.yaml @@ -17,8 +17,8 @@ services: panther: image: husarion/panther-gazebo:humble # build: - # context: .. - # dockerfile: Dockerfile.simulation + # context: .. + # dockerfile: Dockerfile.simulation <<: - *common-config - *cpu-config @@ -26,12 +26,3 @@ services: - /tmp/.X11-unix:/tmp/.X11-unix:rw command: > ros2 launch panther_gazebo simulation.launch.py - - rviz: - image: husarion/rviz2:humble - <<: - - *common-config - - *cpu-config - volumes: - - /tmp/.X11-unix:/tmp/.X11-unix:rw - - ./panther.rviz:/root/.rviz2/default.rviz diff --git a/demo/compose.yaml b/demo/compose.yaml index 87bab60..ce1a558 100644 --- a/demo/compose.yaml +++ b/demo/compose.yaml @@ -15,10 +15,10 @@ x-gpu-config: services: panther: - image: husarion/panther:humble - # build: - # context: .. - # dockerfile: Dockerfile.hardware + # image: husarion/panther:humble + build: + context: .. + dockerfile: Dockerfile.hardware <<: *common-config devices: - /dev/bus/usb @@ -30,6 +30,14 @@ services: - /sys/bus/iio/devices:/sys/bus/iio/devices - /run/husarion/panther_config.env:/run/husarion/panther_config.env - /run/husarion/panther_config.yaml:/run/husarion/panther_config.yaml + # Realtime hardware (https://control.ros.org/master/doc/ros2_control/controller_manager/doc/userdoc.html#determinism) + ulimits: + rtprio: + soft: 99 + hard: 99 + memlock: + soft: 102400 + hard: 102400 command: > ros2 launch panther_bringup bringup.launch.py @@ -43,12 +51,3 @@ services: "ros2 launch joy2twist gamepad_controller.launch.py joy2twist_params_file:=$(ros2 pkg prefix joy2twist)/share/joy2twist/config/joy2twist_panther.yaml" - - rviz: - image: husarion/rviz2:humble-11.2.8-20231122 - <<: - - *common-config - - *cpu-config - volumes: - - /tmp/.X11-unix:/tmp/.X11-unix:rw - - ./panther.rviz:/root/.rviz2/default.rviz diff --git a/ros_entrypoint.sh b/ros_entrypoint.sh deleted file mode 100755 index 825e9f5..0000000 --- a/ros_entrypoint.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -e - -# setup ros environment -source "/opt/ros/$ROS_DISTRO/setup.bash" -source "/ros2_ws/install/setup.bash" - -if [ "$HUSARION_ROS_BUILD_TYPE" = "hardware" ]; then - # source eeprom environment variables - set -a - source "/run/husarion/panther_config.env" -fi - -exec "$@"