Hardware - larics/crazyflies_wiki GitHub Wiki
To deploy your code on Crazyflies, you can use docker setup with everything pre-installed. The detailed instructions are given in the readme.
Starting with crazyflies
Crazyflies dongle
Crazyflies communicate with a computer using Crazyradio (radio dongle), which works on 2.4 GHz. One dongle can communicate with several Crazyflies simultaneously. When using the dongle for the first time, you need to flash it. This is only required if the dongle is taken straight out of the box for the first time.
cfclient
Crazyflie client (cfclient
) is the default UI for controlling the Crazyflie, flashing firmware, setting parameters, and logging data. For more info, check this link. The Crazyflie client can be started by typing the command cfclient
or python3 -m cfclient.gui
. It can be used to change the address of a Crazyflie, check the battery status, update firmware, etc.
Changing the address
To change the address of a Crazyflie, follow the instructions here. It is recommended to use 2 Mbit/s radio bandwidth, and if using different channels, they should be at least 2 apart. If two Crazyflies are on the same channel, they should have different radio addresses. Since Crazyradio works on 2.4 GHz, the same as the Wi-Fi, it is recommended to set the radio channel to 90 and above, up to 120, in order to avoid interference with Wi-Fi.
Joystick control
After starting the cfclient
and connecting to one of the Crazyflies, you can set up the joystick following the instructions on this link. Crazyflies can be controlled with a joystick without any deck on it, however, they cannot hold the height and hover. It is better to add the optical flow deck, which will enable holding the altitude (hovering). For this, the assist mode dropdown menu in the cfclient
should be set to Hover
.
One of the example mappings for a joystick is shown in the image below:
To enable Crazyflies with optical flow to hover by holding the altitude, keep the assisted mode button pressed during the flight.
Charging Crazyflies
Crazyflies have attached a small 250 mAh battery. Usually, with a full battery, the UAV has a flight time of approx. 7 minutes. However, this time can significantly be reduced if there are additional decks on it. The full battery is around 4.1 V, and you shouldn't start flying if it falls below 3.7 V. These voltages are measured when the UAV is landed; during the flight, it is normal that voltage drops up to 3.2. If it falls below 3.1 V, please land the UAV and replace the battery. You can check the battery status in cfclient
. Batteries can be charged while Crazyflies are connected to the laptop/PC via USB and it is on. You can also replace the battery and connect the empty ones to the charger. This way you can charge multiple batteries in parallel by connecting the charges in the USB-hub.
Setting up and working with positioning systems
It is possible to fly in different localization systems with Crazyflies. The detailed overview of positioning systems is here.
Optical flow deck
When using only the optical flow deck on Crazyflies, it is possible to fly and hover without using external anchors. This deck installs on the bottom of the Crazyflies and uses a camera to determine ground velocity by observing changes in ground texture and visible features. Additionally, it has a Time-of-Flight (ToF) ranging sensor that measures the distance to the ground. There are a couple of things that you need to be careful with when using this deck, and they are explained here and here. Also, keep in mind that ToF sensors expect the floor to be flat. Otherwise, the controller might receive abrupt changes in the measured height and become unstable.
Loco positioning
The Loco positioning system is a positioning system based on Ultra Wide Band (UWB) radio frequencies. It is used to find the absolute 3D position in the space. It consists of a set of anchors (Loco positioning nodes) positioned in the room whose locations should be known. The other part is the Loco positioning deck that is attached to the Crazyflies. You can check more information on this link. Loco positioning nodes are powered by power banks and should be set in the desired places. There are several modes of operation, and the recommended one is TDoA 3. You can check it by running cfclient
and connecting to the UAV that has a Loco positioning deck. A detailed explanation is given here. In the image below is an example of a setup we have in Ericsson with 8 anchors.
If some of the anchors status is red for a long time and doesn't change, try to configure the node once again as described here. The positions should be measured manually and written to anchors.
Optitrack
Optitrack is one of the motion capture systems that uses IR cameras to detect the markers attached to the object that is tracked. Each object needs to have reflective marker(s) in order to determine the position and orientation of the object. You can find more info here. In a general setup, each object needs to have a unique arrangement of reflective markers - this is also possible to do on crazyflies. However, due to their size, we often use Optitrack in the single marker setup, where then only position is obtained from Optitrack, and the orientation is filtered from other sensors on Crazyflies (such as IMU, gyro...).
The general setup contains two laptops:
- one with the Windows and Motive program with hardware (USB) key
- another is a Linux machine from which crazyflies are started.
Other equipment includes:
- Power over the Ethernet (POE) switch
- router
- hardware key
- min. 4 optitrack cameras
- long ethernet cables
- short ethernet cables
- tripods
Optitrack/Motive setup
Optitrack cameras are powered over the ethernet - this is why we must use a POE switch. All cameras should be connected to this switch, alongside the uplink cable that transfers the data to the Windows laptop with Motive software installed. Motive software serves to connect to the Optitrack system and get the data from cameras. It is necessary to install it (the version depends on the hardware key, currently, we have Motive 2.2.0.) and insert the hardware key. The router should be connected to the switch and the Linux laptop. Check the scheme below.
Windows laptop. When Motive software is on, several steps need to be done:
-
Calibration: To do a calibration of the system, please follow the instructions as described here.
-
Set up the data streaming pane similar to the image below. You should put the local net IP address of this laptop into the local interface field. Also, Up Axis should be set to Z Up, and Transmission type should be Multicast. Missing the image of data streaming setup
- Usually, when flying or moving a robot in Optitrack, we combine visible markers attached to the body in a unique pattern into a rigid body frame (by selecting visible markers, right-click, create rigid body). However, Crazyflies are too small to create differentiable unique patterns for each of them. This is why we attach one big marker and use a single marker setup. Missing the image of a crazyflie with single marker setup
Linux laptop.
To receive data on the laptop, you should have locally installed and set up NatNetSDK. In the dockerfile, there is already cloned Motion Capture Tracking ROS 2 package. If using only this package (without crazyswarm2) to receive poses, you should set here the right IP address from the data streaming pane. And the data should come to topic /poses
. If you are using Crazyswarm2, this package is automatically started in the launch.py
file (mocap
parameter should be set to true
). The correct IP address should be set here. Keep in mind that when using the crazyswarm2 package, depending on the type of crazyflies that is defined in crazyflies.yaml.
, mocap
should be set to true
(link to example).
Adding other decks
When using different decks on the Crazyflie at the same time, please keep in mind that some combinations of decks are not compatible. For more info, check this site. Below is a compatibility table taken from this link. There are some workarounds. For example, if you want to use a flow deck and an LED ring, here are example 1 and example 2 for this.
AI deck
AI deck can be mounted on top or bottom of the crazyflie. It has a monochrome camera, Wi-Fi module and a small processor on it. The monochrome camera module can be replaced by an RGB camera module (tutorial).
To start working with the AI deck, you can follow this tutorial. You will also need a JTAG adapter and JTAG programmer. When you get to this command:
docker run --rm -it -v $PWD:/module/ --device /dev/ttyUSB0 --privileged -P bitcraze/aideck /bin/bash -c 'export GAPY_OPENOCD_CABLE=interface/ftdi/olimex-arm-usb-tiny-h.cfg; source /gap_sdk/configs/ai_deck.sh; cd /module/; make all image flash'
change the interface ftdi/olimex-arm-usb-tiny-h.cfg
to jlink.cfg
, because we have a j-link based programmer.
Originally, the AI deck acts as an access point. This means that it creates its own Wi-Fi. This can be changed in kbuild's menuconfig by following this tutorial and checking this answer in discussion.
Multi ranger deck
Multi ranger deck contains 5 ToF sensors that measure distance up to 4 meters in 5 directions. It goes on the top of the crazyflie. To use it with Python, check the examples here, or with crazyswarm2, check /cf_x/scan
topic and follow these tutorials.
LED deck
LED deck contains 12 RGB LEDs. Primarily, it should be attached looking downwards, however, then it couldn't be used with an optical flow sensor. There is also a hack on how to remap the inputs of the LED deck so it can light up when it is on top. To control the lights on the LED deck, you can use cfclient, or you can do it from crazyswarm2 package by defining an RGB combination of the desired color here.