Skip to content

Commit

Permalink
combined.launch.py is working fine
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikN committed Dec 1, 2023
1 parent 299d1a1 commit e614e1b
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 9 deletions.
22 changes: 17 additions & 5 deletions Dockerfile.hardware
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 ================================

Expand All @@ -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

Expand Down Expand Up @@ -115,20 +119,28 @@ RUN apt-get update && apt-get install -y \

RUN echo $(cat /ros2_ws/src/rosbot/package.xml | grep '<version>' | sed -r 's/.*<version>([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/
Expand Down
18 changes: 18 additions & 0 deletions demo/compose.combined.yaml
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions demo/namespace/compose.yaml
Original file line number Diff line number Diff line change
@@ -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`
5 changes: 5 additions & 0 deletions demo/namespace/filter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
allowlist:
- name: "rt/robot1/cmd_vel"
type: "geometry_msgs::msg::dds_::Twist_"
blocklist: []
builtin-topics: []
26 changes: 26 additions & 0 deletions microros_localhost_only.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--The only purpose of this file is to disable
Fast-DDS SHM transport used by default to use UDPv4-->
<dds>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
<transport_descriptors>
<transport_descriptor>
<transport_id>CustomUdpTransport</transport_id>
<type>UDPv4</type>
<interfaceWhiteList>
<address>127.0.0.1</address>
</interfaceWhiteList>
</transport_descriptor>
</transport_descriptors>

<participant profile_name="participant_profile" is_default_profile="true">
<rtps>
<userTransports>
<transport_id>CustomUdpTransport</transport_id>
</userTransports>

<useBuiltinTransports>false</useBuiltinTransports>
</rtps>
</participant>
</profiles>
</dds>
22 changes: 22 additions & 0 deletions ros_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
8 changes: 4 additions & 4 deletions sync_with_rosbot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 22 additions & 0 deletions vulcanexus_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit e614e1b

Please sign in to comment.