Skip to content

Commit

Permalink
working SHM communication betweeen host and docker (compose.build.yaml)
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikN committed Dec 29, 2023
1 parent bd7cc5c commit 8e8e3a4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile.hardware
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ RUN apt-get update && apt-get install -y \
python3-pip \
python3-rosdep \
stm32flash \
gosu \
ros-$ROS_DISTRO-teleop-twist-keyboard && \
pip3 install pyftdi && \
rm -rf /etc/ros/rosdep/sources.list.d/20-default.list && \
Expand Down
28 changes: 28 additions & 0 deletions demo/compose.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Quick Start
#
# 1. run `docker compose up` on the robot
# 2. run `ROS_DOMAIN_ID=10 ros2 run teleop_twist_keyboard teleop_twist_keyboard` in the robot termianl

x-common-config:
&common-config
network_mode: host
ipc: host
environment:
- FASTRTPS_DEFAULT_PROFILES_FILE=/shm-only.xml
- ROS_DOMAIN_ID=10
- USER

services:

rosbot:
build:
context: ..
dockerfile: Dockerfile.hardware
<<: *common-config
devices:
- ${SERIAL_PORT:?err}
command: >
ros2 launch rosbot_bringup combined.launch.py
mecanum:=${MECANUM:-False}
serial_port:=$SERIAL_PORT
serial_baudrate:=576000
17 changes: 17 additions & 0 deletions demo/shm-only.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
<transport_descriptors>
<transport_descriptor>
<transport_id>shm_transport</transport_id>
<type>SHM</type>
</transport_descriptor>
</transport_descriptors>
<participant profile_name="SHMParticipant" is_default_profile="true">
<rtps>
<userTransports>
<transport_id>shm_transport</transport_id>
</userTransports>
<useBuiltinTransports>false</useBuiltinTransports>
</rtps>
</participant>
</profiles>
9 changes: 7 additions & 2 deletions ros_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ source "/opt/ros/$ROS_DISTRO/setup.bash"
source "/ros2_ws/install/setup.bash"
source "/ros2_ws_healthcheck/install/setup.bash"

ros2 run healthcheck_pkg healthcheck_node &
if [ -z "$USER" ]; then
export USER=root
elif ! id "$USER" &>/dev/null; then
useradd -ms /bin/bash "$USER"
fi

exec "$@"
gosu $USER bash -c "ros2 run healthcheck_pkg healthcheck_node &"
exec gosu $USER "$@"

0 comments on commit 8e8e3a4

Please sign in to comment.