Setup RAI with docker¶
Docker images are experimental
Docker images are experimental. For tested setup, see the local setup.
1. Build the docker image¶
Choose the docker image based on your preferred ROS 2 version. You may build the selected image with only the core dependencies or, alternatively, with all the additional modules. To build the docker image, you must clone the RAI repository:
git clone https://github.com/RobotecAI/rai.git
cd rai
1.1. Humble¶
Core dependencies only:
docker build -t rai:humble --build-arg ROS_DISTRO=humble -f docker/Dockerfile .
All dependencies:
docker build -t rai:humble --build-arg ROS_DISTRO=humble --build-arg DEPENDENCIES=all_groups -f docker/Dockerfile .
1.2. Jazzy¶
Core dependencies only:
docker build -t rai:jazzy --build-arg ROS_DISTRO=jazzy -f docker/Dockerfile .
All dependencies:
docker build -t rai:jazzy --build-arg ROS_DISTRO=jazzy --build-arg DEPENDENCIES=all_groups -f docker/Dockerfile .
2. Set up communications between docker and host (Optional)¶
ROS 2 communication
If you intend to run demos on the host machine, ensure the docker container can communicate with it. Test this by running the standard ROS 2 example with one node in docker and one on the host: link.
ROS 2 distributions
It is highly recommended that ROS 2 distribution on the host machine matches the ROS 2 distribution of the docker container. A distribution version mismatch may result in the demos not working correctly.
To allow the container to communicate with the host machine, configure the host environment as presented below:
-
Source ROS 2 on the host machine:
source /opt/ros/jazzy/setup.bash # or humble -
If not configured, set the
ROS_DOMAIN_IDenvironment variable to a domain ID between 0 and 101, inclusive. Example:export ROS_DOMAIN_ID=99 -
Install the eProsima Fast DDS middleware (should come preinstalled with ROS 2):
sudo apt install ros-"${ROS_DISTRO}"-fastrtps -
Configure the DDS middleware using the
fastrtps_config.xmlfile included in the RAI repository:export FASTRTPS_DEFAULT_PROFILES_FILE=$(pwd)/docker/fastrtps_config.xml -
Set the RMW to use eProsima Fast DDS:
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
3. Run the docker container¶
3.1. Humble¶
docker run --net=host --ipc=host --pid=host -e ROS_DOMAIN_ID=$ROS_DOMAIN_ID -it rai:humble
3.2. Jazzy¶
docker run --net=host --ipc=host --pid=host -e ROS_DOMAIN_ID=$ROS_DOMAIN_ID -it rai:jazzy
4. Run the tests to confirm the setup¶
cd /rai
source setup_shell.sh
poetry run pytest tests/{agents,messages,tools,types}