Create Overlay Docker Images
When working with MoveIt Studio, you will likely create new packages which may contain:
New Behaviors and Objectives
A number of configuration packages
Descriptions and drivers for a new robot
Novel algorithms currently not present in MoveIt Studio
For many of these applications, you can mount a user workspace directly into the MoveIt Studio Docker containers. However, there may be some use cases where this may not be sufficient, such as:
Your workspace requires additional binary packages, where
rosdep install
,apt-get install
, etc. is needed to build the workspace.The hardware and/or algorithms you are working with require additional dependencies.
You want to install additional tools for debugging during development.
Creating a Release Overlay Container
Extend the MoveIt Studio workspace defined in ~/moveit_studio/moveit_studio_ws/
with a new Docker overlay.
First, go to the ~/moveit_studio/moveit_studio_ws
folder and create a Dockerfile.overlay
file:
# Extend the 2.3.0 release of MoveIt Studio
FROM picknikciuser/moveit-studio:2.3.0 as moveit-studio-custom-release
# Copy the src/ folder of the workspace into the image
ENV MOVEIT_STUDIO_CUSTOM_WS=/opt/custom_ws
COPY ./src $MOVEIT_STUDIO_CUSTOM_WS/src
WORKDIR $MOVEIT_STUDIO_CUSTOM_WS
# Install dependencies and build the workspace
RUN . "/opt/overlay_ws/install/setup.sh" && \
apt-get update && \
rosdep install -q -y --from-paths src --ignore src && \
colcon build
Next, create a docker-compose-overlay.yaml
file which extends the docker-compose.yaml
file that was installed.
We recommend creating a copy or symbolic link of this docker-compose.yaml
file in your current folder.
version: "3.9"
services:
base:
extends:
file: docker-compose.yaml
service: base
# Optionally allow building this service from source with `docker compose build`
build:
context: .
dockerfile: Dockerfile.overlay
target: moveit-studio-custom-release
# Extend all the services from the base image
agent:
extends:
file: docker-compose.yaml
service: agent
bridge:
extends:
file: docker-compose.yaml
service: bridge
rest_api:
extends:
file: docker-compose.yaml
service: rest_api
drivers:
extends:
file: docker-compose.yaml
service: drivers
Finally, you can create a .env.overlay
file containing the necessary variables to use when launching MoveIt Studio.
For this example, you can include the following contents.
STUDIO_CONFIG_PACKAGE=picknik_ur_site_config
STUDIO_DOCKER_TAG=2.0.0
STUDIO_LICENSE_KEY= # Place your license key here
Now, you should be able to build and launch your MoveIt Studio overlay release image:
docker compose -f docker-compose-overlay.yaml --env-file .env.overlay build
docker compose -f docker-compose-overlay.yaml --env-file .env.overlay up
Creating a Dev Container
With the release container workflow from the previous section, every time you change your source code you will need to rebuild the Docker image entirely for the changes to take effect when launching MoveIt Studio. One way to get around this is by making a developer container (or dev container) that mounts the source code and lets you build and run it repeatedly without restarting the container.
As an example, let us extend the moveit-studio-custom-release
target in Dockerfile.overlay
with a development target that adds a few extra packages for debugging.
First, create a new custom entrypoint file specifically for development.
This file adds some useful aliases, sources the workspace every time the container is entered, and configures DDS settings for ROS 2 inter-process communication.
In .docker/entrypoint-dev.sh
,
#!/bin/bash
# Custom entrypoint to start when running a developer container.
set -e
# Allow aliases in noninteractive shells and source common MoveIt Studio aliases
shopt -s expand_aliases
source "/common_aliases.sh"
# If the custom workspace has been compiled we will source the setup.bash file.
# Otherwise it is up to the developer to compile and source it in their session.
if [[ -f ${MOVEIT_STUDIO_CUSTOM_WS}/install/setup.bash ]]
then
echo "Sourcing custom workspace"
source "${MOVEIT_STUDIO_CUSTOM_WS}/install/setup.bash"
else
echo -e "Custom workspace is not built. Please build it with: \ncolcon build\n"
fi
# Copies a DDS configuration file from the user's environment, if available.
/copy_dds_configs.sh
exec "$@"
Then update your Dockerfile with the following dev layer:
FROM moveit-studio-custom-release as moveit-studio-custom-dev
# The location of the user's workspace inside the container
ENV MOVEIT_STUDIO_CUSTOM_WS /opt/custom_ws
WORKDIR $MOVEIT_STUDIO_CUSTOM_WS
# Install any additional packages for development work
# hadolint ignore=DL3008
RUN apt-get update && \
apt-get install -y --no-install-recommends \
less \
gdb \
ros-humble-rclcpp-dbgsym
# Add the developer entrypoint
COPY .docker/entrypoint-dev.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
# Source the entrypoint when starting shell sessions, and prevent non-zero exit codes from terminating the session
RUN echo "source /entrypoint.sh" >> ~/.bashrc && \
echo "set +e" >> ~/.bashrc
CMD ["/usr/bin/bash"]
You can then extend the docker-compose-overlay.yaml
file with a new service named dev
as follows:
dev:
extends: base
build:
target: moveit-studio-custom-dev
# This image deliberately has no user prefix because it should not be pushed!
stdin_open: true
tty: true
privileged: true
volumes:
- ${HOME}/.ros/log_moveit_studio:/home/studio-user/.ros/log
# Mount source code
- ./src/:/opt/custom_ws/src/:rw
# Mount anonymous volumes to build cache and artifacts
- /opt/custom_ws/build
- /opt/custom_ws/install
- /opt/custom_ws/log
# Allow access to host hardware e.g. RealSense cameras
- /dev:/dev
command: sleep infinity
# Making a separate profile prevents this service from being built when using `docker compose build`
profiles: ["dev"]
Now, you should be able to build and launch your MoveIt Studio overlay dev container:
docker compose -f docker-compose-overlay.yaml --env-file .env.overlay build dev
docker compose -f docker-compose-overlay.yaml --env-file .env.overlay up dev
Once you have started the dev container, you can enter an interactive Bash session and launch one of the MoveIt Studio launch files directly. For example:
docker compose -f docker-compose-overlay.yaml --env-file .env.overlay exec -it bash
colcon build
source install/setup.bash
Once inside the container, you can compile, run tests, or even launch different parts of the MoveIt Studio applications.
Because the entrypoint runs source /common_aliases.sh
, the following shortcuts are available to launch different applications inside the container:
agent.app # brings up the MoveIt Studio agent
robot.app # brings up robot drivers (if relevant)
studio_bridge.app # brings up MoveIt Studio bridge
rest_api.app # brings up MoveIt Studio REST API
Note
Using Docker containers for development is a common practice. Many IDEs, such as Visual Studio Code and PyCharm <https://www.jetbrains.com/help/pycharm/using-docker-as-a-remote-interpreter.html>, have built-in support for developing with Docker containers. Once you have familiarized yourself with the steps above, we recommend setting up your favorite IDE(s) to help you develop new functionality for MoveIt Studio.