Created
June 4, 2020 05:45
-
-
Save atinfinity/43c33d798a9fd55133d9800c179d6f68 to your computer and use it in GitHub Desktop.
ROS1 navigation on Docker
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
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 melodic | |
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/* | |
# addtional ROS package | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
ros-melodic-amcl \ | |
ros-melodic-slam-gmapping \ | |
ros-melodic-dwa-local-planner \ | |
ros-melodic-turtlebot3 \ | |
ros-melodic-turtlebot3-gazebo \ | |
ros-melodic-turtlebot3-msgs \ | |
ros-melodic-turtlebot3-navigation \ | |
ros-melodic-turtlebot3-slam \ | |
ros-melodic-turtlebot3-teleop \ | |
&& \ | |
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 echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc && \ | |
echo "export TURTLEBOT3_MODEL=waffle" >> ~/.bashrc |
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
#!/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 "melodic" \ | |
ros:melodic \ | |
bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ROS1 navigation on Docker
Requirements
Build Docker image
Create Docker container