forked from AutonomyLab/create_robot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Docker with ROS Melodic + Gazebo 9 + nvidia-docker2 (#16)
* Docker container: first commit * Fix Error in Dockerfile * Start testing vcstool * Add Github dependencies using vcstool * Edit building instructions * Delete * Clean up package.xml in ca_move_base * Delete unnecessary kobuki_msgs dependency * Edit Docker instructions * Fix Dockerfile * Docker container: first commit * Delete kobuki_msgs dependency * Fix Dockerfile * Add EOL * Edit README
- Loading branch information
Showing
13 changed files
with
463 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# If you want to rebuild all images, set this to --no-cache from the commandline | ||
DOCKER_ARGS?= | ||
|
||
.PHONY: create_ubuntu_bionic | ||
create_ubuntu_bionic: | ||
docker build ${DOCKER_ARGS} -t create_ubuntu_bionic create_ubuntu_bionic | ||
|
||
.PHONY: create_ros_melodic | ||
create_ros_melodic: create_ubuntu_bionic | ||
docker build ${DOCKER_ARGS} -t create_ros_melodic create_ros_melodic | ||
|
||
.PHONY: create_gazebo9 | ||
create_gazebo9: create_ros_melodic | ||
docker build ${DOCKER_ARGS} -t create_gazebo9 create_gazebo9 | ||
|
||
.PHONY: create_nvidia | ||
create_nvidia: create_gazebo9 | ||
docker build ${DOCKER_ARGS} -t create_nvidia create_nvidia |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# ROS Melodic + Gazebo 9 on Docker | ||
|
||
## Step 1: Install Docker | ||
[Install docker](https://docs.docker.com/engine/installation/linux/ubuntu/) and [configure after postintalling it](https://docs.docker.com/install/linux/linux-postinstall/). | ||
|
||
To run docker without super user: | ||
|
||
```bash | ||
$ sudo groupadd docker | ||
$ sudo gpasswd -a ${USER} docker | ||
$ sudo service docker restart | ||
``` | ||
|
||
## Step 2: Use NVIDIA acceleration | ||
|
||
### Install [nvidia-docker2](https://github.com/nvidia/nvidia-docker/wiki/Installation-(version-2.0)) | ||
|
||
#### Prerequisites | ||
|
||
1. GNU/Linux x86_64 with kernel version > 3.10 | ||
2. Docker >= 1.12 | ||
3. NVIDIA GPU with Architecture > Fermi (2.1) | ||
4. NVIDIA drivers ~= 361.93 (untested on older versions) | ||
|
||
#### Removing nvidia-docker 1.0 | ||
|
||
Version 1.0 of the nvidia-docker package must be cleanly removed before continuing. | ||
You must stop and remove all containers started with nvidia-docker 1.0. | ||
|
||
```bash | ||
$ docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f | ||
$ sudo apt-get purge nvidia-docker | ||
``` | ||
|
||
#### Installing version 2.0 | ||
|
||
Make sure you have installed the [NVIDIA driver](https://github.com/NVIDIA/nvidia-docker/wiki/Frequently-Asked-Questions#how-do-i-install-the-nvidia-driver). | ||
|
||
If you have a custom `/etc/docker/daemon.json`, the `nvidia-docker2` package might override it. | ||
|
||
Install the repository for your distribution by following the instructions here. | ||
|
||
```bash | ||
$ wcurl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \ | ||
sudo apt-key add - | ||
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) | ||
$ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \ | ||
sudo tee /etc/apt/sources.list.d/nvidia-docker.list | ||
$ sudo apt-get update | ||
``` | ||
|
||
Add Docker's official GPG key. | ||
|
||
```bash | ||
$ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \ | ||
sudo apt-key add - | ||
``` | ||
|
||
Install the `nvidia-docker2` package and reload the Docker daemon configuration: | ||
|
||
```bash | ||
$ sudo apt-get install nvidia-docker2 | ||
$ sudo pkill -SIGHUP dockerd | ||
``` | ||
|
||
## Step 3: Creating the container | ||
|
||
This repository contain the Dockerfile. Move into the directory containing the file and type | ||
|
||
The command below will **create** the container from the base image if it doesn't exist and log you in. | ||
|
||
```bash | ||
$ make create-melodic-gazebo9 | ||
``` | ||
|
||
## Step 4: Start the container | ||
|
||
To make it easier, I created the launcher **launch_docker.sh** (you might need to call **chmod +x ./launch_docker.sh** first). | ||
|
||
```bash | ||
$ ./launch_docker.sh -d create_nvidia | ||
``` | ||
|
||
Every time you launch the Docker container, you'll need to compile the workspace and source: | ||
|
||
```bash | ||
$ catkin_make -DCMAKE_BUILD_TYPE=Release -j4 | ||
$ source devel/setup.bash | ||
``` | ||
|
||
# References | ||
|
||
* http://wiki.ros.org/docker/Tutorials/Docker | ||
* http://wiki.ros.org/docker/Tutorials/Hardware%20Acceleration | ||
* http://wiki.ros.org/docker/Tutorials/GUI |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
FROM ros:melodic-ros-base | ||
LABEL maintainer="Emiliano Borghi" | ||
|
||
ENV ROS_DISTRO melodic | ||
|
||
RUN apt-get update && \ | ||
apt-get install --no-install-recommends -y \ | ||
apt-utils \ | ||
curl \ | ||
dialog \ | ||
software-properties-common \ | ||
tmux \ | ||
wget | ||
|
||
# Setup environment | ||
ENV \ | ||
LANG=en_US.UTF-8 \ | ||
DEBIAN_FRONTEND=noninteractive \ | ||
TERM=xterm | ||
RUN apt-get update && apt-get install -y locales | ||
RUN locale-gen en_US.UTF-8 | ||
|
||
# install bootstrap tools | ||
RUN apt-get update && apt-get install --no-install-recommends -y \ | ||
ros-${ROS_DISTRO}-gazebo-* \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn | ||
|
||
# Setup sources.list for ROS | ||
RUN echo "deb http://packages.ros.org/ros/ubuntu bionic main" > /etc/apt/sources.list.d/ros-latest.list | ||
|
||
# Setup keys for ROS | ||
RUN apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 | ||
|
||
# Setup sources.list for Gazebo | ||
RUN echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable bionic main" > /etc/apt/sources.list.d/gazebo-stable.list | ||
|
||
# Setup keys for Gazebo | ||
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D2486D2DD83DB69272AFE98867170598AF249743 | ||
|
||
# Install bootstrap tools | ||
RUN apt-get update && apt-get install --no-install-recommends -y \ | ||
python-rosdep \ | ||
python-rosinstall \ | ||
python3-vcstool | ||
|
||
# Install ROS packages | ||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
gazebo9 \ | ||
libgazebo9-dev | ||
|
||
RUN apt-get clean -y && \ | ||
apt-get autoremove -y && \ | ||
apt-get autoclean -y && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
rm -rf /usr/share/doc | ||
|
||
# Install dependencies for gscam and visual odometry | ||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
gstreamer1.0-tools \ | ||
libgstreamer1.0-dev \ | ||
libgstreamer-plugins-base1.0-dev \ | ||
libgstreamer-plugins-good1.0-dev | ||
|
||
# Install ROS dependencies | ||
RUN apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get install -y \ | ||
ros-${ROS_DISTRO}-amcl \ | ||
ros-${ROS_DISTRO}-camera-calibration \ | ||
ros-${ROS_DISTRO}-controller-manager \ | ||
ros-${ROS_DISTRO}-ecl-threads \ | ||
ros-${ROS_DISTRO}-gazebo-ros-pkgs \ | ||
ros-${ROS_DISTRO}-joint-state-publisher \ | ||
ros-${ROS_DISTRO}-joy-teleop \ | ||
ros-${ROS_DISTRO}-map-server \ | ||
ros-${ROS_DISTRO}-move-base \ | ||
ros-${ROS_DISTRO}-pcl-ros \ | ||
ros-${ROS_DISTRO}-robot-localization \ | ||
ros-${ROS_DISTRO}-robot-state-publisher \ | ||
ros-${ROS_DISTRO}-yocs-controllers \ | ||
ros-${ROS_DISTRO}-xacro \ | ||
&& \ | ||
apt-get clean && \ | ||
apt-get autoremove && \ | ||
apt-get autoclean && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
rm -rf /usr/share/doc | ||
|
||
# Compile RTIMULib2 and IMU dependencies | ||
RUN mkdir -p /home/${USER}/catkin_ws/src | ||
WORKDIR /home/${USER}/catkin_ws/src | ||
RUN git clone https://github.com/RoboticaUtnFrba/RTIMULib2.git && \ | ||
git clone https://github.com/RoboticaUtnFrba/i2c_imu.git | ||
WORKDIR /home/${USER}/catkin_ws/src/RTIMULib2/Linux | ||
RUN apt-get update && apt-get install -y libqt4-dev | ||
RUN mkdir build && \ | ||
cd build && \ | ||
cmake .. && \ | ||
make -j4 && \ | ||
make install && \ | ||
ldconfig | ||
|
||
ENV PATH /usr/local/nvidia/bin:${PATH} | ||
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64:${LD_LIBRARY_PATH} | ||
|
||
RUN echo ". /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/${USER}/.bashrc | ||
|
||
WORKDIR /home/${USER}/catkin_ws | ||
|
||
CMD [ "tmux" ] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM create_ros_melodic | ||
LABEL maintainer="Emiliano Borghi" | ||
|
||
ENV ROS1_DISTRO=melodic | ||
|
||
USER root | ||
|
||
# Setup sources.list for Gazebo | ||
RUN echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable bionic main" > /etc/apt/sources.list.d/gazebo-stable.list | ||
|
||
# Setup keys for Gazebo | ||
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D2486D2DD83DB69272AFE98867170598AF249743 | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
gazebo9 \ | ||
libgazebo9-dev \ | ||
ros-$ROS1_DISTRO-gazebo-ros-pkgs \ | ||
ros-$ROS1_DISTRO-gazebo-ros-control | ||
|
||
CMD tmux |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM nvidia/opengl:1.0-glvnd-runtime-ubuntu16.04 as nvidia | ||
FROM create_gazebo9 | ||
LABEL maintainer="Emiliano Borghi" | ||
|
||
# Installing OpenGL for nvidia-docker2 | ||
# https://stackoverflow.com/a/53823600 | ||
|
||
COPY --from=nvidia /usr/local /usr/local | ||
COPY --from=nvidia /etc/ld.so.conf.d/glvnd.conf /etc/ld.so.conf.d/glvnd.conf | ||
|
||
ENV NVIDIA_VISIBLE_DEVICES=all NVIDIA_DRIVER_CAPABILITIES=all | ||
|
||
RUN apt-get update | ||
|
||
USER create |
Oops, something went wrong.