ArduPilot Setup on Docker
Building Docker Container
Pull the Docker Image
docker pull osrf/ros:noetic-desktop-fullDockerfile for Building Docker Image
# Use the base image for ROS Noetic Desktop
FROM osrf/ros:noetic-desktop-full
# Set build arguments
ARG USER=ariitk
ARG DEBIAN_FRONTEND=noninteractive
RUN groupadd -r ${USER} && useradd -r -g ${USER} ${USER} && \
mkdir -p /home/${USER} && \
chown -R ${USER}:${USER} /home/${USER} && \
echo ${USER}' ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers && \
chmod 0440 /etc/sudoers
# Set the working directory
WORKDIR /home/${USER}
# Update package lists and install required ROS packages and tools
RUN apt-get update && \
apt-get install -y \
ros-noetic-moveit \
ros-noetic-ros-controllers \
ros-noetic-gazebo-ros-control \
ros-noetic-rosserial \
ros-noetic-rosserial-arduino \
ros-noetic-roboticsgroup-upatras-gazebo-plugins \
ros-noetic-actionlib-tools \
ros-noetic-rqt \
ros-noetic-rqt-common-plugins \
ros-noetic-rqt-robot-plugins \
terminator \
python \
python3 \
python3-pip \
python3-rosdep \
python3-rosinstall \
python3-rosinstall-generator \
python3-wstool \
python3-catkin-tools \
build-essential \
libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly \
libprotobuf-dev \
libprotoc-dev \
protobuf-compiler \
libeigen3-dev \
libxml2-utils \
python3-rospkg \
python3-jinja2 \
ros-noetic-mavros \
ros-noetic-mavros-extras \
ros-noetic-mavlink \
nano \
git \
vim && \
rm -rf /var/lib/apt/lists/*
# Install Gazebo & Meshlab
RUN curl -sSL http://get.gazebosim.org | sh && \
apt-get install -y gazebo11 \
meshlab
# PX4 Install Script
RUN wget https://raw.githubusercontent.com/PX4/PX4-Autopilot/refs/heads/main/Tools/setup/ubuntu.sh && \
wget https://raw.githubusercontent.com/PX4/PX4-Autopilot/refs/heads/main/Tools/setup/requirements.txt && \
chmod +x ubuntu.sh && \
./ubuntu.sh && \
rm ubuntu.sh && \
rm requirements.txt
# Install MAVROS
RUN apt-get install -y ros-noetic-mavros \
ros-noetic-mavros-extras && \
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh && \
chmod +x install_geographiclib_datasets.sh && \
./install_geographiclib_datasets.sh && \
rm install_geographiclib_datasets.sh
# Ardupilot Setup
RUN git clone --recurse-submodules https://github.com/ArduPilot/ardupilot.git /home/${USER}/ardupilot && \
chmod +x /home/${USER}/ardupilot/Tools/environment_install/install-prereqs-ubuntu.sh && \
sed -i "s/sudo //g" /home/${USER}/ardupilot/Tools/environment_install/install-prereqs-ubuntu.sh && \
sed -i "s/exit 1//g" /home/${USER}/ardupilot/Tools/environment_install/install-prereqs-ubuntu.sh && \
/home/${USER}/ardupilot/Tools/environment_install/install-prereqs-ubuntu.sh -y
# Install Python packages
RUN apt-get install -y --reinstall libssl-dev && \
rm -rf /usr/lib/python3/dist-packages/OpenSSL /usr/lib/python3/pyOpenSSL-19.0.0.egg-info && \
pip install flask flask-ask-sdk ask-sdk && \
pip install --upgrade pymavlink MAVProxy && \
pip3 install kconfiglib pyserial && \
pip3 install --user empy && \
pip3 install --user toml && \
pip3 install --user numpy && \
pip3 install --user pandas && \
pip3 install --user jinja2 && \
pip3 install --user pyyaml pyros-genmsg packaging
# Edit .bashrc
RUN echo '#! /bin/bash' >> /home/${USER}/.bashrc && \
echo 'source /opt/ros/noetic/setup.bash' >> /home/${USER}/.bashrc && \
echo 'source /usr/share/gazebo/setup.sh' >> /home/${USER}/.bashrc && \
echo 'export GAZEBO_MODEL_PATH=~/ardupilot_gazebo/models' >> /home/${USER}/.bashrc && \
echo 'export GAZEBO_RESOURCE_PATH=~/ardupilot_gazebo/worlds:${GAZEBO_RESOURCE_PATH}' >> /home/${USER}/.bashrc && \
echo 'export PATH=/usr/lib/ccache:$PATH' >> /home/${USER}/.bashrc && \
echo 'export GAZEBO_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:$GAZEBO_PLUGIN_PATH ' && \
echo 'export GAZEBO_PLUGIN_PATH=/opt/ros/noetic/lib:$GAZEBO_PLUGIN_PATH'
# Switch to the specified user
USER ${USER}Build Docker Image
Make a Shared Directory between Host & Docker Container
Running the Docker Container
Attach to Docker Container
Initial Setup Inside the Container
Test the Docker Container
Save the Initial Changes
Export Docker Image
Using Docker Image
Import Docker Image
Make a Shared Directory between Host & Docker Container
Run Docker Image
Attach to Docker Container
Last updated
Was this helpful?