Bitcraze ICRA 2017 Demos
This repository contains code for the demo that we were running at ICRA 2017 in Singapore.
The flying area
We had a cage (3x2 meters and 2.5 meters high) in the booth where we had a Crazyflie flying autonomously with on-board control, no external computer in the loop. The external position reference was provided by the Loco Positioning System. The coordinate system origin was located in the far end left corner with the X-axis pointing forward. The center of the flying area was at (1.0, 1.5).
We had two decks on the Crazyflie:
- the Loco Positioning deck to get position
- a button deck that we used to control the behaviour of the demo. The deck has two button (play and record) and the schematics caon be found in the button-deck directory.
The emergency stop
We also built an emergency stop button mounted on an external box. In the box we used an Arduino to scan the button and emulating a joystick. The Arduino was connected to the USB port of a raspberry pi where a python script scanned the emulated joystick. A Crazyradio was also connected to the raspberry pi via USB and the python script was broadcasting watch dog/emergency stop packets to all Crazyflies. This setup enabled us to instantly kill all autonomously flying Crazyflies in the area.
Since we had a good cage at ICRA we never used the emergency stop. It could be useful in other scenarios though if anyone is interested.
The goal was to create a demo that required a minimum of manual work to let us interact with visitors rather than making the demo work.
The demo had two basic modes: autonomous flight of pre-recorded or live-recorded trajectory.
Pre recorded trajectory
We had a pre recorded trajectory in the copter that was started by pressing the play button on the button deck. When the copter got position lock from the positioning system it entered a start sequence to take off and go to the center of the flying space. After that it repeated the pre recorded sequence over and over again. When out of battery it entered the landing sequence to go back and land close to the net where we easily could change battery.
We used a few different versions of the pre recorded trajectories. The first variations were generated by python scripts (see crazyflie-firmware-experimental/tools/seqSpiralGen.py for instance) and are smooth but a bit boring. The last day we added functionality to generate C-code of a trajectory from a live recording. When the record button on the copter was clicked its position was logged (as C-code, ready to be pasted into sequences.h) in the console in python client. Using this method we recorded a spiral trajectory that was a bit more aggressive and this is what is committed in the final version of the firmware.
The record button was used to record a trajectory by moving the copter around in the flying space. When dropped (in free fall) the copter started retracing the recorded trajectory to go back to where it started.
If the end point was close to the starting point of the recorded trajectory, the playback was done forward (as opposed to retracing) and repeated. That enabled us to record a trajectory and then leave the copter to fly it over and over again. Or to record only one point and let the copter hover at a static point, which was useful when showing the precission of the positioning system.
Recording was not started until position lock was acquired.
We had implemented tumble detection to kill the copter when the motion was too "weird". Very useful if it crashes into a wall or when we wanted to terminate a sequence as we simply could grab it and flip it up side down to stop a running sequence.