If you love to develop with your Crazyflie I’ve no doubt you will want to get your hands on its newest deck, the Flow Deck. You can grab it on the Seeed Bazaar for just $35! It features a flow sensor (a camera sensor with attached processor) and a laser distance sensor which together allows the flight controller to know the drones velocity and acceleration. This provides location awareness and allows the drone to hold its position by itself. While this deck can be used to help manually fly the drone its true use and power lies in the ability to grant the drone autonomous flight without an expensive external positioning system.
To get this working you attach the Flow Deck to the bottom of your Crazyflie as normal for decks – it is simple and labeled so there will be no confusion. The developers over at bitcraze.io have put out new firmware which contains the code required to use the Flow Deck, so an update is required and will also need the Crazyradio PA. Once you have updated your firmware you can simply snap in the deck and it will be recognized as soon as you power on your drone. Again, you can do manual flight, but this is only currently supported when you have a controller – not through the phone app.
The other more exciting option is to have the drone fly autonomously. All the tools to do so are up on their GitHub, as well as the installation instructions. Note: I am running on macOS Sierra 10.12. It’s pretty simple to get it up and running as long as you have some minor experience with Python. I’m a bit rusty and it took me roughly an hour to get everything up and running, though I think most of the time was due to a slow internet connection on my side. This was quick and painless to get the client running. They do have an installer for Windows, which I am sure makes the installation quicker and very simple. Once you have the client and library installed you can run the demo program, which you can see in the video above.
Note: You cannot use the radio with the Crazyflie client and run the python script at the same time. Please learn from my 30 minutes of confusion!
The python script I used for autonomous flight (the figure 8) is slightly edited from the default – I wanted it to fly up a bit higher on the second half to show changing height in the video. I did do a few custom flight paths for fun, but forgot to record them. My favorite was getting the drone to make a spiral, starting smaller and growing in radius. Here’s my code!
<pre># -*- coding: utf-8 -*-
# || ____ _ __
# +——+ / __ )(_) /_______________ _____ ___
# | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
# +——+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
# || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
# Copyright (C) 2016 Bitcraze AB
# Crazyflie Nano Quadcopter Client
# 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; either version 2
# of the License, or (at your option) any later version.
# 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
Simple example that connects to the crazyflie at `URI` and runs a 8 sequence.
This script requires some kind of location system, it has been tested with
(and designed for) the flow deck.
Change the URI variable to your Crazyflie configuration.
from cflib.crazyflie.syncCrazyflie import SyncCrazyflie
URI = ‘radio://0/80/250K’
# Only output errors from the logging framework
if __name__ == ‘__main__’:
# Initialize the low-level drivers (don’t list the debug drivers)
with SyncCrazyflie(URI) as scf:
cf = scf.cf
#Pop up in the air to start.
for _ in range(10):
cf.commander.send_hover_setpoint(0, 0, 0, 0.2)
#Altitude for flight.
for _ in range(15):
cf.commander.send_hover_setpoint(0, 0, 0, 0.4)
#Start Spiral, Spiral for 17 seconds (Each loop is 0.1s)
#Spiral starts small, grows larger
#I didn’t want to use decimal on my side, so I used 800/10
#to have an initial yawrate of 80 degrees/s
#Note: send_hover_setpoint(self, vx, vy, yawrate, zdistance)
#Velocity (vx,vy) are in m/s, yawrate is degrees/s, zdistance is in m
yr = 800
for _ in range (170):
cf.commander.send_hover_setpoint(0.7, 0, (yr/10), 0.4)
#I decrease the yawrate by 0.4 rad/s each 1/10 seconds.
yr -= 4
#Stop and lower itself for landing
for _ in range(30):
cf.commander.send_hover_setpoint(0, 0, 0, 0.2)
#Kill motors and land
Since I am not well versed in Python I didn’t go much further, yet I still found the experience enjoyable and easy. I look forward to see what the Crazyflie community creates with the Flow Deck.
Please leave comments and suggestions! Your feedback is appreciated.