{"id":21702436,"url":"https://github.com/2b-t/realsense-ros2-docker","last_synced_at":"2025-09-11T05:17:01.342Z","repository":{"id":69124133,"uuid":"502744846","full_name":"2b-t/realsense-ros2-docker","owner":"2b-t","description":"Dockerfile for Intel Realsense camera in ROS 2","archived":false,"fork":false,"pushed_at":"2024-09-09T19:59:55.000Z","size":1026,"stargazers_count":64,"open_issues_count":0,"forks_count":18,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-03T01:41:27.373Z","etag":null,"topics":["docker","docker-compose","dockerfile","dockerfile-examples","intel-realsense","intel-realsense-camera","intel-realsense2","perception","robot-operating-system","ros2","ros2-humble","stereo-camera","stereo-vision"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/2b-t.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-12T22:47:46.000Z","updated_at":"2025-03-26T19:03:43.000Z","dependencies_parsed_at":"2024-09-10T12:56:35.992Z","dependency_job_id":null,"html_url":"https://github.com/2b-t/realsense-ros2-docker","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"e546388ce741111ffd95cc943334a135533e826a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/2b-t/realsense-ros2-docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2b-t%2Frealsense-ros2-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2b-t%2Frealsense-ros2-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2b-t%2Frealsense-ros2-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2b-t%2Frealsense-ros2-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2b-t","download_url":"https://codeload.github.com/2b-t/realsense-ros2-docker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2b-t%2Frealsense-ros2-docker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274580559,"owners_count":25311199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","dockerfile","dockerfile-examples","intel-realsense","intel-realsense-camera","intel-realsense2","perception","robot-operating-system","ros2","ros2-humble","stereo-camera","stereo-vision"],"created_at":"2024-11-25T21:15:36.744Z","updated_at":"2025-09-11T05:17:01.297Z","avatar_url":"https://github.com/2b-t.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker for Intel Realsense cameras on ROS 2\n\nAuthor: [Tobit Flatscher](https://github.com/2b-t) (2022 - 2024)\n\n[![Build](https://github.com/2b-t/realsense-ros2-docker/actions/workflows/build.yml/badge.svg)](https://github.com/2b-t/realsense-ros2-docker/actions/workflows/build.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\n\n## 0. Overview\nThis repository contains a Docker and all the documentation required to launch an [Intel Realsense camera](https://www.intel.co.uk/content/www/uk/en/architecture-and-technology/realsense-overview.html) with the [Robot Operating System ROS 2](https://docs.ros.org/en/humble/index.html).\n\n## 1. Creating a Docker\nThere are two different approaches for creating a Docker for a Realsense camera, one uses existing **Debian packages** while the other performs a full **compilation from source**. It is then important to mount `/dev` as a volume so that the Docker can access the hardware.\n\nIn the `docker-compose.yml` this is done with the options:\n\n```yaml\n    volumes:\n      - /dev:/dev\n    device_cgroup_rules:\n      - 'c 81:* rmw'\n      - 'c 189:* rmw'\n```\n\nFor more information on how to obtain these device cgroup rules see [here](https://github.com/2b-t/docker-for-robotics/blob/main/doc/WorkingWithHardware.md). For running the IMU as well you will have to add [**`privileged: true`**](https://docs.docker.com/compose/compose-file/compose-file-v3/#domainname-hostname-ipc-mac_address-privileged-read_only-shm_size-stdin_open-tty-user-working_dir).\n\n### 1.1 Installation from Debian packages\n\nThe relevant packages for `amd64` and most distributions can be installed from Debian packages. This is significantly simpler and less error prone than a full compilation from source but corresponding Debian packages might not be available for all Ubuntu versions and are sadly currently not available for `arm64`. **In the case of an `arm64` architecture you will have to go for a compilation from source as described in the next section.** The corresponding Dockerfile for `amd64` can be found below. It is based on the installation guides for [`librealsense`](https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md#installing-the-packages) and [its ROS wrapper](https://github.com/IntelRealSense/realsense-ros/tree/ros2-beta).\n\n```Dockerfile\nFROM ros:humble-perception\n\nENV WS_DIR=\"/ros2_ws\"\nWORKDIR ${WS_DIR}\n\nSHELL [\"/bin/bash\", \"-c\"]\n\nARG DEBIAN_FRONTEND=noninteractive\n\nRUN apt-get update \\\n \u0026\u0026 apt-get install -y \\\n    build-essential \\\n    cmake \\\n    git-all \\\n    software-properties-common \\\n \u0026\u0026 rm -rf /var/lib/apt/lists/*\n\nRUN apt-get update \\\n \u0026\u0026 apt-get install -y \\\n    ros-${ROS_DISTRO}-librealsense2* \\\n    ros-${ROS_DISTRO}-realsense2-* \\\n \u0026\u0026 rm -rf /var/lib/apt/lists/*\n\nRUN apt-get update \\\n \u0026\u0026 apt-get install -y \\\n    ros-${ROS_DISTRO}-rviz2 \\\n \u0026\u0026 rm -rf /var/lib/apt/lists/*\n\nARG DEBIAN_FRONTEND=dialog\n```\n\n### 1.2 Installation from source\nThe installation from source is slightly more involved but more general: It might work with ROS 2 distributions before the support is officially added (as used to be the case for ROS Humble for quite a while). In order to optimise memory usage a [multi-stage build](https://docs.docker.com/develop/develop-images/multistage-build/) is performed. The Dockerfile is inspired by the [Dockerfile of `librealsense`](https://github.com/IntelRealSense/librealsense/blob/master/scripts/Docker/Dockerfile) contributed by community members:\n\n```Dockerfile\nARG BASE_IMAGE=ros:humble-perception\n\n# The following steps are based on the offical multi-stage build: https://github.com/IntelRealSense/librealsense/blob/master/scripts/Docker/Dockerfile\n#################################\n#   Librealsense Builder Stage  #\n#################################\nFROM $BASE_IMAGE as librealsense-builder\n\nSHELL [\"/bin/bash\", \"-c\"]\n\nENV DEBIAN_FRONTEND=noninteractive\n\nRUN apt-get update \\\n \u0026\u0026 apt-get install -qq -y --no-install-recommends \\\n    build-essential \\\n    cmake \\\n    git \\\n    libssl-dev \\\n    libusb-1.0-0-dev \\\n    pkg-config \\\n    libgtk-3-dev \\\n    libglfw3-dev \\\n    libgl1-mesa-dev \\\n    libglu1-mesa-dev \\    \n    curl \\\n    python3 \\\n    python3-dev \\\n    ca-certificates \\\n \u0026\u0026 rm -rf /var/lib/apt/lists/*\n\nWORKDIR /usr/src\n# Get the latest tag of remote repository: https://stackoverflow.com/a/12704727\n# Needs to be a single command as ENV can't be set from Bash command: https://stackoverflow.com/questions/34911622/dockerfile-set-env-to-result-of-command\nRUN export LIBRS_GIT_TAG=`git -c 'versionsort.suffix=-' \\\n                         ls-remote --exit-code --refs --sort='version:refname' --tags https://github.com/IntelRealSense/librealsense '*.*.*' \\\n                         | tail --lines=1 \\\n                         | cut --delimiter='/' --fields=3`; \\\n    export LIBRS_VERSION=${LIBRS_VERSION:-${LIBRS_GIT_TAG#\"v\"}}; \\\n    curl https://codeload.github.com/IntelRealSense/librealsense/tar.gz/refs/tags/v${LIBRS_VERSION} -o librealsense.tar.gz; \\\n    tar -zxf librealsense.tar.gz; \\\n    rm librealsense.tar.gz; \\\n    ln -s /usr/src/librealsense-${LIBRS_VERSION} /usr/src/librealsense\n\nRUN cd /usr/src/librealsense \\\n \u0026\u0026 mkdir build \u0026\u0026 cd build \\\n \u0026\u0026 cmake \\\n    -DCMAKE_C_FLAGS_RELEASE=\"${CMAKE_C_FLAGS_RELEASE} -s\" \\\n    -DCMAKE_CXX_FLAGS_RELEASE=\"${CMAKE_CXX_FLAGS_RELEASE} -s\" \\\n    -DCMAKE_INSTALL_PREFIX=/opt/librealsense \\    \n    -DBUILD_GRAPHICAL_EXAMPLES=OFF \\\n    -DBUILD_PYTHON_BINDINGS:bool=true \\\n    -DCMAKE_BUILD_TYPE=Release ../ \\\n \u0026\u0026 make -j$(($(nproc)-1)) all \\\n \u0026\u0026 make install\n \n ENV DEBIAN_FRONTEND=dialog\n\n######################################\n#   librealsense Base Image Stage    #\n######################################\nFROM ${BASE_IMAGE} as librealsense\n\nSHELL [\"/bin/bash\", \"-c\"]\n\nCOPY --from=librealsense-builder /opt/librealsense /usr/local/\nCOPY --from=librealsense-builder /usr/lib/python3/dist-packages/pyrealsense2 /usr/lib/python3/dist-packages/pyrealsense2\nCOPY --from=librealsense-builder /usr/src/librealsense/config/99-realsense-libusb.rules /etc/udev/rules.d/\nENV PYTHONPATH=${PYTHONPATH}:/usr/local/lib\n\nENV DEBIAN_FRONTEND=noninteractive\n\nRUN apt-get update \\\n \u0026\u0026 apt-get install -y --no-install-recommends \\\t\n    libusb-1.0-0 \\\n    udev \\\n    apt-transport-https \\\n    ca-certificates \\\n    curl \\\n    software-properties-common \\\n \u0026\u0026 rm -rf /var/lib/apt/lists/*\n\n# The following steps are based on: https://github.com/IntelRealSense/realsense-ros/tree/ros2-development\nENV WS_DIR=\"/ros2_ws\"\nWORKDIR ${WS_DIR}\nRUN apt-get update -y \\\n \u0026\u0026 apt-get install -y \\\n    ros-${ROS_DISTRO}-rviz2 \\\n \u0026\u0026 mkdir src \\\n \u0026\u0026 cd src \\\n \u0026\u0026 git clone https://github.com/IntelRealSense/realsense-ros.git -b ros2-development \\\n \u0026\u0026 cd .. \\\n \u0026\u0026 apt-get install -y python3-rosdep \\\n \u0026\u0026 source /opt/ros/${ROS_DISTRO}/setup.bash \\\n \u0026\u0026 rm /etc/ros/rosdep/sources.list.d/20-default.list \\\n \u0026\u0026 rosdep init \\\n \u0026\u0026 rosdep update \\\n \u0026\u0026 rosdep install -i --from-path src --rosdistro ${ROS_DISTRO} --skip-keys=librealsense2 -y \\\n \u0026\u0026 colcon build\n\nENV DEBIAN_FRONTEND=dialog\n\nCMD [ \"rs-enumerate-devices\", \"--compact\" ]\n```\n\n## 2. Launching\nAllow the container to display contents on your host machine by typing\n\n```bash\n$ xhost +local:root\n```\n\nThen build the Docker container with\n\n```shell\n$ docker compose -f docker-compose-gui.yml build\n```\nor directly with the [`devcontainer` in Visual Studio Code](https://code.visualstudio.com/docs/devcontainers/containers). For Nvidia graphic cards the file `docker-compose-gui-nvidia.yml` in combination with the [`nvidia-container-runtime`](https://nvidia.github.io/nvidia-container-runtime/) has to be used instead.\nAfter it is done building **connect the Realsense**, start the container\n\n```shell\n$ docker compose -f docker-compose-gui.yml up\n```\nand see if you can **detect it from inside the Docker** by typing inside the Docker\n```shell\n$ rs-enumerate-devices --compact\n```\nTurn on the camera inside the application, see if you can see a three-dimensional image. Finally we can **launch the ROS 2 wrapper**\n```shell\n$ ros2 launch realsense2_camera rs_launch.py pointcloud.enable:=true\n```\nand in another terminal the ROS visualiser Rviz\n```shell\n$ ros2 run rviz2 rviz2\n```\nIn Rviz you can then display the topics published by the Realsense. For the list of available topics use\n```shell\n$ ros2 topic list\n```\nin combination with\n```shell\n$ ros2 topic info \u003ctopic_name\u003e\n```\nto find out what display type has to be selected in Rviz.\n\n![Rviz2 preview](./media/preview.png)\n\n\n\n## 3. Debugging\n\nThe Intel Realsense driver has several serious flaws/bugs. In case this Docker image does not work for you please have a look at the [issues on `realsense-ros`](https://github.com/IntelRealSense/realsense-ros/issues) to see if somebody has encountered the same issue already. Issues you might encounter are likely related to the underlying fragile library itself.\n\n- The driver is **closely connected to the [kernel version of the Linux operating system](https://github.com/IntelRealSense/librealsense/issues/9360)**. If the Dockerfile above do not work then you are likely unlucky and it is an incompatible version of the kernel of your host system and you will either have to [downgrade your kernel](https://linuxhint.com/install-linux-kernel-ubuntu/) or switch to another Ubuntu version that is officially supported.\n\n- The Realsense is **pretty [picky about USB 3.x cables](https://github.com/IntelRealSense/librealsense/issues/2045)**. If your camera is detected via `rs-enumerate-devices`, you can see it `realsense-viewer` but can't output its video stream, then it might be that your cable lacks the bandwidth. Either you can try to turn down the resolution of the camera in the `realsense-viewer` or switch cable (preferably to one that is [already known to work](https://community.intel.com/t5/Items-with-no-label/long-USB-cable-for-realsense-D435i/m-p/694963)).\n\n- The Realsense ROS driver itself is known for **struggling with [Nvidia Jetson embedded computers](https://github.com/IntelRealSense/realsense-ros/issues?q=jetson+) and [Raspberry Pi single-board computers](https://github.com/IntelRealSense/realsense-ros/issues?q=raspberry)**. Some users seem to have had success by up- or downgrading the versions of `librealsense` and/or the camera firmware but it might as well be that you find exactly the issue that you are encountering but it was never solved and closed due to inactivity (see also the issues [#2](https://github.com/2b-t/realsense-ros2-docker/issues/2) and [#4](https://github.com/2b-t/realsense-ros2-docker/issues/4)).\n\n- A useful tool to check if the Realsense is working properly without ROS is the Realsense viewer. It can be installed as discussed in [issue #3](https://github.com/2b-t/realsense-ros2-docker/issues/3) and launched with:\n\n  ```shell\n  $ realsense-viewer\n  ```\n\n- In case you want to also use the **IMU** present in some Realsense models such as the D435i with e.g.\n  ```\n  $ ros2 launch realsense2_camera rs_launch.py pointcloud.enable:=true enable_gyro:=true enable_accel:=true unite_imu_method:=2\n  ```\n\n  it seems like the only way for this is to run the container with the [**`privileged`** flag](https://docs.docker.com/compose/compose-file/compose-file-v3/#domainname-hostname-ipc-mac_address-privileged-read_only-shm_size-stdin_open-tty-user-working_dir). For more details see [issue #5](https://github.com/2b-t/realsense-ros2-docker/issues/5).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2b-t%2Frealsense-ros2-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2b-t%2Frealsense-ros2-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2b-t%2Frealsense-ros2-docker/lists"}