From e614e1b8e1e59981912c16cb121a6716f306fd0c Mon Sep 17 00:00:00 2001 From: dominikn Date: Fri, 1 Dec 2023 20:34:52 +0100 Subject: [PATCH] combined.launch.py is working fine --- Dockerfile.hardware | 22 ++++++++++++++++----- demo/compose.combined.yaml | 18 ++++++++++++++++++ demo/namespace/compose.yaml | 38 +++++++++++++++++++++++++++++++++++++ demo/namespace/filter.yaml | 5 +++++ microros_localhost_only.xml | 26 +++++++++++++++++++++++++ ros_entrypoint.sh | 22 +++++++++++++++++++++ sync_with_rosbot.sh | 8 ++++---- vulcanexus_entrypoint.sh | 22 +++++++++++++++++++++ 8 files changed, 152 insertions(+), 9 deletions(-) create mode 100644 demo/compose.combined.yaml create mode 100644 demo/namespace/compose.yaml create mode 100644 demo/namespace/filter.yaml create mode 100644 microros_localhost_only.xml create mode 100755 ros_entrypoint.sh create mode 100755 vulcanexus_entrypoint.sh diff --git a/Dockerfile.hardware b/Dockerfile.hardware index d33fe6c..7e8217a 100644 --- a/Dockerfile.hardware +++ b/Dockerfile.hardware @@ -1,6 +1,6 @@ ARG ROS_DISTRO=humble ARG PREFIX= -ARG ROSBOT_FW_RELEASE=0.7.0 +ARG ROSBOT_FW_RELEASE=0.8.0 ## ============================ STM32FLASH ================================= # stm32flash needs an older version of glibc (2.28), which is why ubuntu 18.04 was used FROM ubuntu:18.04 AS stm32flash_builder_and_downloader @@ -26,7 +26,7 @@ RUN echo ros_distro=$ROS_DISTRO firmware_release=$ROSBOT_FW_RELEASE RUN curl -L https://github.com/husarion/rosbot_ros2_firmware/releases/download/$ROSBOT_FW_RELEASE/firmware.bin -o /firmware.bin && \ curl -L https://github.com/husarion/rosbot_ros2_firmware/releases/download/$ROSBOT_FW_RELEASE/firmware.hex -o /firmware.hex -RUN git clone https://github.com/husarion/rosbot_ros.git /ros2_ws/src +RUN git clone https://github.com/husarion/rosbot_ros.git /ros2_ws/src -b ros2-combined-microros ## =========================== Firmware CPU ID ================================ @@ -50,6 +50,10 @@ RUN pip3 install -U platformio && \ pio run && \ chmod -x .pio/build/olimex_e407/firmware.bin +## =========================== Micro ROS agent =============================== + +FROM husarion/micro-ros-agent:humble-3.1.3-20231122 AS microros_agent_getter + ## =========================== ROS image =============================== FROM husarnet/ros:${PREFIX}${ROS_DISTRO}-ros-core @@ -115,20 +119,28 @@ RUN apt-get update && apt-get install -y \ RUN echo $(cat /ros2_ws/src/rosbot/package.xml | grep '' | sed -r 's/.*([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt -RUN if [ -f "/ros_entrypoint.sh" ]; then \ +COPY ros_entrypoint.sh / +COPY vulcanexus_entrypoint.sh / + +RUN if [[ ${PREFIX} == 'vulcanexus-' ]]; then \ sed -i '/test -f "\/ros2_ws\/install\/setup.bash" && source "\/ros2_ws\/install\/setup.bash"/a \ ros2 run healthcheck_pkg healthcheck_node &' \ - /ros_entrypoint.sh; \ + /vulcanexus_entrypoint.sh; \ else \ sed -i '/test -f "\/ros2_ws\/install\/setup.bash" && source "\/ros2_ws\/install\/setup.bash"/a \ ros2 run healthcheck_pkg healthcheck_node &' \ - /vulcanexus_entrypoint.sh; \ + /ros_entrypoint.sh; \ fi COPY ./healthcheck.sh / HEALTHCHECK --interval=7s --timeout=2s --start-period=5s --retries=5 \ CMD ["/healthcheck.sh"] +# copy micro-ros agent + +COPY --from=microros_agent_getter /ros2_ws /ros2_ws_microros_agent +COPY microros_localhost_only.xml / + # copy scripts COPY flash-firmware.py / COPY flash-firmware.py /usr/bin/ diff --git a/demo/compose.combined.yaml b/demo/compose.combined.yaml new file mode 100644 index 0000000..2d0e488 --- /dev/null +++ b/demo/compose.combined.yaml @@ -0,0 +1,18 @@ +services: + + rosbot: + build: + context: ../ + dockerfile: Dockerfile.hardware + devices: + - ${SERIAL_PORT:?err} + environment: + - ROS_DOMAIN_ID=123 + - ROS_LOCALHOST_ONLY=1 + command: > + ros2 launch rosbot_bringup combined.launch.py + mecanum:=${MECANUM:-False} + serial_port:=$SERIAL_PORT + serial_baudrate:=576000 + + diff --git a/demo/namespace/compose.yaml b/demo/namespace/compose.yaml new file mode 100644 index 0000000..85f2039 --- /dev/null +++ b/demo/namespace/compose.yaml @@ -0,0 +1,38 @@ +services: + + rosbot: + build: + context: ../../ + dockerfile: Dockerfile.hardware + network_mode: host + ipc: host + devices: + - ${SERIAL_PORT:?err} + environment: + - FASTRTPS_DEFAULT_PROFILES_FILE=/shm-only.xml + command: > + ros2 launch rosbot_bringup combined.launch.py + mecanum:=${MECANUM:-False} + serial_port:=$SERIAL_PORT + serial_baudrate:=576000 + namespace:=robot1 + + ros2router: + image: husarnet/ros2router:release-1.4.0 + network_mode: host + ipc: host + volumes: + - ./filter.yaml:/filter.yaml + environment: + - USE_HUSARNET=FALSE + - ROS_LOCALHOST_ONLY=1 + - ROS_DISTRO + +# 1. run `docker-compose up` on the robot +# 2. On the second host in LAN you will see only single ros2 topic: +# $ ros2 topic list +# /parameter_events +# /robot1/cmd_vel +# /rosout +# 3. You can use teleop_twist_keyboard to control the robot in robot1 namespace: +# `ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r __ns:=/robot1` \ No newline at end of file diff --git a/demo/namespace/filter.yaml b/demo/namespace/filter.yaml new file mode 100644 index 0000000..a6da4ee --- /dev/null +++ b/demo/namespace/filter.yaml @@ -0,0 +1,5 @@ +allowlist: + - name: "rt/robot1/cmd_vel" + type: "geometry_msgs::msg::dds_::Twist_" +blocklist: [] +builtin-topics: [] \ No newline at end of file diff --git a/microros_localhost_only.xml b/microros_localhost_only.xml new file mode 100644 index 0000000..d433142 --- /dev/null +++ b/microros_localhost_only.xml @@ -0,0 +1,26 @@ + + + + + + + CustomUdpTransport + UDPv4 + +
127.0.0.1
+
+
+
+ + + + + CustomUdpTransport + + + false + + +
+
\ No newline at end of file diff --git a/ros_entrypoint.sh b/ros_entrypoint.sh new file mode 100755 index 0000000..f0da6dc --- /dev/null +++ b/ros_entrypoint.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +output=$(husarnet-dds singleshot) || true +if [[ "$HUSARNET_DDS_DEBUG" == "TRUE" ]]; then + echo "$output" +fi + +# Check if XRCE_DOMAIN_ID_OVERRIDE is unset or empty +if [ -z "$XRCE_DOMAIN_ID_OVERRIDE" ]; then + # If ROS_DOMAIN_ID is set and not empty, set XRCE_DOMAIN_ID_OVERRIDE to its value + if [ -n "$ROS_DOMAIN_ID" ]; then + export XRCE_DOMAIN_ID_OVERRIDE="$ROS_DOMAIN_ID" + fi +fi + +# setup ros environment +source "/opt/ros/$ROS_DISTRO/setup.bash" +source "/ros2_ws/install/setup.bash" +source "/ros2_ws_microros_agent/install/setup.bash" + +exec "$@" diff --git a/sync_with_rosbot.sh b/sync_with_rosbot.sh index 2dbd9c5..f4a2738 100755 --- a/sync_with_rosbot.sh +++ b/sync_with_rosbot.sh @@ -3,8 +3,8 @@ # If your ROSbot's IP addr is 10.5.10.64 execute: # ./sync_with_rosbot.sh 10.5.10.64 -sshpass -p "husarion" rsync -vRr ./ husarion@$1:/home/husarion/${PWD##*/} +sshpass -p "husarion" rsync -vRr --delete ./ husarion@$1:/home/husarion/${PWD##*/} -while inotifywait -r -e modify,create,delete,move ./ ; do - sshpass -p "husarion" rsync -vRr ./ husarion@$1:/home/husarion/${PWD##*/} -done +while inotifywait -r -e modify,create,delete,move ./ ; do + sshpass -p "husarion" rsync -vRr --delete ./ husarion@$1:/home/husarion/${PWD##*/} +done \ No newline at end of file diff --git a/vulcanexus_entrypoint.sh b/vulcanexus_entrypoint.sh new file mode 100755 index 0000000..e362a3b --- /dev/null +++ b/vulcanexus_entrypoint.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +output=$(husarnet-dds singleshot) || true +if [[ "$HUSARNET_DDS_DEBUG" == "TRUE" ]]; then + echo "$output" +fi + +# Check if XRCE_DOMAIN_ID_OVERRIDE is unset or empty +if [ -z "$XRCE_DOMAIN_ID_OVERRIDE" ]; then + # If ROS_DOMAIN_ID is set and not empty, set XRCE_DOMAIN_ID_OVERRIDE to its value + if [ -n "$ROS_DOMAIN_ID" ]; then + export XRCE_DOMAIN_ID_OVERRIDE="$ROS_DOMAIN_ID" + fi +fi + +# setup ros environment +source "/opt/vulcanexus/$ROS_DISTRO/setup.bash" +source "/ros2_ws/install/setup.bash" +source "/ros2_ws_microros_agent/install/setup.bash" + +exec "$@"