Skip to content

Commit 93ea8ad

Browse files
authored
Merge pull request #135 from hmakelin/better-builds
Use mavros from package index instead of building from source
2 parents 7690da3 + 783684c commit 93ea8ad

File tree

8 files changed

+41
-90
lines changed

8 files changed

+41
-90
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ listener sensor_gps
8585
8686
[5]: https://docs.px4.io/main/en/debug/mavlink_shell.html#qgroundcontrol
8787

88-
## Build and run SITL simulation
89-
90-
Stop all simulation services with the below command:
88+
Finally, you can stop all simulation services with the below command:
9189

9290
```bash
9391
gnc stop

debian/gisnav/DEBIAN/postinst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

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

77
# The gnc CLI tool should be provided with this package
88
# We prepare containers here as part of the installation process so that the

debian/gisnav/DEBIAN/postrm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,12 @@ else
3030
echo "docker command not found. Skipping docker compose down."
3131
fi
3232

33+
# Remove /etc/gisnav folder and all contents
34+
#if [ -d "/etc/gisnav" ]; then
35+
# rm -rf /etc/gisnav
36+
# echo "Successfully removed /etc/gisnav and all its contents."
37+
#else
38+
# echo "/etc/gisnav does not exist. Skipping removal."
39+
#fi
40+
3341
exit 0

debian/gisnav/Makefile

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ SHELL := /bin/bash
88
PACKAGE_NAME = gisnav
99
BUILD_DIR = build
1010
DIST_DIR = dist
11-
REPO_ROOT_PATH = ../..
11+
REPO_ROOT_PATH = $(shell realpath ../..)
1212
ARCHITECTURE = all
1313

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

3333
.PHONY: distclean
3434
distclean:
@@ -78,31 +78,18 @@ $(BUILD_DIR)/etc/systemd:
7878
@mkdir -p $@
7979
@cp -r etc/systemd/ $@
8080

81-
# We need to copy .git to make git describe work for the docs (docs are built
82-
# with git version string). pre-commit might also need the .git folder.
83-
# TODO: only copy over a shallow copy of git repo - we do not need entire history
84-
# nor all branches
85-
$(BUILD_DIR)/etc/gisnav: $(BUILD_DIR)/etc/gisnav/ros $(BUILD_DIR)/etc/gisnav/docker $(BUILD_DIR)/etc/gisnav/docs
86-
@dest=debian/gisnav/$@ && \
87-
mkdir -p $@ && \
88-
touch $(BUILD_DIR)/COLCON_IGNORE && \
89-
cd ${REPO_ROOT_PATH}; rsync -av --exclude-from='.gitignore' Makefile .pre-commit-config.yaml LICENSE.md README.md pyproject.toml .git $$dest
90-
91-
$(BUILD_DIR)/etc/gisnav/ros:
92-
@dest=debian/gisnav/$@ && \
93-
mkdir -p $@ && \
94-
touch $(BUILD_DIR)/COLCON_IGNORE && \
95-
cd ${REPO_ROOT_PATH}; rsync -av --exclude-from='.gitignore' ros/ $$dest
96-
@echo -e "\033[1;33;40mWarning! Check the file list above that no unintended files were copied over to the distributable.\033[0m"
97-
98-
$(BUILD_DIR)/etc/gisnav/docker:
99-
@dest=debian/gisnav/$@ && \
100-
mkdir -p $@ && \
101-
cd ${REPO_ROOT_PATH}; rsync -av --exclude-from='.gitignore' docker/ $$dest
102-
@echo -e "\033[1;33;40mWarning! Check the file list above that no unintended files were copied over to the distributable.\033[0m"
103-
104-
$(BUILD_DIR)/etc/gisnav/docs:
105-
@dest=debian/gisnav/$@ && \
106-
mkdir -p $@ && \
107-
touch $(BUILD_DIR)/COLCON_IGNORE && \
108-
cd ${REPO_ROOT_PATH}; rsync -av --exclude-from='.gitignore' docs/ $$dest
81+
# We need a shallow copy of git repo to make git describe work for the docs
82+
# (docs are built with git version string). pre-commit might also need the
83+
# .git folder.
84+
# We also grab any uncommitted changes from the local repo and apply them
85+
# as a patch to the shallow copy, to make development more convenient. We apply
86+
# staged changes first, and then unstaged changes (we create a combined patch
87+
# file)
88+
$(BUILD_DIR)/etc/gisnav:
89+
@mkdir -p $@
90+
@touch $(BUILD_DIR)/COLCON_IGNORE
91+
@git clone --depth 1 file://${REPO_ROOT_PATH} $@
92+
@cd ${REPO_ROOT_PATH} && git diff --cached > /tmp/gisnav-diff.patch \
93+
&& git diff >> /tmp/gisnav-diff.patch
94+
@cd $@ && git apply /tmp/gisnav-diff.patch
95+
@rm -rf /tmp/gisnav-diff.patch

docker/mavros/Dockerfile

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,29 @@ FROM ros:${ROS_DISTRO} as mavros-msgs
44
ARG ROS_DISTRO
55
ENV ROS_DISTRO=${ROS_DISTRO}
66

7-
# Combine apt update, upgrade and cleaning up in one layer
8-
RUN apt update --fix-missing && \
9-
apt -y upgrade
10-
117
SHELL ["/bin/bash", "-c"]
128

13-
WORKDIR /opt/colcon_ws/src/
14-
159
# Install GeographicLib related dependencies
1610
# Also add universe repository for ROS packages
1711
# tcpdump for health checks
18-
RUN apt-get -y install software-properties-common wget curl tcpdump && \
12+
# Need mavros-extras for the gimbal_control plugin (mavros-extras v2.8+)
13+
RUN apt-get update && \
14+
apt-get -y install software-properties-common wget curl tcpdump && \
1915
add-apt-repository ppa:ubuntugis/ppa && \
2016
add-apt-repository universe && \
2117
apt-get update && \
22-
apt-get -y install gdal-bin libgdal-dev geographiclib-tools && \
23-
geographiclib-get-geoids egm96-5
24-
25-
# Get mavros with gimbal protocol v2 plugin and build mavros_msgs only
26-
# mavros_msgs is needed by both downstream images so it is already built here
27-
# adds an additional custom patch to gps_input.cpp
28-
RUN source /opt/ros/${ROS_DISTRO}/setup.bash && \
29-
git clone --branch 2.8.0 https://github.com/mavlink/mavros.git && \
30-
rosdep update && \
31-
apt-get update && \
32-
rosdep install --from-paths . --ignore-src -y && \
33-
cd .. && \
34-
colcon build --packages-ignore mavros mavros_extras libmavconn && \
35-
sed -i 's/rclcpp::Time last_pos_time;/rclcpp::Time last_pos_time{0, 0, get_clock()->get_clock_type()};/' \
36-
src/mavros/mavros_extras/src/plugins/gps_input.cpp
18+
apt-get -y install gdal-bin libgdal-dev geographiclib-tools ros-${ROS_DISTRO}-mavros ros-${ROS_DISTRO}-mavros-extras && \
19+
geographiclib-get-geoids egm96-5 && \
20+
rm -rf /var/lib/apt/lists/* && \
21+
apt-get clean
3722

23+
RUN mkdir -p /opt/colcon_ws/src
3824

3925
FROM mavros-msgs AS mavros
4026
ARG ROS_DISTRO
4127

4228
WORKDIR /opt/colcon_ws/
4329

44-
COPY mavros/filter_plugins.sh /opt/colcon_ws/src/mavros
45-
46-
# Build mavros and mavros_extras gimbal protocol v2 (gimbal_control) plugin
47-
# We use the filter_plugins.sh script to disable unneeded plugins to significantly
48-
# speed up build time and use of memory.
49-
# mavros_msgs was built earlier so we ignore it here
50-
RUN source /opt/ros/${ROS_DISTRO}/setup.bash \
51-
&& source install/setup.bash \
52-
&& cd src/mavros \
53-
&& ./filter_plugins.sh \
54-
&& cd /opt/colcon_ws/ \
55-
&& colcon build --packages-ignore mavros_msgs
56-
57-
RUN rm -rf /var/lib/apt/lists/* && \
58-
apt clean
59-
6030
COPY mavros/entrypoint.sh /
6131

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

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

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

137108
ENTRYPOINT ["/entrypoint.sh"]

docker/mavros/mavros/entrypoint.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
set -e
33

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

76
exec "$@"

docker/mavros/mavros/filter_plugins.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

docs/vitepress/docs/glossary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ Used to refer to the [vehicle](#vehicle), typically in a [ROS](#ros-ros-2) conte
284284

285285
### Rotation
286286

287-
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.
287+
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.
288288

289289
### Service
290290
- A [Docker Compose](#docker-compose) service

0 commit comments

Comments
 (0)