Skip to content

Commit 1e1d1ed

Browse files
committed
Added ROS_IP configuration
1 parent 72ea379 commit 1e1d1ed

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

robot-template/_build/robot-noble-ros2/Dockerfile-base

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ ARG RECIPES_TAG=main
99
ARG ROBOT_PACKAGES=""
1010
ARG ADDITIONAL_PACKAGES=""
1111

12-
12+
# ROS2 DDS Configuration arguments (ADD THESE NEW ARGS)
13+
ARG ROS_DDS_VENDOR=cyclonedds
14+
ARG ROS_IP=localhost
15+
ARG SETUP_ROS2_DDS=true
1316

1417
# env
1518
ENV PYTHONUNBUFFERED=1
@@ -24,7 +27,6 @@ RUN sudo apt-get update && sudo apt-get install -y curl && \
2427

2528
RUN sudo apt update && sudo apt install -y xbot2_desktop_full ros-$ROS_DISTRO-realsense2-description
2629

27-
2830
# add kyon user
2931
USER root
3032

@@ -53,6 +55,31 @@ ENV HHCM_FOREST_CLONE_DEFAULT_PROTO=https
5355
# pip deps
5456
RUN source ~/env/bin/activate && pip install netifaces
5557

58+
# ============ ADD ROS2 DDS CONFIGURATION HERE ============
59+
# ROS2 DDS Configuration (for all robots using ROS2)
60+
# Install cmake if not already present (might be needed for ros2_config)
61+
RUN if [ "$SETUP_ROS2_DDS" = "true" ]; then \
62+
sudo apt-get update && sudo apt-get install -y cmake build-essential; \
63+
fi
64+
65+
# Conditionally setup ROS2 DDS configuration
66+
RUN if [ "$SETUP_ROS2_DDS" = "true" ]; then \
67+
git clone https://github.com/advrhumanoids/ros2_config.git /tmp/ros2_config && \
68+
cd /tmp/ros2_config && \
69+
mkdir build && cd build && \
70+
cmake .. -DROS2_IP=$ROS_IP && \
71+
make && \
72+
sudo make install && \
73+
echo "source ~/ros2_config/dds/${ROS_DDS_VENDOR}/setup.bash" >> ~/.bashrc && \
74+
cd / && rm -rf /tmp/ros2_config; \
75+
fi
76+
77+
# Also set the RMW implementation if using CycloneDDS
78+
RUN if [ "$ROS_DDS_VENDOR" = "cyclonedds" ]; then \
79+
echo "export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp" >> ~/.bashrc; \
80+
fi
81+
# ============ END ROS2 DDS CONFIGURATION ============
82+
5683
# build required software (requires valid netrc for auth)
5784
# FIX 2: Activate env before running build script
5885
RUN --mount=type=secret,id=netrc,dst=/home/$USER_NAME/.netrc,uid=$USER_ID \

robot-template/_build/robot-noble-ros2/docker-bake.hcl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ variable "ADDITIONAL_PACKAGES" { default = "" }
1616
variable "CI" { default = "" } # Will be set by GitHub Actions
1717
variable "GITHUB_ACTIONS" { default = "" } # Also set by GitHub Actions
1818
variable "LOCAL_CACHE_DIR" { default = "/tmp/buildkit-cache" }
19-
19+
variable "ROS_DDS_VENDOR" { default = "cyclonedds" }
20+
variable "ROS_IP" { default = "localhost" }
21+
variable "SETUP_ROS2_DDS" { default = "true" }
2022

2123

2224
# Function to generate tags for images
@@ -60,7 +62,10 @@ target "base" {
6062
RECIPES_TAG = RECIPES_TAG
6163
ROBOT_PACKAGES = ROBOT_PACKAGES
6264
ADDITIONAL_PACKAGES = ADDITIONAL_PACKAGES
63-
65+
# Add DDS configuration args
66+
ROS_DDS_VENDOR = ROS_DDS_VENDOR
67+
ROS_IP = ROS_IP
68+
SETUP_ROS2_DDS = SETUP_ROS2_DDS
6469
}
6570
secret = [
6671
{

0 commit comments

Comments
 (0)