Skip to content

Commit

Permalink
Add librealsense to Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsided committed Jun 3, 2020
1 parent c897e59 commit c421b87
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git/
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ RUN apt-get update && apt-get install -y \
protobuf-compiler \
&& rm -rf /var/lib/apt/lists/*

# librealsense cannot be installed in this container; see
# https://github.com/IntelRealSense/librealsense/issues/4781

# Installation of librealsense fix
COPY docker/build-librealsense.sh /tmp/build-librealsense.sh
RUN mkdir -p /tmp/librealsense && cd /tmp/librealsense && /tmp/build-librealsense.sh \
&& rm -rf /tmp/librealsense \
&& rm -rf /var/lib/apt/lists/*

# Install packages the Home Service Robot? project
RUN apt-get update && apt-get install -y \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
ros-kinetic-gmapping \
ros-kinetic-joy \
ros-kinetic-turtlebot \
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Home Service Robot

To build the project, you can try executing `./run-nvidia.sh` to drop
into an X11 aware Docker container with NVIDIA GPU support.

## Docker environment

An issue exists with ROS Kinetic and TurtleBot in Docker, since the TurtleBot packages rely on
`librealsense`, which in turn depends on a Kernel module that cannot be installed. This is pointed out by
[IntelRealSense/librealsense#4781](https://github.com/IntelRealSense/librealsense/issues/4781), which
(thankfully) also provides a workaround. That workaround is implemented in [`docker/build-librealsense.sh`](docker/build-librealsense.sh) and is executed as part of the Docker image build in [`build-docker.sh`](build-docker.sh).

## Building with CLion IDE

**Note:** This does not _really_ work, as CLion will be unable to find generated headers. It's still a bit
better than doing everything the hard way.

The full requirements for setting up CLion are given in the [sunsided/robond-ros-docker](https://github.com/sunsided/robond-ros-docker)
repository. In short, run SSHD in Docker, configure a Remote Host build to connect to it, then configure
the your build settings for ROS. For this repo and the included Dockerfile, this configuration will do:

**CMake options:**

```
-DCATKIN_DEVEL_PREFIX:PATH=/workspace/devel -DCMAKE_PREFIX_PATH=/workspace/devel;/opt/ros/kinetic;/opt/ros/kinetic/share
```

**Environment:**

```
ROS_ROOT=/opt/ros/kinetic/share/ros;ROS_PACKAGE_PATH=/workspace/src:/opt/ros/kinetic/share;ROS_MASTER_URI=http://localhost:11311;ROS_PYTHON_VERSION=2;ROS_VERSION=1;ROSLISP_PACKAGE_DIRECTORIES=/workspace/devel/share/common-lisp;ROS_DISTRO=kinetic;ROS_ETC_DIR=/opt/ros/kinetic/etc/ros;PYTHONPATH=/opt/ros/kinetic/lib/python2.7/dist-packages;PKG_CONFIG_PATH=/workspace/devel/lib/pkgconfig:/opt/ros/kinetic/lib/pkgconfig:/opt/ros/kinetic/lib/x86_64-linux-gnu/pkgconfig;LD_LIBRARY_PATH=/workspace/devel/lib:/opt/ros/kinetic/lib:/opt/ros/kinetic/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH;PATH=/opt/ros/kinetic/bin:$PATH
```
37 changes: 37 additions & 0 deletions docker/build-librealsense.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# see https://github.com/IntelRealSense/librealsense/issues/4781

export DEBIAN_FRONTEND=noninteractive

# basic container setup
apt-get update
apt-get install -y lsb-release
apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list
apt-get update

# dependencies needed by librealsense. `deb -i` will not resolve these
apt-get install -y binutils cpp cpp-5 dkms fakeroot gcc gcc-5 kmod libasan2 libatomic1 libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libfakeroot libgcc-5-dev libgmp10 libgomp1 libisl15 libitm1 liblsan0 libmpc3 libmpfr4 libmpx0 libquadmath0 libssl-dev libssl-doc libtsan0 libubsan0 libusb-1.0-0 libusb-1.0-0-dev libusb-1.0-doc linux-headers-4.4.0-159 linux-headers-4.4.0-159-generic linux-headers-generic linux-libc-dev make manpages manpages-dev menu patch zlib1g-dev
apt-get install -y libssl-dev libssl-doc libusb-1.0-0 libusb-1.0-0-dev libusb-1.0-doc linux-headers-4.4.0-159 linux-headers-4.4.0-159-generic linux-headers-generic zlib1g-dev

# modify librealsense deb (unpack, replace script, repack)
apt-get download ros-kinetic-librealsense
dpkg-deb -R ros-kinetic-librealsense*.deb ros-rslib/

wget https://gist.githubusercontent.com/dizz/404ef259a15e1410d692792da0c27a47/raw/3769e80a051b5f2ce2a08d4ee6f79c766724f495/postinst
chmod +x postinst
cp postinst ros-rslib/DEBIAN

PACKAGE_VERSION=$(cat ros-rslib/DEBIAN/control | grep Version | cut -d'-' -f1 | cut -d' ' -f2)
PACKAGE_DATE=$(cat ros-rslib/DEBIAN/control | grep Version | cut -d'-' -f3)
PACKAGE_NAME=ros-kinetic-librealsense_${PACKAGE_VERSION}-0xenial-${PACKAGE_DATE}_icrlab_amd64.deb

echo ${PACKAGE_VERSION} ${PACKAGE_DATE}

dpkg-deb -b ./ros-rslib/ ${PACKAGE_NAME}

# install container friendly libsense
dpkg -i ${PACKAGE_NAME}

# lock from updates
apt-mark hold ros-kinetic-librealsense

0 comments on commit c421b87

Please sign in to comment.