Skip to content

repository containing the code to make a swarm of crazyflies avoid obstacles on a waypoint mission. Ubuntu 22.04 was used for this project. This git repo was cloned into the home directory.

Notifications You must be signed in to change notification settings

boomer319/verrueckter_schwarm

Repository files navigation

cloning this git repo

git clone --recurse-subodules https://github.com/boomer319/verrueckter_schwarm.git

crazyflie configuration

The crazyflies have a number on their belly. The number corresponds to the last digits in their radio address:

  • radio:https://0/80/2M/0xE7E7E7E701 for cf01
  • radio:https://1/100/2M/0xE7E7E7E702 for cf02
  • radio:https://0/80/2M/0xE7E7E7E703 for cf03
  • radio:https://1/100/2M/0xE7E7E7E704 for cf04
  • radio:https://0/80/2M/0xE7E7E7E705 for cf05
  • radio:https://1/100/2M/0xE7E7E7E706 for cf06
  • radio:https://0/80/2M/0xE7E7E7E707 for cf07
  • radio:https://1/100/2M/0xE7E7E7E708 for cf08

0 and 1 in ...//0/... are the ids of the radio that shall be used

80 and 100 are the channels

2M is radio bandwith

look at verrueckter_schwarm/ros2_ws/src/verrueckterschwarm2/crazyflie/config/crazyflies.yaml...this is the radio configuration found there

frequently needed & useful commands

general

source /opt/ros/humble/setup.bash # can be added at the bottom of your .bashrc
source install/setup.bash # execute in your ros2_ws! can be added at the bottom of your .bashrc
ifconfig # find out the network adapter configuration of your device
ping IP-Address # test wether data transfer to specified IP works as quickly as intended

drone movement/control/interaction

cfclient # open the crazyflie client
ros2 launch crazyflie launch.py backend:=cflib # starting crazyswarm2's crazyflie server with cflib backend
ros2 launch crazyflie launch.py # starting crazyswarm2's crazyflie server with cpp backend (this one is used in the course of this project)
export PYTHONPATH=~/verrueckter_schwarm/crazyflie-firmware/build:$PYTHONPATH # necessary for starting the crazyflie simulation
ros2 launch crazyflie launch.py backend:=sim # starting simulated server
ros2 run crazyflie_examples hello_world # in separate terminal
ros2 run crazyflie_waypoint_mission goTo # in separate terminal

The main waypoint mission script can be found in verrueckter_schwarm/ros2_ws/src/verrueckterschwarm2/crazyflie_waypoint_mission/crazyflie_waypoint_mission/goTo.py. It is intended to make the drones go to points in space while maintaining their respective positions in the swarm and always having the cameras face the direction of flight. This was done to give the crazyflies the ability to avoid obstacles in later parts of the project.

python env

It is very practical to make a python environment for all your different use cases.

This will allow you to not disrupt any of your other sub-projects by messing up your python dependencies

A python environment was made for:

Tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-programming-environment-on-an-ubuntu-20-04-server

source ~/environments/cf/bin/activate # enter python environment
deactivate # exit python env

You can add an alias in your .bashrc. This way you dont need to type the command every time. You just need to use cf in the command line and the corresponding command is executed:

alias cf='source ~/environments/cf/bin/activate'

lines added to my .bashrc

# ROS
source /opt/ros/humble/setup.bash # source ros
alias cs2='cd ~/verrueckter_schwarm/ros2_ws && source install/local_setup.bash' # source ros workspace
alias chooser='ros2 run crazyflie chooser.py' # makes it easy to read the battery voltage, restart crazyflies, select and deselect them. the alternative to selecting them in chooser.py would be to manually go to crazyflies.yaml and type true and false for each crazyflie.

# MoCap
alias NatNet='~/verrueckter_schwarm/NatNetSDKCrossplatform/build/sampleClient' # launching the sampleClient to see whether your PC receives the MoCap data thats streamed by NatNet.

# Python
alias cf='source ~/environments/cf/bin/activate' # Environment for working with the crazyflie
alias cf_py2='source ~/environments/cf_py2/bin/activate' # Environment for working with the crazyflie but python2
alias cfai='source ~/environments/cfai/bin/activate' # Environment for following the classification example with the ai deck
alias gap='source ~/environments/gap/bin/activate' # Environment for working with the GAP8 chip

# GAP
alias GAP_SDK='gap && source ~/verrueckter_schwarm/gap_sdk/sourceme.sh' # sourcing the chip configuration for working with the GapSDK
alias JTAG='export GAPY_OPENOCD_CABLE=~/verrueckter_schwarm/gap_sdk/utils/gap8-openocd/tcl/interface/ftdi/olimex-arm-usb-tiny-h.cfg' # needed whenever you are working with the JTAG debugger

getting started from scratch

set up git

https://git-scm.com/download/linux

https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup

install cfclient

https://www.bitcraze.io/documentation/tutorials/getting-started-with-crazyflie-2-x/#inst-comp

https://www.bitcraze.io/documentation/repository/crazyflie-clients-python/master/installation/install/

sudo apt install git python3-pip libxcb-xinerama0
pip3 install --upgrade pip

pip3 install cfclient

configure your usb permissions for crazyradio access

https://www.bitcraze.io/documentation/repository/crazyflie-lib-python/master/installation/usb_permissions/

sudo groupadd plugdev
sudo usermod -a -G plugdev $USER

log out / in

cat <<EOF | sudo tee /etc/udev/rules.d/99-bitcraze.rules > /dev/null
# Crazyradio (normal operation)
SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", ATTRS{idProduct}=="7777", MODE="0664", GROUP="plugdev"
# Bootloader
SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", ATTRS{idProduct}=="0101", MODE="0664", GROUP="plugdev"
# Crazyflie (over USB)
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", MODE="0664", GROUP="plugdev"
EOF

reloading udev-rules:

sudo udevadm control --reload-rules
sudo udevadm trigger

update the crazyradio PA (needed when using the cpp backend of crazyswarm2)

I already did this on the two radios used in this project. Shouldn't be necessary if you don't plan on using more radios.

https://www.bitcraze.io/documentation/repository/crazyradio-firmware/master/building/building_flashing/#building-the-firmware

launch cfclient

cfclient

used for:

set up crazyswarm2

set up ros2 humble

https://docs.ros.org/en/humble/Installation.html

"install" crazyswarm2

https://imrclab.github.io/crazyswarm2/installation.html

important: step 3 in this case will be as follows (notice crazyswarm2 is missing, as my fork was already cloned recursively with this git):

mkdir -p ros2_ws/src
cd ros2_ws/src
git clone --branch ros2 --recursive https://github.com/IMRCLab/motion_capture_tracking.git

set up config of crazyswarm2

I configured the drones in crazyflies.yaml. Each drone was assigned a starting position, mocap marker configuration and radio address.

https://imrclab.github.io/crazyswarm2/usage.html

use the crazyswarm2 sim

This can be used to test your scripts before running them with the drones in real life. Depending on the power you have available this might run slow.

set up MoCap System and Motive Software

general setup

In order for the motion capture streaming service "NatNet" to send data to the PC you are running the crazyswarm server from, you have to have them both in the same newtork or directly linked through an ethernet switch. A wifi router can be used as a switch too. Simply plug everything into the yellow ethernet ports. Find the IP corresponding to the network both your PC and the MoCap PC use. Choose that IP of the MoCap PC in Motive. Also put it in to verrueckter_schwarm/ros2_ws/src/verrueckterschwarm2/crazyflie/config/motion_capture.yaml

Motive Streaming Settings

  • enable
  • local interface: use the IP address of the PC running Motive
    • the third group of numbers of the IP has to be the same as for the receiving machine 192.168.XYZ.103 (this group should correspond for all devices on the given router)
  • Multicast
  • turn on only labeled and unlabeled marker streaming, turn off the streaming of other things, e.g. Rigid Bodies. Crazyswarm2 only needs the pointcloud of said markers.
  • The rest can be left as seen on the screenshot NatNetSettings.png

Bookmarks

Python

How To Install Python 3 and Set Up a Programming Environment on an Ubuntu 20.04 Server | DigitalOcean

Solve Python error: subprocess-exited-with-error | bobbyhadz

How to Add Python to PATH – Real Python

Git

Git - First-Time Git Setup

Git - Make local HEAD the new master - Stack Overflow

git - How to push changes to github without pull - Stack Overflow

ROS2 Humble

Ubuntu (Debian packages) — ROS 2 Documentation: Humble documentation

Tutorials — ROS 2 Documentation: Humble documentation

Sim

Gazebo - Docs: Binary Ubuntu Install

Gazebo Spin Motors | Bitcraze

Configuration — Crazyswarm 0.3 documentation

Tutorials — Crazyswarm 0.3 documentation

crazyswarm2

NatNet

NatNet SDK - EXTERNAL OptiTrack Documentation

whoenig/NatNetSDKCrossplatform: Crossplatform version of the OptiTrack NatNet SDK

Crazyswarm2: A ROS 2 testbed for Aerial Robot Teams — Crazyswarm2 1.0a1 documentation

IMRCLab/crazyswarm2: A Large Quadcopter Swarm

IMRCLab/libmotioncapture: Interface Abstraction for Motion Capture System APIs such as VICON or OptiTrack

Optitrack to Crazyflie Set up - Bitcraze Forums

libmotioncapture/examples/python.py at main · IMRCLab/libmotioncapture

Optitrack · IMRCLab/crazyswarm2 · Discussion #286

Settings: Streaming - EXTERNAL OptiTrack Documentation

Crazyswarm2 development | Bitcraze

Frequently Asked Questions — Crazyswarm2 1.0a1 documentation

How does crazyswarm2 process data? What are the outputs to crazyflies? Documentation on the inner workings and data flow. · IMRCLab/crazyswarm2 · Discussion #338

Building and Flashing | Bitcraze

Collision avoidance by jpreiss · Pull Request #628 · bitcraze/crazyflie-firmware

whoenig/uav_trajectories: Helper scripts and programs for trajectories

crazyswarm/ros_ws/src/crazyswarm/scripts/backgroundComputation.py at master · USC-ACTLab/crazyswarm

cf client setup

Installation Instructions | Bitcraze

USB permissions | Bitcraze

step-by-step tutorials

Step-by-Step: Connecting, logging and parameters | Bitcraze

Step-by-Step: Motion Commander | Bitcraze

bitcraze discussions

bitcraze · Discussions · GitHub

crazyflie 2.1 > custom firmware > xyz.bin generating out of custom .config · bitcraze · Discussion #936

AI deck cannot be flashed with wifi example (old bootloader, flashing freezes) · bitcraze · Discussion #942

AI deck

Releases · bitcraze/aideck-gap8-examples

Getting started with the AI deck | Bitcraze

WiFi Video Streamer | Bitcraze

Flashing | Bitcraze

Classification Demo | Bitcraze

AI deck 1.1 | Bitcraze

PULP-DroNet: open source and open hardware artificial intelligence for fully autonomous navigation on Crazyflie | Bitcraze

AI-deck Workshop 1 - YouTube

Deep Learning

STM-GAP8 CPX communication Example | Bitcraze

NanoFlowNet

Obstacle Avoidance AI-deck | Bitcraze

2209.06918.pdf

tudelft/nanoflownet: Code and trained networks of the paper "NanoFlowNet: Real-time Dense Optical Flow on a Nano Quadcopter"

semantic segmentation CNN STDC-Seg

UAVid Semantic Segmentation Dataset

[1504.06852] FlowNet: Learning Optical Flow with Convolutional Networks

FlowNet: Learning Optical Flow with Convolutional Networks - YouTube

GAP8

GreenWaves-Technologies/gap_sdk: SDK for Greenwaves Technologies' GAP8 IoT Application Processor

PowerPoint Presentation

Machine Learning on GAP8 for tiny devices - YouTube

gap_sdk/tools/nntool/README.md at master · GreenWaves-Technologies/gap_sdk

gap_sdk/tools/nntool at master · GreenWaves-Technologies/gap_sdk

GreenWaves-Technologies/gap_sdk at release-v4.8.0

crazyradio PA

Build and flash radio | Bitcraze

USB and Radio protocol of the Crazyradio dongle | Bitcraze

crazyflie-firmware

crazyflie-firmware

CPX - Crazyflie Packet eXchange | Bitcraze

index [Bitcraze Wiki]

Bitcraze

Bitcraze - Crazyflie 101 EPFL-LIS lecture - part 2 (2020) - YouTube

Guest Lecture at EPFL Aerial Robotics Course 2020 | Bitcraze

Helping drone swarms avoid obstacles without hitting each other - EPFL

Crazyflie

crazyflie API

Tutorials | Bitcraze

User guides | Bitcraze

Crazyflie Summer Project with ROS2 and Mapping | Bitcraze

Motion Capture positioning | Bitcraze

Customize firmware with kbuild | Bitcraze

Building and Flashing | Bitcraze

Install Docker Engine on Ubuntu | Docker Docs

Mellinger and PID controllers - Bitcraze Forums

About

repository containing the code to make a swarm of crazyflies avoid obstacles on a waypoint mission. Ubuntu 22.04 was used for this project. This git repo was cloned into the home directory.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages