Skip to content

Commit

Permalink
Merge pull request #135 from hmakelin/better-builds
Browse files Browse the repository at this point in the history
Use mavros from package index instead of building from source
  • Loading branch information
hmakelin authored Aug 10, 2024
2 parents 7690da3 + 783684c commit 93ea8ad
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 90 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ listener sensor_gps
[5]: https://docs.px4.io/main/en/debug/mavlink_shell.html#qgroundcontrol

## Build and run SITL simulation

Stop all simulation services with the below command:
Finally, you can stop all simulation services with the below command:

```bash
gnc stop
Expand Down
2 changes: 1 addition & 1 deletion debian/gisnav/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

# Change to the directory where the docker-compose.yml is located
cd /etc/gisnav/docker
#cd /etc/gisnav/docker

# The gnc CLI tool should be provided with this package
# We prepare containers here as part of the installation process so that the
Expand Down
8 changes: 8 additions & 0 deletions debian/gisnav/DEBIAN/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@ else
echo "docker command not found. Skipping docker compose down."
fi

# Remove /etc/gisnav folder and all contents
#if [ -d "/etc/gisnav" ]; then
# rm -rf /etc/gisnav
# echo "Successfully removed /etc/gisnav and all its contents."
#else
# echo "/etc/gisnav does not exist. Skipping removal."
#fi

exit 0
47 changes: 17 additions & 30 deletions debian/gisnav/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SHELL := /bin/bash
PACKAGE_NAME = gisnav
BUILD_DIR = build
DIST_DIR = dist
REPO_ROOT_PATH = ../..
REPO_ROOT_PATH = $(shell realpath ../..)
ARCHITECTURE = all

# Get the latest git tag and format the version string
Expand All @@ -28,7 +28,7 @@ all: dist
# Phony target for cleaning the build directory
.PHONY: clean
clean:
@rm -rf $(BUILD_DIR) $(DIST_DIR)
@rm -rf $(MAKEFILE_DIR)$(BUILD_DIR) $(MAKEFILE_DIR)$(DIST_DIR)

.PHONY: distclean
distclean:
Expand Down Expand Up @@ -78,31 +78,18 @@ $(BUILD_DIR)/etc/systemd:
@mkdir -p $@
@cp -r etc/systemd/ $@

# We need to copy .git to make git describe work for the docs (docs are built
# with git version string). pre-commit might also need the .git folder.
# TODO: only copy over a shallow copy of git repo - we do not need entire history
# nor all branches
$(BUILD_DIR)/etc/gisnav: $(BUILD_DIR)/etc/gisnav/ros $(BUILD_DIR)/etc/gisnav/docker $(BUILD_DIR)/etc/gisnav/docs
@dest=debian/gisnav/$@ && \
mkdir -p $@ && \
touch $(BUILD_DIR)/COLCON_IGNORE && \
cd ${REPO_ROOT_PATH}; rsync -av --exclude-from='.gitignore' Makefile .pre-commit-config.yaml LICENSE.md README.md pyproject.toml .git $$dest

$(BUILD_DIR)/etc/gisnav/ros:
@dest=debian/gisnav/$@ && \
mkdir -p $@ && \
touch $(BUILD_DIR)/COLCON_IGNORE && \
cd ${REPO_ROOT_PATH}; rsync -av --exclude-from='.gitignore' ros/ $$dest
@echo -e "\033[1;33;40mWarning! Check the file list above that no unintended files were copied over to the distributable.\033[0m"

$(BUILD_DIR)/etc/gisnav/docker:
@dest=debian/gisnav/$@ && \
mkdir -p $@ && \
cd ${REPO_ROOT_PATH}; rsync -av --exclude-from='.gitignore' docker/ $$dest
@echo -e "\033[1;33;40mWarning! Check the file list above that no unintended files were copied over to the distributable.\033[0m"

$(BUILD_DIR)/etc/gisnav/docs:
@dest=debian/gisnav/$@ && \
mkdir -p $@ && \
touch $(BUILD_DIR)/COLCON_IGNORE && \
cd ${REPO_ROOT_PATH}; rsync -av --exclude-from='.gitignore' docs/ $$dest
# We need a shallow copy of git repo to make git describe work for the docs
# (docs are built with git version string). pre-commit might also need the
# .git folder.
# We also grab any uncommitted changes from the local repo and apply them
# as a patch to the shallow copy, to make development more convenient. We apply
# staged changes first, and then unstaged changes (we create a combined patch
# file)
$(BUILD_DIR)/etc/gisnav:
@mkdir -p $@
@touch $(BUILD_DIR)/COLCON_IGNORE
@git clone --depth 1 file://${REPO_ROOT_PATH} $@
@cd ${REPO_ROOT_PATH} && git diff --cached > /tmp/gisnav-diff.patch \
&& git diff >> /tmp/gisnav-diff.patch
@cd $@ && git apply /tmp/gisnav-diff.patch
@rm -rf /tmp/gisnav-diff.patch
55 changes: 13 additions & 42 deletions docker/mavros/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,29 @@ FROM ros:${ROS_DISTRO} as mavros-msgs
ARG ROS_DISTRO
ENV ROS_DISTRO=${ROS_DISTRO}

# Combine apt update, upgrade and cleaning up in one layer
RUN apt update --fix-missing && \
apt -y upgrade

SHELL ["/bin/bash", "-c"]

WORKDIR /opt/colcon_ws/src/

# Install GeographicLib related dependencies
# Also add universe repository for ROS packages
# tcpdump for health checks
RUN apt-get -y install software-properties-common wget curl tcpdump && \
# Need mavros-extras for the gimbal_control plugin (mavros-extras v2.8+)
RUN apt-get update && \
apt-get -y install software-properties-common wget curl tcpdump && \
add-apt-repository ppa:ubuntugis/ppa && \
add-apt-repository universe && \
apt-get update && \
apt-get -y install gdal-bin libgdal-dev geographiclib-tools && \
geographiclib-get-geoids egm96-5

# Get mavros with gimbal protocol v2 plugin and build mavros_msgs only
# mavros_msgs is needed by both downstream images so it is already built here
# adds an additional custom patch to gps_input.cpp
RUN source /opt/ros/${ROS_DISTRO}/setup.bash && \
git clone --branch 2.8.0 https://github.com/mavlink/mavros.git && \
rosdep update && \
apt-get update && \
rosdep install --from-paths . --ignore-src -y && \
cd .. && \
colcon build --packages-ignore mavros mavros_extras libmavconn && \
sed -i 's/rclcpp::Time last_pos_time;/rclcpp::Time last_pos_time{0, 0, get_clock()->get_clock_type()};/' \
src/mavros/mavros_extras/src/plugins/gps_input.cpp
apt-get -y install gdal-bin libgdal-dev geographiclib-tools ros-${ROS_DISTRO}-mavros ros-${ROS_DISTRO}-mavros-extras && \
geographiclib-get-geoids egm96-5 && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean

RUN mkdir -p /opt/colcon_ws/src

FROM mavros-msgs AS mavros
ARG ROS_DISTRO

WORKDIR /opt/colcon_ws/

COPY mavros/filter_plugins.sh /opt/colcon_ws/src/mavros

# Build mavros and mavros_extras gimbal protocol v2 (gimbal_control) plugin
# We use the filter_plugins.sh script to disable unneeded plugins to significantly
# speed up build time and use of memory.
# mavros_msgs was built earlier so we ignore it here
RUN source /opt/ros/${ROS_DISTRO}/setup.bash \
&& source install/setup.bash \
&& cd src/mavros \
&& ./filter_plugins.sh \
&& cd /opt/colcon_ws/ \
&& colcon build --packages-ignore mavros_msgs

RUN rm -rf /var/lib/apt/lists/* && \
apt clean

COPY mavros/entrypoint.sh /

RUN chmod 755 /entrypoint.sh
Expand Down Expand Up @@ -129,9 +99,10 @@ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | b

COPY Makefile .pre-commit-config.yaml LICENSE.md README.md pyproject.toml /opt/colcon_ws/src/gisnav/

# .git needed to make pre-commit and git describe work
# TODO: solve this in a better way - we have an unnecessarily large git
# history in the container
COPY .git /opt/colcon_ws/src/gisnav/.git
# .git needed to make pre-commit and git describe work. We create a shallow
# copy of the repo to avoid carrying over all of commit history.
COPY .git /tmp/gisnav/.git
RUN git clone --depth 1 /tmp/gisnav/.git /opt/colcon_ws/src/gisnav/.git && \
rm -rf /tmp/gisnav/.git

ENTRYPOINT ["/entrypoint.sh"]
1 change: 0 additions & 1 deletion docker/mavros/mavros/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
set -e

source "/opt/ros/$ROS_DISTRO/setup.bash"
source "/opt/colcon_ws/install/setup.bash" --

exec "$@"
12 changes: 0 additions & 12 deletions docker/mavros/mavros/filter_plugins.sh

This file was deleted.

2 changes: 1 addition & 1 deletion docs/vitepress/docs/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Used to refer to the [vehicle](#vehicle), typically in a [ROS](#ros-ros-2) conte

### Rotation

Most likely rotation of the [reference raster](#reference-reference-image-reference-raster) when aligning it with the [FOV](#fov--fov). This is done in [pose](#pose) estimation because the neural [networks](#network) are not assumed to be rotation agnostic.
Most likely rotation of the [reference raster](#reference-reference-image-reference-raster) when aligning it with the [FOV](#fov-fov). This is done in [pose](#pose) estimation because the neural [networks](#network) are not assumed to be rotation agnostic.

### Service
- A [Docker Compose](#docker-compose) service
Expand Down

0 comments on commit 93ea8ad

Please sign in to comment.