Skip to content

Instantly share code, notes, and snippets.

@gabrieleara
Last active August 1, 2019 02:45
Show Gist options
  • Save gabrieleara/c4cb030cf04912ad75f560ee483c344d to your computer and use it in GitHub Desktop.
Save gabrieleara/c4cb030cf04912ad75f560ee483c344d to your computer and use it in GitHub Desktop.
ROS Kinetic container used for my Robotics course
FROM ubuntu:xenial
RUN apt-get update && apt-get install -y software-properties-common
RUN echo "deb http://packages.ros.org/ros/ubuntu xenial main" > /etc/apt/sources.list.d/ros-latest.list && \
apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
RUN apt-get update && \
apt-get install --no-install-recommends -y \
ros-kinetic-desktop-full \
python-rosinstall \
python-rosinstall-generator \
python-wstool \
build-essential \
ros-kinetic-navigation \
ros-kinetic-gmapping \
ros-kinetic-hector-mapping \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -ms /bin/bash gabriele
ADD init_robotics.bash /home/gabriele/init_robotics.bash
RUN chmod a+x /home/gabriele/init_robotics.bash \
&& rosdep init
USER gabriele
ENV HOME /home/gabriele
WORKDIR /home/gabriele
RUN rosdep update && \
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc && \
echo "source /home/gabriele/tb3_ws/devel/setup.bash" >> ~/.bashrc && \
echo 'export TURTLEBOT3_MODEL="burger"' >> ~/.bashrc && \
echo "export QT_X11_NO_MITSHM=1" >> ~/.bashrc
# Remember to launch this image as
# docker run -ti --device=/dev/dri:/dev/dri --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --mount type=bind,source="$HOME/Documents/Robotics/workspace",target=/home/gabriele/tb3_ws gabrieleara/robotics
# And the first run execute init_robotics.bash
#!/bin/bash
set -e
docker exec -ti $(docker container list -q) bash
#!/bin/bash
source /opt/ros/kinetic/setup.bash
mkdir -p ~/tb3_ws/src
cd ~/tb3_ws/src
catkin_init_workspace
cd ..
catkin_make
source devel/setup.bash
cd src
git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
git clone https://github.com/ros-teleop/teleop_twist_keyboard.git
cd ..
catkin_make
sed -i 's:<visualize>:<!--visualize>:g' ~/tb3_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_burger.gazebo.xacro
sed -i 's:<\/visualize>:</visualize-->:g' ~/tb3_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_burger.gazebo.xacro
sed -i 's:<visualize>:<!--visualize>:g' ~/tb3_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_waffle.gazebo.xacro
sed -i 's:<\/visualize>:</visualize-->:g' ~/tb3_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_waffle.gazebo.xacro
perl -pi -e 's#(<pose>)(\s*\$)\((?:arg\s+)([\s\w\_]+)\)(\s*\$)\((?:arg\s+)([\s\w\_]+)\)(\s*\$)\((?:arg\s+)([\s\w\_]+)\)([\s0]+)(<\/pose>)#$1$2\{$3\}$4\{$5\}$6\{$7\}$8$9#g' ~/tb3_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_waffle.gazebo.xacro
perl -pi -e 's#(<pose>)(\s*\$)\((?:arg\s+)([\s\w\_]+)\)([\s0]+)(<\/pose>)#$1$2\{$3\}$4$5#g' ~/tb3_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_waffle.gazebo.xacro
catkin_make
mkdir -p ~/.gazebo/
cp -r ~/tb3_ws/src/turtlebot3_simulations/turtlebot3_gazebo/models ~/.gazebo/
set -e
mkdir -p ~/Documents/Robotics/workspace
docker pull gabrieleara/robotics
docker run -ti --device=/dev/dri:/dev/dri --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --mount type=bind,source="$HOME/Documents/Robotics/workspace",target=/home/gabriele/tb3_ws gabrieleara/robotics "./init_robotics.bash"
rm -- "$0"
#!/bin/bash
set -e
docker run -ti --device=/dev/dri:/dev/dri --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --network host --mount type=bind,source="$HOME/Documents/Robotics/workspace",target=/home/gabriele/tb3_ws gabrieleara/robotics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment