-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from bitcraze/jonasdn/crazyswarm
Add testing of swarms using Crazyswarm project
- Loading branch information
Showing
10 changed files
with
409 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Crazyswarm test 🐝 | ||
|
||
# Controls when the action will run. | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 4 * * *' | ||
|
||
jobs: | ||
swarm_at_crazylab: | ||
runs-on: self-hosted | ||
container: | ||
image: ros:noetic | ||
options: --privileged | ||
|
||
env: | ||
CSW_PYTHON: python3 | ||
CRAZYSWARM_PATH: crazyswarm | ||
CRAZYSWARM_YAML: crazylab-malmö.yaml | ||
|
||
steps: | ||
- name: Update apt sources | ||
run: | | ||
echo "deb http://ports.ubuntu.com/ubuntu-ports focal main restricted" >> /etc/apt/sources.list | ||
sudo apt-get update | ||
- name: Install Crazyswarm dependencies | ||
run: | | ||
sudo apt-get install -y git swig libpython3-dev python3-numpy \ | ||
python3-yaml python3-matplotlib python3-pytest python3-scipy \ | ||
libpcl-dev libusb-1.0-0-dev sdcc ros-noetic-vrpn gcc-arm-none-eabi \ | ||
ros-noetic-tf ros-noetic-tf-conversions python3-toml python3-pip | ||
- name: Check out sources | ||
uses: actions/checkout@v2 | ||
|
||
- name: Download latest firmware files | ||
with: | ||
repo: bitcraze/crazyflie-release | ||
workflow: nightly.yml | ||
uses: dawidd6/action-download-artifact@v2.14.0 | ||
|
||
- name: Check out sources | ||
uses: actions/checkout@v2 | ||
|
||
- name: Download latest firmware files | ||
with: | ||
repo: bitcraze/crazyflie-release | ||
workflow: nightly.yml | ||
uses: dawidd6/action-download-artifact@v2.14.0 | ||
|
||
- name: Checkout Crazyswarm | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: USC-ACTLab/crazyswarm | ||
path: crazyswarm | ||
|
||
- name: Build Crazyswarm | ||
run: | | ||
source /opt/ros/noetic/setup.bash | ||
cd crazyswarm | ||
./build.sh | ||
shell: bash | ||
|
||
- name: Install Crazyflie python library | ||
run: pip3 install git+https://github.com/bitcraze/crazyflie-lib-python.git@master | ||
|
||
- name: Upgrade swarm to latest firmware | ||
run: | | ||
source crazyswarm/ros_ws/devel/setup.bash | ||
python3 management/program_swarm.py nightly/firmware-tag-nightly.zip --sim | ||
shell: bash | ||
|
||
- name: Run Crazyswarm tests | ||
run: | | ||
source crazyswarm/ros_ws/devel/setup.bash | ||
roslaunch swarms/crazylab-malmö.launch & | ||
python3 -m pytest --verbose tests/crazyswarm | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ repos: | |
rev: 7192665e31cea6ace58a71e086c7248d7e5610c2 | ||
hooks: | ||
- id: flake8 | ||
args: [--ignore=E501] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Copyright (C) 2021 Bitcraze AB | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, in version 3. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
import logging | ||
import os | ||
import sys | ||
import traceback | ||
|
||
from pathlib import Path | ||
|
||
import cflib.crtp | ||
|
||
# Initiate the low level drivers | ||
cflib.crtp.init_drivers() | ||
|
||
# | ||
# This is to make it possible to import from conftest | ||
# | ||
currentdir = os.path.dirname(os.path.realpath(__file__)) | ||
parentdir = os.path.join(currentdir, '..') | ||
sys.path.append(parentdir) | ||
|
||
from conftest import get_swarm # noqa | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
current_frame = 0 | ||
|
||
|
||
def progress_cb(msg: str, percent: int): | ||
global current_frame | ||
frames = ['◢', '◣', '◤', '◥'] | ||
frame = frames[current_frame % 4] | ||
|
||
print('{} {}% {}'.format(frame, percent, msg), end='\r') | ||
current_frame += 1 | ||
|
||
|
||
def program_swarm(fw_file: Path) -> bool: | ||
for dev in get_swarm(): | ||
try: | ||
print('Programming device: {}'.format(dev)) | ||
dev.flash(fw_file, progress_cb) | ||
except Exception as err: | ||
print('Programming failed: {}'.format(str(err)), file=sys.stderr) | ||
traceback.print_exc() | ||
return False | ||
|
||
return True | ||
|
||
|
||
if __name__ == "__main__": | ||
if not program_swarm(sys.argv[1]): | ||
sys.exit(1) |
Oops, something went wrong.