Created
August 29, 2026 07:11
-
-
Save proffalken/39bdafa112ef97e7c1aedc45641c0901 to your computer and use it in GitHub Desktop.
ROS2 Hardware Passthrough
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Docker Compose is a way of "orchestrating" (deciding what's going to run) | |
| # containers. We only need one service here as it does all the heavy lifting | |
| # via a single launch file, but you could easily have multiple containers | |
| # doing different things | |
| services: | |
| ros2: | |
| # We want to use the Dockerfile in this directory to | |
| # build our own image | |
| build: . | |
| # This is what the image should be called once built so we can | |
| # reference it elsewhere when managing the containers | |
| image: microarm-ros2-jazzy | |
| # This is what the container should be called when we look at | |
| # `docker ps -a` so we can easily identify it | |
| container_name: microarm-ros2 | |
| # If our user on the "host" (laptop etc) | |
| # does not have a userid of 1000, use that here instead | |
| # for the user within the container to prevent | |
| # permissions errors | |
| user: "${HOST_UID:-1000}:${HOST_GID:-1000}" | |
| # If we're changing the userid, we need to make sure that | |
| # we're still in the dialout group in order to access USB | |
| # and other serial devices | |
| group_add: | |
| - dialout | |
| # There are multiple options for networking, but to keep things simple | |
| # we'll just bridge directly to the host controller and get an IP Address | |
| # on the local network | |
| network_mode: host | |
| ipc: host | |
| # We need to set some environment variables so that the GUI tools | |
| # launch and are displayed on the host (laptop) rather than inside the container | |
| environment: | |
| - DISPLAY=${DISPLAY} | |
| - QT_X11_NO_MITSHM=1 | |
| - HOME=/tmp | |
| - LIBGL_ALWAYS_SOFTWARE=${LIBGL_ALWAYS_SOFTWARE:-0} | |
| # Now for the storage passthrough stuff | |
| volumes: | |
| # Mount the current directory that has our code in it into the | |
| # /workspace WORKINGDIR we created in the Dockerfile | |
| - .:/workspace | |
| # Pass through the Unix X11 Display socket so we can launch the GUI | |
| - /tmp/.X11-unix:/tmp/.X11-unix:rw | |
| devices: | |
| # Pass through the dri device to help with rendering | |
| - /dev/dri:/dev/dri | |
| # Pass through the connection to your serial/USB devices, one per line. | |
| # NOTE: Depending on your underlying HOST operating system, these values will change | |
| # I'm using Linux, so it's /dev/ttyACM* or /dev/ttyUSB*, but on a Mac it will be different! | |
| - /dev/ttyACM0:/dev/ttyACM0 | |
| # Make sure we can send adhoc commands to the container | |
| stdin_open: true | |
| # Make sure that we have a "proper" terminal to execute those commands against | |
| tty: true | |
| # if no other command is given, then just sleep in the background with a terminal | |
| # prompt in the foreground. | |
| command: sleep infinity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # We want to be able to run RViz etc, but we don't want to have to build everything from scratch, | |
| # so we'll use an existing container with most of that setup as a base | |
| FROM osrf/ros:jazzy-desktop | |
| # This is where we make sure the OS is up to date, and also where | |
| # we install any additional packages we need for our specific use-case | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| ros-jazzy-joint-state-publisher \ | |
| ros-jazzy-joint-state-publisher-gui \ | |
| ros-jazzy-xacro \ | |
| ros-jazzy-urdf-launch \ | |
| ros-jazzy-ros2-control \ | |
| ros-jazzy-ros2-controllers \ | |
| ros-jazzy-rqt-joint-trajectory-controller \ | |
| python3-colcon-common-extensions \ | |
| libserial-dev \ | |
| libexpected-dev \ | |
| libspdlog-dev \ | |
| libfmt-dev \ | |
| librange-v3-dev \ | |
| libyaml-cpp-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Now we make sure that every new execution of the container sets up | |
| # the environment correctly | |
| RUN echo "source /opt/ros/jazzy/setup.bash" >> /etc/bash.bashrc | |
| RUN echo "[ -f /workspace/install/setup.bash ] && source /workspace/install/setup.bash" >> /etc/bash.bashrc | |
| # If we're using Serial devices (USB etc) then we need to make sure we're | |
| # in the right groups | |
| RUN usermod -a -G dialout ubuntu | |
| # Finally, we set where all our code is going to live on disk | |
| WORKDIR /workspace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment