Skip to content

Commit 91aa077

Browse files
committed
feat(docker): Add docker scripts from gisnav-docker repo
1 parent 65d56a6 commit 91aa077

21 files changed

+1188
-0
lines changed

docker-compose.ardupilot.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: "3.4"
2+
3+
services:
4+
gisnav:
5+
command: bash -c "source ~/colcon_ws/install/setup.bash && ros2 launch gisnav ardupilot.launch.py"

docker-compose.yaml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
version: "3.4"
2+
3+
services:
4+
mapserver:
5+
image: camptocamp/mapserver
6+
network_mode: host
7+
environment:
8+
- NAIP_GDOWN_ID=16M_kbsLpF3t87KC2n9YgqGEBA5h0lG7U
9+
- OSM_GDOWN_ID=1snGYjWxs71m6I-qxKsmUzch_bAfQtrEW
10+
volumes:
11+
- $PWD/mapserver/mapfiles/mapserver.map:/etc/mapserver/mapserver.map:ro
12+
- $PWD/mapserver/setup_mapserver.sh:/etc/mapserver/setup_mapserver.sh:ro
13+
entrypoint: /etc/mapserver/setup_mapserver.sh
14+
15+
mapproxy:
16+
build:
17+
context: docker/mapproxy
18+
dockerfile: Dockerfile
19+
network_mode: host
20+
21+
micro-ros-agent:
22+
image: microros/micro-ros-agent:foxy
23+
command: udp4 -p 8888
24+
network_mode: host
25+
volumes:
26+
- /dev/shm:/dev/shm
27+
28+
mavros:
29+
build:
30+
context: docker/mavros
31+
dockerfile: Dockerfile
32+
environment:
33+
- FASTRTPS_DEFAULT_PROFILES_FILE=/disable_shared_memory.xml
34+
network_mode: host
35+
volumes:
36+
- /dev/shm:/dev/shm
37+
38+
qgc:
39+
build:
40+
context: docker/qgc
41+
dockerfile: Dockerfile
42+
environment:
43+
- QT_X11_NO_MITSHM=1
44+
- DISPLAY=${DISPLAY}
45+
volumes:
46+
- /tmp/.X11-unix:/tmp/.X11-unix:ro
47+
- /dev/shm:/dev/shm
48+
- /dev/dri:/dev/dri
49+
network_mode: host
50+
stdin_open: true
51+
tty: true
52+
53+
gisnav:
54+
build:
55+
context: docker/gisnav
56+
dockerfile: Dockerfile
57+
environment:
58+
- FASTRTPS_DEFAULT_PROFILES_FILE=/disable_shared_memory.xml
59+
volumes:
60+
- /dev/dri:/dev/dri
61+
network_mode: host
62+
stdin_open: true
63+
tty: true
64+
deploy:
65+
resources:
66+
reservations:
67+
devices:
68+
- driver: nvidia
69+
count: 1
70+
capabilities: [ gpu ]
71+
command: bash -c "source /opt/ros/foxy/setup.bash && source ~/colcon_ws/install/setup.bash && ros2 launch gisnav px4.launch.py"
72+
73+
px4:
74+
build:
75+
context: docker/px4
76+
dockerfile: Dockerfile
77+
environment:
78+
- QT_X11_NO_MITSHM=1
79+
- DISPLAY=${DISPLAY}
80+
- GAZEBO_HEADLESS=${GAZEBO_HEADLESS}
81+
volumes:
82+
- /tmp/.X11-unix:/tmp/.X11-unix:ro
83+
- /dev/shm:/dev/shm
84+
- /dev/dri:/dev/dri
85+
network_mode: host
86+
stdin_open: true
87+
tty: true
88+
deploy:
89+
resources:
90+
reservations:
91+
devices:
92+
- driver: nvidia
93+
count: 1
94+
capabilities: [ gpu ]
95+
96+
#ardupilot:
97+
# build:
98+
# context: https://github.com/ArduPilot/ardupilot.git
99+
# dockerfile: https://raw.githubusercontent.com/ArduPilot/ardupilot/master/Dockerfile
100+
101+
ardupilot:
102+
build:
103+
context: docker/ardupilot
104+
dockerfile: Dockerfile
105+
environment:
106+
- QT_X11_NO_MITSHM=1
107+
- DISPLAY=${DISPLAY}
108+
- GAZEBO_HEADLESS=${GAZEBO_HEADLESS}
109+
volumes:
110+
- /tmp/.X11-unix:/tmp/.X11-unix:ro
111+
- /dev/shm:/dev/shm
112+
- /dev/dri:/dev/dri
113+
network_mode: host
114+
stdin_open: true
115+
tty: true
116+
deploy:
117+
resources:
118+
reservations:
119+
devices:
120+
- driver: nvidia
121+
count: 1
122+
capabilities: [ gpu ]
123+
command: bash -c "cd ~ && make gazebo"

docker/ardupilot/Dockerfile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
FROM ros:foxy
2+
3+
LABEL maintainer="Harri Makelin <hmakelin@protonmail.com>"
4+
5+
ARG USERNAME=gisnav
6+
ARG UID=1000
7+
ARG GID=$UID
8+
9+
# Set 'gisnav' as default user and add it to sudo'ers
10+
RUN apt-get update --fix-missing && \
11+
apt-get install -y sudo wget && \
12+
groupadd --gid $GID $USERNAME && useradd --uid $UID --gid $GID -m $USERNAME && \
13+
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME
14+
USER $USERNAME
15+
16+
# Install required tools
17+
RUN sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" \
18+
> /etc/apt/sources.list.d/gazebo-stable.list' && \
19+
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add - && \
20+
sudo apt-get update && \
21+
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git gitk git-gui python3-pip python-is-python3 gazebo11 \
22+
gazebo11-common libgazebo11-dev libgazebo11 ros-foxy-gazebo-ros-pkgs ros-foxy-gazebo-plugins ros-foxy-gazebo-dev \
23+
ros-foxy-gazebo-ros && \
24+
pip install --upgrade pymavlink MAVProxy pexpect
25+
26+
# Clone ArduPilot and update submodules
27+
RUN cd $HOME && \
28+
git clone https://github.com/ArduPilot/ardupilot && \
29+
cd ardupilot && \
30+
git submodule update --init --recursive
31+
32+
# Install ArduPilot prerequisites
33+
# The script requires the USER env variable be set to ${USERNAME}
34+
SHELL ["/bin/bash", "-c"]
35+
RUN cd $HOME/ardupilot/ && \
36+
export USER=$USERNAME && \
37+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y keyboard-configuration && \
38+
Tools/environment_install/install-prereqs-ubuntu.sh -y
39+
40+
# Update PATH
41+
ENV PATH="/usr/lib/ccache:${PATH}:${HOME}/ardupilot/Tools/autotest"
42+
43+
# Install Gazebo plugin
44+
RUN cd $HOME && \
45+
git clone https://github.com/hmakelin/ardupilot_gazebo && \
46+
cd ardupilot_gazebo && \
47+
mkdir build && \
48+
cd build && \
49+
cmake .. && \
50+
make -j4 && \
51+
sudo make install && \
52+
echo 'source /usr/share/gazebo/setup.sh' >> ~/.bashrc && \
53+
echo 'export GAZEBO_MODEL_PATH=~/ardupilot_gazebo/models' >> ~/.bashrc && \
54+
echo 'export GAZEBO_RESOURCE_PATH=~/ardupilot_gazebo/worlds:${GAZEBO_RESOURCE_PATH}' >> ~/.bashrc
55+
56+
# Make initial build
57+
RUN cd $HOME/ardupilot && \
58+
source ~/.profile && \
59+
$(sim_vehicle.py -v ArduCopter -f gazebo-iris -L KSQL_Airport | grep -m 1 "BUILD SUMMARY") || echo "Gazebo built."
60+
61+
# Copy and apply configuration files, add SITL simulation demo location
62+
COPY * /
63+
RUN sudo mv -t $HOME/ /gazebo-iris.parm /Makefile && \
64+
cat $HOME/gazebo-iris.parm >> $HOME/ardupilot/Tools/autotest/default_params/gazebo-iris.parm && \
65+
echo "KSQL_Airport=37.523640,-122.255122,1.7,90" >> $HOME/ardupilot/Tools/autotest/locations.txt
66+
67+
CMD ["bash"]

docker/ardupilot/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
SHELL:=/bin/bash
2+
3+
sim_vehicle:
4+
sim_vehicle.py -v ArduCopter -f gazebo-iris -L KSQL_Airport -m '--cmd="module load GPSInput"' &
5+
6+
gazebo: sim_vehicle
7+
cd ${HOME} && \
8+
if [ -z ${GAZEBO_HEADLESS} ]; then \
9+
echo "Launching Gazebo client & server..."; \
10+
gazebo --verbose worlds/ksql_airport.world; \
11+
else \
12+
echo "Launching Gazebo in headless mode..."; \
13+
gzserver --verbose worlds/ksql_airport.world; \
14+
fi

docker/ardupilot/gazebo-iris.parm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SIMULATION USE ONLY
2+
# ArduPilot mock GPS SITL simulation demo default parameters
3+
# Disable GPS arming check (GPS2 will not work until already flying) and use best GPS
4+
# Use MAVLink (14) for second GPS type
5+
# Use 2D position only with EK2 (no velocity estimates)
6+
ARMING_CHECK 0
7+
AHRS_EKF_TYPE 2
8+
EK2_ENABLE 1
9+
EK3_ENABLE 0
10+
EK2_GPS_TYPE 2
11+
GPS_TYPE2 14
12+
SIM_GPS2_TYPE 14
13+
GPS_AUTO_SWITCH 1

docker/gisnav/Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM ros:foxy
2+
3+
ARG USERNAME=gisnav
4+
ARG UID=1000
5+
ARG GID=$UID
6+
7+
RUN apt-get update --fix-missing && \
8+
apt-get install sudo && \
9+
groupadd --gid $GID $USERNAME && useradd --uid $UID --gid $GID -m $USERNAME && \
10+
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME
11+
USER $USERNAME
12+
13+
# Install GISNav & colcon dependencies
14+
RUN mkdir -p $HOME/colcon_ws/src && \
15+
cd $HOME/colcon_ws/src && \
16+
git clone --branch hmakelin-update-px4-v1.14 https://github.com/hmakelin/gisnav.git && \
17+
git clone https://github.com/hmakelin/gisnav_msgs.git && \
18+
git clone https://github.com/px4/px4_msgs.git && \
19+
rosdep update && \
20+
rosdep install --from-paths . -y --ignore-src
21+
22+
# Install LoFTR
23+
RUN cd $HOME/colcon_ws/src/gisnav && \
24+
git submodule update --init gisnav/pose_estimators/third_party/LoFTR && \
25+
sudo apt-get -y install python3-pip && \
26+
pip3 install gdown && \
27+
mkdir weights && \
28+
cd weights && \
29+
$HOME/.local/lib/$USERNAME/gdown https://drive.google.com/uc?id=1M-VD35-qdB5Iw-AtbDBCKC7hPolFW9UY
30+
31+
# Python dependencies
32+
RUN cd $HOME/colcon_ws/src/gisnav && \
33+
pip3 install -r requirements.txt && \
34+
pip3 install --upgrade numpy python-dateutil
35+
36+
# GeographicLib
37+
RUN sudo apt-get -y install ros-foxy-mavros ros-foxy-mavros-extras && \
38+
cd $HOME && \
39+
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh && \
40+
sudo bash ./install_geographiclib_datasets.sh
41+
42+
# Build
43+
SHELL ["/bin/bash", "-c"]
44+
RUN cd $HOME/colcon_ws && \
45+
source /opt/ros/foxy/setup.bash && \
46+
colcon build
47+
48+
# Clean
49+
RUN sudo apt-get clean && \
50+
sudo rm -rf /var/lib/apt/lists/*
51+
52+
COPY * /
53+
RUN sudo chmod 755 /disable_shared_memory.xml
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles" >
3+
<transport_descriptors>
4+
<transport_descriptor>
5+
<transport_id>CustomUdpTransport</transport_id>
6+
<type>UDPv4</type>
7+
</transport_descriptor>
8+
</transport_descriptors>
9+
<participant profile_name="participant_profile" is_default_profile="true">
10+
<rtps>
11+
<userTransports>
12+
<transport_id>CustomUdpTransport</transport_id>
13+
</userTransports>
14+
<useBuiltinTransports>false</useBuiltinTransports>
15+
</rtps>
16+
</participant>
17+
</profiles>

docker/mapproxy/Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM ubuntu:20.04
2+
3+
ARG CONFIG_FILE=yaml/mapproxy.yaml
4+
ARG HOST=localhost
5+
ARG PORT=80
6+
ARG MAPPROXY_TILE_URL
7+
8+
ENV CONFIG_FILE=${CONFIG_FILE}
9+
ENV HOST=${HOST}
10+
ENV PORT=${PORT}
11+
ENV MAPPROXY_TILE_URL=${MAPPROXY_TILE_URL}
12+
13+
# Check that the tile endpoint url was provided as build argument
14+
RUN if [ -z "$MAPPROXY_TILE_URL" ]; \
15+
then \
16+
tput setaf 1; \
17+
echo -e "\$MAPPROXY_TILE_URL is empty! Provide it with --build-arg MAPPROXY_TILE_URL=\"url\"."; \
18+
tput sgr0; \
19+
false; \
20+
else \
21+
echo "Using ${MAPPROXY_TILE_URL} for tile endpoint."; \
22+
fi
23+
24+
# Install MapProxy along with required & optional dependencies
25+
RUN apt-get update && \
26+
DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip python3-pil python3-yaml libproj-dev libgeos-dev \
27+
python3-lxml libgdal-dev python3-shapely && \
28+
pip3 install MapProxy
29+
30+
# Copy configuration file over to $HOME
31+
# MapProxy config files can't use environment variables so do tile URL substitution manually
32+
COPY ${CONFIG_FILE} /
33+
RUN mv $(basename $CONFIG_FILE) $HOME/$(basename $CONFIG_FILE) && \
34+
sed -i -e "s#\$MAPPROXY_TILE_URL#$MAPPROXY_TILE_URL#g" $HOME/$(basename $CONFIG_FILE)
35+
36+
# Expose port for incoming WMS requests
37+
EXPOSE $PORT/tcp
38+
39+
# Start the MapProxy server
40+
CMD mapproxy-util serve-develop -b ${HOST}:${PORT} ${HOME}/$(basename $CONFIG_FILE)

docker/mapproxy/yaml/mapproxy.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
layers:
2+
- name: imagery
3+
title: High resolution satellite or aerial imagery.
4+
sources: [imagery_cache]
5+
6+
caches:
7+
imagery_cache:
8+
grids: [GLOBAL_WEBMERCATOR]
9+
sources: [imagery_source]
10+
11+
sources:
12+
imagery_source:
13+
type: tile
14+
grid: GLOBAL_WEBMERCATOR
15+
url: $MAPPROXY_TILE_URL
16+
17+
services:
18+
wms:
19+
md:
20+
title: MapProxy WMS Proxy
21+
abstract: Example MapProxy configuration for proxying a tile-based endpoint as a cached WMS service.

0 commit comments

Comments
 (0)