Skip to content

Commit bde3696

Browse files
authored
Merge pull request #26 from hmakelin/hmakelin-update-px4-v1.14
Update defaults for PX4 v1.14
2 parents 5bf4b5e + a0c1520 commit bde3696

32 files changed

+1255
-65
lines changed

README.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,47 @@ https://user-images.githubusercontent.com/22712178/187902004-480397cc-460f-4d57-
77
88
GISNav is a ROS 2 package that enables map-based visual navigation for airborne drones **in a simulation environment**.
99

10-
GISNav provides an *accurate* **global** position for an airborne drone by visually comparing frames from the drone's
11-
nadir-facing camera to a map of the drone's *approximate* global position retrieved from an underlying
12-
GIS system.
10+
GISNav provides a *precise* global position for an airborne drone by visually comparing frames from the drone's
11+
nadir-facing camera to a map of the drone's *approximate* global position retrieved from an underlying GIS system.
1312

1413
# Mock GPS Example
1514

16-
The below steps demonstrate how GISNav's `MockGPSNode` ROS 2 node enables GNSS-free flight with PX4 Autopilot's
17-
[Mission mode][1] in a SITL simulation.
15+
The below steps demonstrate how GISNav enables GNSS-free flight with PX4 Autopilot's [Mission mode][1] in a SITL
16+
simulation.
1817

19-
You will need to have [NVIDIA Container Toolkit][2] for Docker installed.
18+
You will need to have the [docker compose plugin][2] and [NVIDIA Container Toolkit][3] installed.
2019

2120
[1]: https://docs.px4.io/v1.12/en/flight_modes/mission.html
22-
23-
[2]: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html
21+
[2]: https://docs.docker.com/compose/install/linux/
22+
[3]: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html
2423

2524
## Build and run SITL simulation
2625

26+
Build the Docker images:
2727
```bash
28-
git clone https://github.com/hmakelin/gisnav-docker.git
29-
cd gisnav-docker
30-
docker-compose build sitl
28+
git clone https://github.com/hmakelin/gisnav.git
29+
cd gisnav
30+
docker compose build px4 qgc mapserver micro-ros-agent gisnav
3131
```
3232

33-
Once the `sitl` image has been built, run the `mapserver` and `sitl` services:
34-
33+
Run GISNav along with supporting services:
3534
```bash
36-
docker-compose up -d mapserver sitl
35+
docker compose up px4 qgc mapserver micro-ros-agent gisnav
3736
```
3837

39-
> **Note**:
40-
> * The build for the `sitl` image takes a long time.
41-
> * The `mapserver` container needs to download roughly 1 GB of high-resolution aerial imagery, so it may take some
42-
> time until it starts serving the WMS endpoint.
43-
> * Prebuilt [sitl][4] and [mapserver][5] images for the demo are available in Docker Hub in case you have problems with
44-
> the build process.
38+
> **Note**
39+
> * The build for the `px4` and `gisnav` images may take a long time.
40+
> * The `mapserver` container needs to download roughly 1 GB of high-resolution aerial imagery when ran for the first
41+
> time, so it may take some time until it starts serving the WMS endpoint.
42+
> * If the Gazebo and QGroundControl windows do not appear on your screen you may need to expose your ``xhost`` to your
43+
> Docker containers (see e.g. [ROS GUI Tutorial][4]):
44+
> ```bash
45+
> for containerId in $(docker ps -f name=gisnav -q); do
46+
> xhost +local:$(docker inspect --format='{{ .Config.Hostname }}' $containerId)
47+
> done
48+
> ```
4549
46-
[4]: https://hub.docker.com/r/hmakelin/gisnav-sitl
47-
[5]: https://hub.docker.com/r/hmakelin/gisnav-mapserver
50+
[4]: http://wiki.ros.org/docker/Tutorials/GUI
4851
4952
## Upload flight plan via QGroundControl
5053
@@ -54,11 +57,9 @@ Docker container, and then start the mission.
5457
5558
## Simulate GPS failure
5659
57-
> **Warning** Do not attempt this on a real flight - simulation use only.
58-
5960
Wait until the drone has risen to its final mission altitude. You should see a visualization of the GISNav-estimated
60-
field of view projected on the ground appear. You can then try disabling GPS from the *nsh* console running on the drone
61-
through your [MAVLink Shell][6] *(accessible e.g. through QGroundControl > Analyze Tools > MAVLink Console)*:
61+
field of view projected on the ground appear. You can then try disabling GPS through your [MAVLink Shell][5]
62+
*(accessible e.g. through QGroundControl > Analyze Tools > MAVLink Console)*:
6263
6364
```
6465
failure gps off
@@ -75,14 +76,14 @@ listener sensor_gps
7576
If the printed GPS message has a `satellites_used` field value of `255`, your PX4 is receiving the mock GPS node output
7677
as expected.
7778
78-
[6]: https://docs.px4.io/main/en/debug/mavlink_shell.html#qgroundcontrol
79+
[5]: https://docs.px4.io/main/en/debug/mavlink_shell.html#qgroundcontrol
7980
8081
# Documentation
8182
82-
See the [latest developer documentation][7] for information on how to setup a local environment for GISNav development,
83+
See the [latest developer documentation][6] for information on how to setup a local environment for GISNav development,
8384
for code examples and API documentation, and for contribution guidelines.
8485
85-
[7]: https://hmakelin.github.io/gisnav
86+
[6]: https://hmakelin.github.io/gisnav
8687
8788
# License
8889

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/docker/mapserver/mapfiles/mapserver.map:/etc/mapserver/mapserver.map:ro
12+
- $PWD/docker/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+
#privileged: True
117+
deploy:
118+
resources:
119+
reservations:
120+
devices:
121+
- driver: nvidia
122+
count: 1
123+
capabilities: [ gpu ]

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:/home/$USERNAME/.local/bin:${PATH}:/home/$USERNAME/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 cd $HOME && make sim_vehicle

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: gazebo
4+
sim_vehicle.py -v ArduCopter -f gazebo-iris -L KSQL_Airport -m '--cmd="module load GPSInput"'
5+
6+
gazebo:
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 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

0 commit comments

Comments
 (0)