CS50 Final Project: Hand Gesture-based Nanocopter Control
The report on the general design and specifications (finite state machine, data structures) is in report.pdf
.
The project focused on flying a Crazyflie 1.0 nanocopter with a Leap Motion sensor. The sensor recognizes custom gestures to control the nanocopter. We communicate with the nanocopter using a USB dongle included with the Crazyflie.
The nanocopters run an embedded OS named RTOS. We focused on writing the code that would allow the motion sensor to communicate with the nanocopter. Some pieces of code were supplied to us.
We use submodules, so use the following command to include those when you clone:
git clone --recursive https://github.com/patxu/attackofthedrones
Try following the Crazyflie startup guide. This didn't fully work for me, so I document my setup process below. Follow at your own risk!
- macports (package installer)
-
Otherwise, upgrade:
sudo port selfupdate sudo port upgrade outdated
-
open a new terminal window to use macports
- install dependencies (this might take a while)
sudo port install libusb python34 py34-SDL2 py34-pyqt4 py34-pip
- pyusb
python -m pip install "pyusb>=1.0.0b2"
- Possibly optional?
- pygame
-
pip install hg+http://bitbucket.org/pygame/pygame
- pyqtgraph (might not be necessary?)
- download "source package"
-
python setup.py install
- move libLeap to correct location (better way to do this?)
sudo cp bin/libLeap.dylib /opt/local/lib
This is the Crazyflie client and will determine the channel ID of the quadcopter. See here if you're unable to compile.
cd crazyflie-clients-python
pip install -e .
/opt/local/bin/python3.4 bin/cfclient
- Select
Select an interface
to determine the channel ID
- radio://0/
[Channel ID]
/250k
- Set this channel ID in
control.cpp
line 589
Note: you can skip this step if you already know everything compiles
cd bin
cmake ..
make
./quickstartup.sh
- this also compiles the client (above)- stay clear of the Leap
- press
enter
to start up copter - bring one hand with spread fingers about 5cm over the Leap
- slowly raise your hand and the copter will rise
-
NORMAL: in NORMAL mode, you are responsible for thrust (height), pitch (forwards and back), and roll. It is advised to reach a desired altitude in NORMAL and then switch to HOVER
-
HOVER: in HOVER mode, the copter holds a steady height and you are responsible for pitch, roll, and yaw. Keep your hand at a steady height in order to not change yaw unless necessary
-
LAND -> NORMAL: show the leap 1 hand (your dominant, flying hand)
-
NORMAL -> HOVER: show 3 or more fingers with your unused hand
-
NORMAL -> LAND: remove hand OR make hand into fist
-
HOVER -> NORMAL: show 2 or more fingers with your unused hand
-
HOVER -> LAND: flash a fist with your unused hand and then also make your dominant hand into a fist
Note: the propeller between the red and green lights is "forward". See more here.