Skip to content

Instantly share code, notes, and snippets.

@atinfinity
Last active April 29, 2020 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atinfinity/2e82266600e7ea5cdd5e9bfbc2b1d80d to your computer and use it in GitHub Desktop.
Save atinfinity/2e82266600e7ea5cdd5e9bfbc2b1d80d to your computer and use it in GitHub Desktop.
mpc_local_planner on Docker
FROM nvidia/cudagl:10.2-devel-ubuntu18.04
ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
# add new sudo user
ENV USERNAME mpc
ENV HOME /home/$USERNAME
RUN useradd -m $USERNAME && \
echo "$USERNAME:$USERNAME" | chpasswd && \
usermod --shell /bin/bash $USERNAME && \
usermod -aG sudo $USERNAME && \
mkdir /etc/sudoers.d && \
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME && \
# Replace 1000 with your user/group id
usermod --uid 1000 $USERNAME && \
groupmod --gid 1000 $USERNAME
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
sudo \
less \
emacs \
tmux \
bash-completion \
command-not-found \
software-properties-common \
xsel \
xdg-user-dirs \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# ROS Melodic
RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
RUN apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
RUN apt-get update && apt-get install -y --no-install-recommends \
ros-melodic-desktop-full \
python-rosdep \
python-rosinstall \
python-rosinstall-generator \
python-wstool \
build-essential \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# ROS package
RUN apt-get update && apt-get install -y --no-install-recommends \
ros-melodic-move-base \
ros-melodic-map-server \
ros-melodic-amcl \
ros-melodic-global-planner \
ros-melodic-costmap-converter \
ros-melodic-mbf-costmap-core \
ros-melodic-mbf-msgs \
ros-melodic-teb-local-planner \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# package for mpc_local_planner
RUN apt-get update && apt-get install -y --no-install-recommends \
coinor-libipopt-dev \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN rosdep init
USER $USERNAME
WORKDIR /home/$USERNAME
RUN rosdep update
SHELL ["/bin/bash", "-c"]
RUN git clone https://github.com/rst-tu-dortmund/control_box_rst.git -b 0.0.4 && \
cd control_box_rst && \
mkdir build && \
cd build && \
cmake -D CMAKE_BUILD_TYPE=Release .. && \
make -j4 && \
sudo make install && \
mkdir -p ~/catkin_ws/src && \
source /opt/ros/melodic/setup.bash && \
catkin_init_workspace ~/catkin_ws/src && \
cd ~/catkin_ws/src && \
git clone https://github.com/rst-tu-dortmund/mpc_local_planner.git -b 0.0.2 && \
cd ~/catkin_ws && \
catkin_make -DCMAKE_BUILD_TYPE=Release && \
source ~/catkin_ws/devel/setup.bash
RUN echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc && \
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
#!/bin/sh
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
touch $XAUTH
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
docker run --runtime=nvidia --privileged --rm -it \
--volume=$XSOCK:$XSOCK:rw \
--volume=$XAUTH:$XAUTH:rw \
--volume=$HOME:$HOME \
--shm-size=1gb \
--env="XAUTHORITY=${XAUTH}" \
--env="DISPLAY=${DISPLAY}" \
--env=TERM=xterm-256color \
--env=QT_X11_NO_MITSHM=1 \
--net=host \
-u "mpc" \
mpc:0.0.2 \
bash
@atinfinity
Copy link
Author

atinfinity commented Apr 29, 2020

mpc_local_planner on Docker

Introduction

This is a Dockerfile to use mpc_local_planner on Docker container.

Requirements

  • NVIDIA graphics driver
  • Docker
  • nvidia-docker2

Preparation

Build Docker image

$ docker build -t mpc:0.0.2 .

Create Docker container

$ ./launch_container.sh

Usage

Launch mpc_local_planner_examples

Please launch mpc_local_planner_examples and set goal using RViz.

$ roslaunch mpc_local_planner_examples diff_drive_quadratic_form.launch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment