Skip to content

Commit

Permalink
Merge pull request #20 from IOES-Lab/ardusub_install
Browse files Browse the repository at this point in the history
Ardusub install
  • Loading branch information
woensug-choi authored Oct 23, 2024
2 parents 105fa19 + 98cc9a9 commit ab6935c
Show file tree
Hide file tree
Showing 9 changed files with 297 additions and 47 deletions.
81 changes: 70 additions & 11 deletions .docker/jazzy.amd64.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@ RUN apt-get update && \
curl wget git build-essential cmake cppcheck \
gnupg libeigen3-dev libgles2-mesa-dev \
lsb-release pkg-config protobuf-compiler \
python3-dbg python3-pip python3-venv \
python3-dbg python3-pip python3-venv python3-pexpect \
python-is-python3 python3-future python3-wxgtk4.0 \
qtbase5-dev ruby dirmngr gnupg2 nano xauth \
software-properties-common htop libtool \
x11-apps mesa-utils bison flex automake && \
rm -rf /var/lib/apt/lists/
x11-apps mesa-utils bison flex automake \
&& rm -rf /var/lib/apt/lists/

# Prereqs for Ardupilot - Ardusub
ADD --chown=root:root --chmod=0644 https://raw.githubusercontent.com/osrf/osrf-rosdep/master/gz/00-gazebo.list /etc/ros/rosdep/sources.list.d/00-gazebo.list
RUN wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null \
&& apt-get update && apt-get install -y --no-install-recommends \
libgz-sim8-dev rapidjson-dev libopencv-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-gl \
&& rm -rf /var/lib/apt/lists/

# Locale for UTF-8
RUN truncate -s0 /tmp/preseed.cfg && \
Expand Down Expand Up @@ -42,8 +53,17 @@ ADD https://raw.githubusercontent.com/IOES-Lab/dave/$BRANCH/\
extras/ros-jazzy-binary-gz-harmonic-source-install.sh install.sh
RUN bash install.sh

# Install Ardupilot - Ardusub
ADD https://raw.githubusercontent.com/IOES-Lab/dave/$BRANCH/\
extras/ardusub-ubuntu-install.sh install.sh
RUN bash install.sh
# Install mavros
ADD https://raw.githubusercontent.com/IOES-Lab/dave/$BRANCH/\
extras/mavros-ubuntu-install.sh install.sh
RUN bash install.sh

# Set up Dave workspace
ENV DAVE_WS=/opt/ws_dave
ENV DAVE_WS=/opt/dave_ws
WORKDIR $DAVE_WS/src

ADD https://raw.githubusercontent.com/IOES-Lab/dave/$BRANCH/\
Expand All @@ -62,17 +82,56 @@ RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" && \

# source entrypoint setup
RUN touch /ros_entrypoint.sh && sed --in-place --expression \
'$i source "/opt/ws_dave/install/setup.bash"' /ros_entrypoint.sh
'$i source "/opt/dave_ws/install/setup.bash"' /ros_entrypoint.sh \
&& sed --in-place --expression \
'$i cd /root' /ros_entrypoint.sh

RUN cp /home/docker/.bashrc ~/.bashrc

# Source ROS and Gazebo
RUN sed --in-place --expression \
'$i source "/opt/ros/jazzy/setup.bash"' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i source "/opt/gazebo/install/setup.bash"' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i export PYTHONPATH=$PYTHONPATH:/opt/gazebo/install/lib/python' /ros_entrypoint.sh

# Set User as user
USER $USER
RUN echo "source /opt/ros/jazzy/setup.bash" >> ~/.bashrc && \
echo "source /opt/gazebo/install/setup.bash" >> ~/.bashrc
'$i source "/opt/mavros/install/setup.bash"' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i export GEOGRAPHICLIB_GEOID_PATH=/usr/local/share/GeographicLib/geoids' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i export PYTHONPATH=\$PYTHONPATH:/opt/gazebo/install/lib/python' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i export PATH=/opt/ardupilot_dave/ardupilot/build/sitl/bin:\$PATH' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i export PATH=/opt/ardupilot_dave/ardupilot/Tools/autotest:\$PATH' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i export GZ_SIM_SYSTEM_PLUGIN_PATH=/opt/ardupilot_dave/ardupilot_gazebo/build:\$GZ_SIM_SYSTEM_PLUGIN_PATH' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i export GZ_SIM_RESOURCE_PATH=/opt/ardupilot_dave/ardupilot_gazebo/models:/opt/ardupilot_dave/ardupilot_gazebo/worlds:\$GZ_SIM_RESOURCE_PATH' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i printf '\''\\033[1;37m \n=====\n'\'' ' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i printf '\'' ____ ___ _______ _ _ _ \n'\'' ' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i printf '\'' | _ \\ / \\ \\ / | ____| / \\ __ _ _ _ __ _| |_(_) ___ \n'\'' ' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i printf '\'' | | | |/ _ \\ \\ / /| _| / _ \\ / _` | | | |/ _` | __| |/ __|\n'\'' ' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i printf '\'' | |_| / ___ \\ V / | |___ / ___ \\ (_| | |_| | (_| | |_| | (__ \n'\'' ' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i printf '\'' |____/_/ \\_\\_/ |_____| /_/ \\_\\__, |\\__,_|\\__,_|\\__|_|\\___|\n'\'' ' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i printf '\'' __ ___ _ _ _____ _ \n'\'' ' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i printf '\'' \\ \\ / (_)_ __| |_ _ _ __ _| | | ____|_ ____ _(_)_ __ \n'\'' ' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i printf '\'' \\ \\ / /| | `__| __| | | |/ _` | | | _| | `_ \\ \\ / | | `__| \n'\'' ' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i printf '\'' \\ V / | | | | |_| |_| | (_| | | | |___| | | \\ V /| | |_ \n'\'' ' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i printf '\'' \\_/ |_|_| \\__|\\__,_|\\__,_|_| |_____|_| |_|\\_/ |_|_(_) \n\\033[0m'\'' ' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i printf '\''\\033[1;32m\n =====\\033[0m\n'\'' ' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i printf '\''\\033[1;32m 👋 Hi! This is Docker virtual environment for DAVE\n\\033[0m'\'' ' /ros_entrypoint.sh && \
sed --in-place --expression \
'$i printf '\''\\033[1;33m\tROS2 Jazzy - Gazebo Harmonic (w ardupilot(ardusub) + mavros)\n\n\\033[0m'\'' ' /ros_entrypoint.sh
91 changes: 63 additions & 28 deletions .docker/jazzy.arm64v8.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

# Using the pre-built image for above commented out dockerfile code lines
# hadolint ignore=DL3007
FROM --platform=linux/arm64 woensugchoi/ubuntu-arm-rdp-base:latest
FROM woensugchoi/ubuntu-arm-rdp-base:latest
ARG USER=docker

# ROS-Gazebo arg
Expand All @@ -90,25 +90,24 @@ ADD https://raw.githubusercontent.com/IOES-Lab/dave/$BRANCH/\
extras/ros-jazzy-binary-gz-harmonic-source-install.sh install.sh
RUN bash install.sh

# Set up Dave workspace
ENV ROS_UNDERLAY=/home/$USER/dave_ws/install
WORKDIR $ROS_UNDERLAY/../src

# Prereqs for Ardupilot - Ardusub
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN=true
# hadolint ignore=DL3008
ADD --chown=root:root --chmod=0644 https://raw.githubusercontent.com/osrf/osrf-rosdep/master/gz/00-gazebo.list /etc/ros/rosdep/sources.list.d/00-gazebo.list
RUN wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null \
&& apt-get -q update && \
apt-get install -y --no-install-recommends \
python-is-python3 python3-future python3-wxgtk4.0 python3-pexpect \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
libgz-sim8-dev rapidjson-dev libopencv-dev libasio-dev \
gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-gl \
&& rm -rf /var/lib/apt/lists/
# Install mavros
ADD https://raw.githubusercontent.com/IOES-Lab/dave/$BRANCH/\
extras/repos/dave.$ROS_DISTRO.repos /home/$USER/ws_dave/dave.repos
RUN vcs import --shallow --input "/home/$USER/ws_dave/dave.repos"

RUN rosdep init && \
rosdep update --rosdistro $ROS_DISTRO

# hadolint ignore=DL3027
RUN apt update && apt --fix-broken install && \
rosdep update && rosdep install -iy --from-paths . && \
rm -rf /var/lib/apt/lists/

WORKDIR $ROS_UNDERLAY/..
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" && \
colcon build
extras/mavros-ubuntu-install.sh install.sh
RUN bash install.sh

# Download the background image from GitHub raw content URL
# hadolint ignore=DL3047
Expand All @@ -122,31 +121,67 @@ extras/background.png && \
cp /usr/share/backgrounds/warty-final-ubuntu.png \
/usr/share/backgrounds/ubuntu-wallpaper-d.png

# source entrypoint setup
RUN touch /ros_entrypoint.sh && sed --in-place --expression \
'$i source "$ROS_UNDERLAY/setup.bash"' /ros_entrypoint.sh
# Install Ardupilot - Ardusub
USER docker
RUN wget -O /tmp/install.sh https://raw.githubusercontent.com/IOES-Lab/dave/$BRANCH/extras/ardusub-ubuntu-install-local.sh
RUN chmod +x /tmp/install.sh && bash /tmp/install.sh

# Set up Dave workspace
ENV DAVE_UNDERLAY=/home/$USER/dave_ws
WORKDIR $DAVE_UNDERLAY/src
RUN wget -O /home/$USER/dave_ws/dave.repos -q https://raw.githubusercontent.com/IOES-Lab/dave/$BRANCH/\
extras/repos/dave.$ROS_DISTRO.repos
RUN vcs import --shallow --input "/home/$USER/dave_ws/dave.repos"

# hadolint ignore=DL3027
RUN sudo apt update && sudo apt --fix-broken install && \
sudo rosdep init && rosdep update --rosdistro $ROS_DISTRO && \
rosdep install --rosdistro $ROS_DISTRO -iy --from-paths . && \
sudo rm -rf /var/lib/apt/lists/

# Build dave workspace
WORKDIR $DAVE_UNDERLAY
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" && colcon build

# Set User as user
USER docker
RUN echo "source /opt/ros/jazzy/setup.bash" >> ~/.bashrc && \
echo "source /opt/gazebo/install/setup.bash" >> ~/.bashrc && \
echo "export PYTHONPATH=$PYTHONPATH:/opt/gazebo/install/lib/python" >> ~/.bashrc && \
echo "if [ -d ~/HOST ]; then chown docker:docker ~/HOST; fi" \
>> ~/.bashrc
echo "source /opt/mavros/install/setup.bash" >> ~/.bashrc && \
echo "source $DAVE_UNDERLAY/install/setup.bash" >> ~/.bashrc && \
echo "export GEOGRAPHICLIB_GEOID_PATH=/usr/local/share/GeographicLib/geoids" >> ~/.bashrc && \
echo "export PYTHONPATH=\$PYTHONPATH:/opt/gazebo/install/lib/python" >> ~/.bashrc && \
echo "export PATH=/home/$USER/ardupilot_dave/ardupilot/Tools/autotest:\$PATH" >> ~/.bashrc && \
echo "export PATH=/home/$USER/ardupilot_dave/ardupilot/build/sitl/bin:\$PATH" >> ~/.bashrc && \
echo "export GZ_SIM_SYSTEM_PLUGIN_PATH=/home/$USER/ardupilot_dave/ardupilot_gazebo/build:\$GZ_SIM_SYSTEM_PLUGIN_PATH" >> ~/.bashrc && \
echo "export GZ_SIM_RESOURCE_PATH=/home/$USER/ardupilot_dave/ardupilot_gazebo/models:/home/$USER/ardupilot_dave/ardupilot_gazebo/worlds:\$GZ_SIM_RESOURCE_PATH" >> ~/.bashrc && \
echo "\n\n" >> ~/.bashrc && echo "if [ -d ~/HOST ]; then chown $USER:$USER ~/HOST; fi" >> ~/.bashrc && \
echo "\n\n" >> ~/.bashrc

# Other environment variables
RUN echo "export XDG_RUNTIME_DIR=~/.xdg_log" >> ~/.bashrc && \
echo "unset SESSION_MANAGER" >> ~/.bashrc

# Create and write the welcome message to a new file
RUN mkdir -p /home/docker/.config/autostart && \
printf '\033[1;37m =====\n' >> ~/.hi && \
printf ' ____ ___ _______ _ _ _ \n' >> ~/.hi && \
printf ' | _ \ / \ \ / | ____| / \ __ _ _ _ __ _| |_(_) ___ \n' >> ~/.hi && \
printf ' | | | |/ _ \ \ / /| _| / _ \ / _` | | | |/ _` | __| |/ __|\n' >> ~/.hi && \
printf ' | |_| / ___ \ V / | |___ / ___ | (_| | |_| | (_| | |_| | (__ \n' >> ~/.hi && \
printf ' |____/_/ \_\_/ |_____| /_/ \_\__, |\__,_|\__,_|\__|_|\___|\n' >> ~/.hi && \
printf ' __ ___ _ _ _____ _ \n' >> ~/.hi && \
printf ' \ \ / (_)_ __| |_ _ _ __ _| | | ____|_ ____ _(_)_ __ \n' >> ~/.hi && \
printf ' \ \ / /| | `__| __| | | |/ _` | | | _| | `_ \ \ / | | `__| \n' >> ~/.hi && \
printf ' \ V / | | | | |_| |_| | (_| | | | |___| | | \ V /| | |_ \n' >> ~/.hi && \
printf ' \_/ |_|_| \__|\__,_|\__,_|_| |_____|_| |_|\_/ |_|_(_) \n\033[0m' >> ~/.hi && \
printf '\033[1;32m\n =====\n\033[0m' >> ~/.hi && \
printf "\\033[1;32m 👋 Hi! This is Docker virtual environment\n\\033[0m" \
printf "\\033[1;32m 👋 Hi! This is Docker virtual environment for DAVE\n\\033[0m" \
>> ~/.hi && \
printf "\\033[1;33m\tROS2 Jazzy - Gazebo Harmonic\n\n\n\\033[0m" \
printf "\\033[1;33m\tROS2 Jazzy - Gazebo Harmonic (w ardupilot(ardusub) + mavros)\n\n\n\\033[0m" \
>> ~/.hi

# Remove sudo message
# Remove sudo message
RUN touch /home/docker/.sudo_as_admin_successful

# Autostart terminal
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
env:
IMAGE_NAME: ${{ github.repository }}
ROS_DISTRO: jazzy
BRANCH: ros2
BRANCH: ${{ github.ref_name }}

jobs:
build-and-push-to-docker-hub:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-arm64v8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
env:
IMAGE_NAME: ${{ github.repository }}
ROS_DISTRO: jazzy
BRANCH: ros2
BRANCH: ${{ github.ref_name }}

jobs:
build-and-push-to-docker-hub:
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ repos:

# Spellcheck in comments and docs
# skipping of *.svg files is not working...
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: ["--write-changes", "--uri-ignore-words-list=ist", "-L manuel"]
exclude: CHANGELOG\.rst|\.(svg|pyc|drawio)$
# - repo: https://github.com/codespell-project/codespell
# rev: v2.3.0
# hooks:
# - id: codespell
# args: ["--write-changes", "--uri-ignore-words-list=ist", "-L manuel"]
# exclude: CHANGELOG\.rst|\.(svg|pyc|drawio)$

# Json lint
- repo: https://github.com/python-jsonschema/check-jsonschema
Expand Down
47 changes: 47 additions & 0 deletions extras/ardusub-ubuntu-install-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# Source Ros and Gazebo
# shellcheck source=/dev/null
source /opt/ros/jazzy/setup.bash
# shellcheck source=/dev/null
source /opt/gazebo/install/setup.bash

export USER=docker

# Really should do version pinning but Sub-4.5 is waaaay behind master
# (e.g. it doesn't know about "noble" yet)
export ARDUPILOT_RELEASE=master
mkdir -p "/home/$USER/ardupilot_dave" && cd "/home/$USER/ardupilot_dave" || exit
git clone -b $ARDUPILOT_RELEASE https://github.com/ArduPilot/ardupilot.git --recurse-submodules

# Install ArduSub dependencies
cd "/home/$USER/ardupilot_dave/ardupilot" || exit
export SKIP_AP_EXT_ENV=1 SKIP_AP_GRAPHIC_ENV=1 SKIP_AP_COV_ENV=1 SKIP_AP_GIT_CHECK=1
# Do not install the STM development tools
export DO_AP_STM_ENV=0
# Do not activate the Ardupilot venv by default
export DO_PYTHON_VENV_ENV=0
Tools/environment_install/install-prereqs-ubuntu.sh -y

# Build ArduSub
modules/waf/waf-light configure --board sitl \
&& modules/waf/waf-light build --target bin/ardusub

# Clone ardupilot_gazebo code
cd "/home/$USER/ardupilot_dave" || exit
git clone https://github.com/ArduPilot/ardupilot_gazebo.git

# Install ardupilot_gazebo plugin
# Check if the directory creation was successful
mkdir -p "/home/$USER/ardupilot_dave/ardupilot_gazebo/build" \
&& cd "/home/$USER/ardupilot_dave/ardupilot_gazebo/build" || exit
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j2

# Add results of ArduSub build
export PATH=/home/$USER/ardupilot_dave/ardupilot/build/sitl/bin:\$PATH
# Optional: add autotest to the PATH, helpful for running sim_vehicle.py
export PATH=/home/$USER/ardupilot_dave/ardupilot/Tools/autotest:\$PATH
# Add ardupilot_gazebo plugin
export GZ_SIM_SYSTEM_PLUGIN_PATH=/home/$USER/ardupilot_dave/ardupilot_gazebo/build:\$GZ_SIM_SYSTEM_PLUGIN_PATH
# Add ardupilot_gazebo models and worlds
export GZ_SIM_RESOURCE_PATH=/home/$USER/ardupilot_dave/ardupilot_gazebo/models:/home/$USER/ardupilot_dave/ardupilot_gazebo/worlds:\$GZ_SIM_RESOURCE_PATH
45 changes: 45 additions & 0 deletions extras/ardusub-ubuntu-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# Source Ros and Gazebo
# shellcheck source=/dev/null
source /opt/ros/jazzy/setup.bash
# shellcheck source=/dev/null
source /opt/gazebo/install/setup.bash

# Really should do version pinning but Sub-4.5 is waaaay behind master
# (e.g. it doesn't know about "noble" yet)
export ARDUPILOT_RELEASE=master
mkdir -p "/opt/ardupilot_dave" && cd "/opt/ardupilot_dave" || exit
git clone -b $ARDUPILOT_RELEASE https://github.com/ArduPilot/ardupilot.git --recurse-submodules

# Install ArduSub dependencies
cd "/opt/ardupilot_dave/ardupilot" || exit
export SKIP_AP_EXT_ENV=1 SKIP_AP_GRAPHIC_ENV=1 SKIP_AP_COV_ENV=1 SKIP_AP_GIT_CHECK=1
# Do not install the STM development tools
export DO_AP_STM_ENV=0
# Do not activate the Ardupilot venv by default
export DO_PYTHON_VENV_ENV=0
Tools/environment_install/install-prereqs-ubuntu.sh -y

# Build ArduSub
modules/waf/waf-light configure --board sitl \
&& modules/waf/waf-light build --target bin/ardusub

# Clone ardupilot_gazebo code
cd "/opt/ardupilot_dave" || exit
git clone https://github.com/ArduPilot/ardupilot_gazebo.git

# Install ardupilot_gazebo plugin
# Check if the directory creation was successful
mkdir -p "/opt/ardupilot_dave/ardupilot_gazebo/build" \
&& cd "/opt/ardupilot_dave/ardupilot_gazebo/build" || exit
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j2

# Add results of ArduSub build
export PATH=/opt/ardupilot_dave/ardupilot/build/sitl/bin:\$PATH
# Optional: add autotest to the PATH, helpful for running sim_vehicle.py
export PATH=/opt/ardupilot_dave/ardupilot/Tools/autotest:\$PATH
# Add ardupilot_gazebo plugin
export GZ_SIM_SYSTEM_PLUGIN_PATH=/opt/ardupilot_dave/ardupilot_gazebo/build:\$GZ_SIM_SYSTEM_PLUGIN_PATH
# Add ardupilot_gazebo models and worlds
export GZ_SIM_RESOURCE_PATH=/opt/ardupilot_dave/ardupilot_gazebo/models:/opt/ardupilot_dave/ardupilot_gazebo/worlds:\$GZ_SIM_RESOURCE_PATH
Loading

0 comments on commit ab6935c

Please sign in to comment.