Skip to content

Commit 43d13fe

Browse files
committed
Implementation of snowsampler drone
0 parents  commit 43d13fe

File tree

101 files changed

+3748
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+3748
-0
lines changed

.github/workflows/build_test.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: ROS1 Build Test
2+
on:
3+
push:
4+
branches:
5+
- 'ros1'
6+
pull_request:
7+
branches:
8+
- '*'
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
config:
17+
- {rosdistro: 'noetic', container: 'ros:noetic-ros-base-focal'}
18+
container: ${{ matrix.config.container }}
19+
steps:
20+
- uses: actions/checkout@v1
21+
with:
22+
token: ${{ secrets.ACCESS_TOKEN }}
23+
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
- name: Install Dependencies
25+
working-directory:
26+
env:
27+
DEBIAN_FRONTEND: noninteractive
28+
run: |
29+
apt update
30+
apt install -y python3-wstool python3-catkin-tools git
31+
shell: bash
32+
- name: Build Test
33+
working-directory:
34+
env:
35+
DEBIAN_FRONTEND: noninteractive
36+
run: |
37+
mkdir -p $HOME/catkin_ws/src;
38+
cd $HOME/catkin_ws
39+
catkin init
40+
catkin config --extend "/opt/ros/${{matrix.config.rosdistro}}"
41+
catkin config --merge-devel
42+
cd $HOME/catkin_ws/src
43+
ln -s $GITHUB_WORKSPACE
44+
cd $HOME/catkin_ws
45+
wstool init src src/adaptive-snowsampler/dependencies.rosinstall
46+
wstool update -t src -j4
47+
rosdep update
48+
rosdep install --from-paths src --ignore-src -y --rosdistro ${{matrix.config.rosdistro}}
49+
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release -DCATKIN_ENABLE_TESTING=False
50+
catkin build -j$(nproc) -l$(nproc) adaptive_snowsampler
51+
# - name: unit_tests
52+
# working-directory:
53+
# run: |
54+
# cd $HOME/catkin_ws/src
55+
# catkin config --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCATKIN_ENABLE_TESTING=True
56+
# catkin build grid_map_geo --no-deps -i --catkin-make-args tests
57+
# source $HOME/catkin_ws/devel/setup.bash
58+
# status=0 && for f in $HOME/catkin_ws/devel/lib/*/*-test; do $f || exit 1; done
59+
# shell: bash

.github/workflows/check_style.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Style Checks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- '*'
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
config:
18+
- {rosdistro: 'humble', container: 'osrf/ros:humble-desktop'}
19+
container: ${{ matrix.config.container }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
path: src/adaptive-snowsampler
24+
- name: Install Dependencies with Rosdep
25+
run: |
26+
apt update
27+
rosdep update
28+
source /opt/ros/${{matrix.config.rosdistro}}/setup.bash
29+
rosdep install --from-paths src --ignore-src -y --dependency-types test
30+
shell: bash
31+
- name: Check Code format
32+
working-directory: src/adaptive-snowsampler/Tools
33+
run: |
34+
./check_code_format.sh ..

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/.vscode/
2+
adaptive_snowsampler/scripts/__pycache__/*

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2024, Jaeyoung Lim, Autonomous Systems Lab, ETH Zurich
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<img align="right" height="60" src="https://user-images.githubusercontent.com/5248102/126074528-004a32b9-7911-486a-9e79-8b78e6e66fdc.png">
2+
3+
# adaptive_snowsampler
4+
5+
[![ROS1 Build Test](https://github.com/Jaeyoung-Lim/adaptive-snowsampler/actions/workflows/build_test.yml/badge.svg)](https://github.com/Jaeyoung-Lim/adaptive-snowsampler/actions/workflows/build_test.yml)
6+
7+
This project includes an implementation of operating the snow sampler drone.
8+
9+
> This work has been submitted to [ISSW 2024](https://www.issw2024.com/).
10+
11+
![drone_in_snow](https://github.com/ethz-asl/adaptive-snowsampler/assets/5248102/acb43300-03ae-4160-b090-5c5f373461be)
12+
13+
## Installation
14+
```
15+
cd ~
16+
mkdir -p catkin_ws/src
17+
cd catkin_ws/src
18+
git clone https://github.com/Jaeyoung-Lim/adaptive-snowsampler.git -b ros1
19+
git clone https://github.com/ethz-asl/grid_map_geo.git
20+
git clone https://github.com/ethz-asl/mav_comm.git
21+
git clone https://github.com/ethz-asl/terrain-navigation.git
22+
cd ..
23+
sudo rosdep init
24+
rosdep update
25+
rosdep install --from-paths src --ignore-src -y
26+
catkin build
27+
28+
29+
# post building tasks
30+
echo 'ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="fc5f", GROUP="dialout"' | sudo tee /etc/udev/rules.d/99-actuonix.rules #setting usb permissions
31+
sudo usermod -aG dialout user # add user to the dailout group
32+
sudo reboot # needed for the usb permissions to take effect
33+
34+
# installation of GeographicLib dependency
35+
cd ~
36+
git clone https://github.com/mavlink/mavros.git
37+
sudo apt install geographiclib-tools libgeographic-dev
38+
sudo ~/mavros/mavros/scripts/install_geographiclib_datasets.sh
39+
40+
```
41+
42+
## Running the code
43+
Run the code with the following launch file
44+
```
45+
source ~/ros2_ws/install/setup.bash
46+
ros2 launch adaptive_snowsampler launch.xml
47+
```
48+
49+
## Testing with PX4 Software-In-The-Loop(SITL) simulation
50+
51+
Set the Package Paths
52+
```
53+
cd ~/PX4-Autopilot/
54+
DONT_RUN=1 make px4_sitl_default gazebo-classic
55+
source ~/catkin_ws/devel/setup.bash # (optional)
56+
source Tools/simulation/gazebo-classic/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
57+
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
58+
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic
59+
```
60+
Set the takeoff location
61+
```
62+
export PX4_HOME_LAT=46.785479
63+
export PX4_HOME_LON=9.846803
64+
export PX4_HOME_ALT=2301.23
65+
66+
```
67+
68+
Run the node
69+
```
70+
roslaunch adaptive_snowsampler sitl_run.launch
71+
72+
```
73+
74+
## Running the ground station
75+
76+
To control the vehicle from the ground, we need to connect to the ROS Master on the drone.
77+
Whereby its important that the IP is correct and that the drone and ground station are in the same zerotier network.
78+
Run rviz with the following command.
79+
```
80+
ROS_MASTER_URI=http://172.30.132.111:11311
81+
roslaunch snowsampler_rviz run.launch
82+
```
83+
84+
![rviz](https://github.com/Jaeyoung-Lim/adaptive-snowsampler/assets/5248102/117a296d-01ad-4209-bec7-fb14267628e0)

Tools/check_code_format.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# Fix style recursively in all the repository
4+
sh fix_code_style.sh ..
5+
6+
# Print the diff with the remote branch (empty if no diff)
7+
git --no-pager diff -U0 --color
8+
9+
# Check if there are changes, and failed
10+
if ! git diff-index --quiet HEAD --; then echo "Code style check failed, please run clang-format (e.g. with scripts/fix_code_style.sh)"; exit 1; fi

Tools/configure.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "This script will configure your system"
6+
7+
if [ "$EUID" -ne 0 ]
8+
then echo "Please run as root"
9+
exit
10+
fi
11+
12+
PACKAGE_PATH=/home/user/catkin_ws/src/adaptive-snowsampler
13+
14+
# Configure systemd service
15+
echo "Copy systemd service"
16+
cp -vf $PACKAGE_PATH/systemd/adaptive-snowsampler.service /etc/systemd/system/
17+
cp -vf $PACKAGE_PATH/systemd/mavlink-router.service /etc/systemd/system/
18+
cp -vf $PACKAGE_PATH/systemd/rosbag-record.service /etc/systemd/system/
19+
cp -vf $PACKAGE_PATH/systemd/ssp-bridge.service /etc/systemd/system/
20+
cp -vf $PACKAGE_PATH/systemd/system-monitor.service /etc/systemd/system/
21+
22+
systemctl enable adaptive-snowsampler.service
23+
systemctl enable mavlink-router.service
24+
systemctl enable ssp-bridge.service
25+
systemctl enable system-monitor.service
26+
27+
sudo systemctl start adaptive-snowsampler.service
28+
sudo systemctl start mavlink-router.service
29+
sudo systemctl start ssp-bridge.service
30+
sudo systemctl start system-monitor.service

Tools/fix_code_style.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
STYLE="google"
4+
5+
if [ "$#" -eq 0 ]; then
6+
echo "Usage: $0 <src_file | dir>"
7+
echo ""
8+
echo "ERROR: At least one source file or one directory must be provided!"
9+
10+
exit 1
11+
fi
12+
13+
for arg in "$@"
14+
do
15+
if [ -f $arg ]; then
16+
clang-format -i -style='{BasedOnStyle: google, ColumnLimit: 120}' $arg
17+
elif [ -d $arg ]; then
18+
find $arg -iname '*.h' -o -iname '*.cpp' -o -iname '*.hpp' | xargs clang-format -i -style='{BasedOnStyle: google, ColumnLimit: 120}'
19+
find $arg -iname '*.h' -o -iname '*.cpp' -o -iname '*.hpp' | xargs chmod 644
20+
fi
21+
done

adaptive_snowsampler/CMakeLists.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
project(adaptive_snowsampler)
3+
add_definitions(-std=c++17)
4+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
5+
6+
7+
# find dependencies
8+
find_package(Eigen3)
9+
find_package(GeographicLib REQUIRED)
10+
include(CheckGeographicLibDatasets)
11+
12+
find_package(catkin REQUIRED COMPONENTS
13+
roscpp
14+
rospy
15+
tf
16+
grid_map_geo
17+
grid_map_ros
18+
grid_map_geo_msgs
19+
eigen_catkin
20+
interactive_markers
21+
planner_msgs
22+
snowsampler_msgs
23+
)
24+
25+
execute_process(
26+
COMMAND "${PYTHON_EXECUTABLE}" -m pip install --no-warn-script-location -r "${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt"
27+
RESULT_VARIABLE _pip_install_result
28+
OUTPUT_VARIABLE _pip_install_output
29+
)
30+
31+
catkin_package(
32+
INCLUDE_DIRS include
33+
LIBRARIES adaptive_snowsampler
34+
CATKIN_DEPENDS roscpp
35+
)
36+
37+
include_directories(
38+
include
39+
${catkin_INCLUDE_DIRS}
40+
${Eigen_INCLUDE_DIRS}
41+
${GeographicLib_INCLUDE_DIRS}
42+
)
43+
44+
catkin_install_python(PROGRAMS
45+
scripts/snowsampler_lac.py
46+
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
47+
48+
include_directories(
49+
include
50+
)
51+
52+
add_executable(adaptive_snowsampler
53+
src/main.cpp
54+
src/adaptive_snowsampler.cpp)
55+
target_link_libraries(adaptive_snowsampler ${catkin_LIBRARIES} ${planner_msgs_TARGETS} ${GeographicLib_LIBRARIES})
56+
add_dependencies(adaptive_snowsampler ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
##
2+
# This module verifies the installation of the GeographicLib datasets and warns
3+
# if it doesn't detect them.
4+
##
5+
6+
find_path(GEOGRAPHICLIB_GEOID_PATH NAMES geoids PATH_SUFFIXES share/GeographicLib share/geographiclib)
7+
find_path(GEOGRAPHICLIB_GRAVITY_PATH_ NAMES gravity PATH_SUFFIXES share/GeographicLib)
8+
find_path(GEOGRAPHICLIB_MAGNETIC_PATH_ NAMES magnetic PATH_SUFFIXES share/GeographicLib)
9+
10+
if(NOT GEOGRAPHICLIB_GEOID_PATH)
11+
message(STATUS "No geoid model datasets found. This will result on a SIGINT! Please execute the script install_geographiclib_dataset.sh in /mavros/scripts")
12+
else()
13+
message(STATUS "Geoid model datasets found in: " ${GEOGRAPHICLIB_GEOID_PATH}/geoid)
14+
set(GEOGRAPHICLIB_GEOID_PATH ${GEOGRAPHICLIB_GEOID_PATH}/geoid)
15+
endif()
16+
if(NOT GEOGRAPHICLIB_GRAVITY_PATH_)
17+
message(STATUS "No gravity field model datasets found. Please execute the script install_geographiclib_dataset.sh in /mavros/scripts")
18+
else()
19+
message(STATUS "Gravity Field model datasets found in: " ${GEOGRAPHICLIB_GRAVITY_PATH_}/gravity)
20+
set(GEOGRAPHICLIB_GRAVITY_PATH ${GEOGRAPHICLIB_GRAVITY_PATH_}/gravity)
21+
endif()
22+
if(NOT GEOGRAPHICLIB_MAGNETIC_PATH_)
23+
message(STATUS "No magnetic field model datasets found. Please execute the script install_geographiclib_dataset.sh in /mavros/scripts")
24+
else()
25+
message(STATUS "Magnetic Field model datasets found in: " ${GEOGRAPHICLIB_MAGNETIC_PATH_}/magnetic)
26+
set(GEOGRAPHICLIB_MAGNETIC_PATH ${GEOGRAPHICLIB_MAGNETIC_PATH_}/magnetic)
27+
endif()

0 commit comments

Comments
 (0)