Notes on getting started with interactive control of the Crazyflie 2.1 drone.
This tutorial walks through how to set up and fly a Crazyflie 2.1 drone with a PC and PS4 Controller.
- (1) Crazyflie 2.1
- (1) Crazyradio PA dongle
- (1) PS4 Controller
- (1) Battery Charger Bundle(Suggested)
- (1) 3D Printed Propeller Guard(Suggested)
- Install the Crazyflie Client on your PC
- Follow instructions for your OS from the github repo: https://github.com/bitcraze/crazyflie-clients-python
- Unpack, Test, Assemble, Update, and Configure your Crazyflie.
- Don't forget to update the firmware.
- Connect the Crazyflie to the Crazyflie Client.
- Plug in the Crazyradio PA.
- Connect your PS4 to the PC.
- Open the Crazyflie Client; in terminal run:
$ cfclient
- Read the Crazyflie Client User Guide. A few things to note:
- In the client, make sure all the trim variables are set to
0
to start. - Turn on the Crazyflie drone by pressing the
ON/OFF
button near the top right of the body. - In the Crazyflie Client, press the
Scan
button to set the Crazyradio PA as the client's interface.- If the drone connected to the Crazyradio PA, it should be blinking red (about once every second).
- Connect the PS4 to the Client by going to the dropdown menu
Input Device
, and selecting Device > PS4 Controller. - Connect the Crazyflie to the PC by hitting the
Connect
Button.- If the drone connected to the PC, you should be getting live IMU readings in the Crazyflie Client.
- Start Flying. Once the input device is connect, here's how to see what button does what:
- Go to Input device > Configure device mapping > Profile Name (at the bottom) > Load
- Once you load a profile, you can press buttons on the joystick and you should see the parameters updating live.
- More info here: https://wiki.bitcraze.io/doc:crazyflie:client:pycfclient:index#input_devices
But in general, there's not a lot of info / explainers for how to fly with a joystick.
- This has the best explanation, but the details are only for when flying with LPS.
- Depending on your configuration, here are a few tidbits:
- Press the
O
button once to start motors.- YOU HAVE TO PRESS AND HOLD THE
O
BUTTON TO DISABLE THE MOTORS.
- YOU HAVE TO PRESS AND HOLD THE
- RIGHT joystick UP/DN is thrust(+/-) <-- Z(+/-)
- RIGHT joystick LEFT/RIGHT is yaw(+/-) <-- Rz(+/-)
- LEFT joystick UP/DN is X(+/-) <-- maybe Rx(+/-)?
- LEFT joystick LEFT/RIGHT is Y(+/-) <-- maybe Ry(+/-)?
- Press the
- Stop Flying.
- You can press-and-hold the
O
button to disable the drone motors. - Once the drone has landed, press the
Disconnect
Button in the Crazyflie Client to end communication. - Now you can turn off the Crazyflie drone by pressing the
ON/OFF
button (you don't need to long press).
This tutorial walks through how to set up Bitcraze's Loco Positioning System (LPS) to work with the Crazyflie drone. The LPS provides absolute positioning (in the 10cm range).
- (8) LPS Nodes
- (1 per drone) LPS Deck
- (8) 3D Printed Stands for the Nodes
- (8) Power Supplies for the Nodes
- Can be any 5V-12V, 150mAmp power supply (25' micro USB cables work)
- Configure, Install, and Calibrate the 8 LPS Nodes.
- LPS Tools Notes:
- LPS Wiki: https://wiki.bitcraze.io/doc:lps:index
- To run the LPS Tools GUI from terminal:
python3 -m lpstools
- You really have to press-and-hold the
DFU
button as you plug in the board to bootload new firmware
- Installation Notes:
- Print 1 stand per anchor
- "The anchor antenna should be placed 15cm from any wall, ceiling or metal object to avoid interfering reflections."
- Each of the nodes needs to be powered — I found that long (25') micro USB cables work well.
- USB cables over 15' are POWER ONLY ... no data.
- Flying Notes:
- You can preview and set the Gamepad buttons using the Input device > Configure device mapping tab. Hit the
Configure
button, and then load a preset to see what buttons do what. - After a crash, look at the Loco Positioning Tab: the LPS is often very, very wrong (meters off), and flying using the
Assisted Control
button will send the drone way off. Turn off the drone and reconnect to try to correct the calibration error. - The drone's battery is too low to reliably fly at around
3.7V
. Swap the battery to avoid a crash.
- You can preview and set the Gamepad buttons using the Input device > Configure device mapping tab. Hit the
Here are a few good examples from crazyflie-lib-python
to run for basic autonomous flying:
example/positioning/intialPosition.py
example/autonomousSequence.py
example/autonomous_sequence_high_level.py
Begin by reading the docs on the Crazyflie Python API
It took me a while to understand how use the Crazyflie API to access all the information and parameters you can visualize cfclient
:
- Here's my original question on the Bitcraze Forum: Streaming multiple crazyflie positions from LPS over UDP
- You can add asynchronous callbacks onto certain variables using the Logging and Parameter frameworks.
- Use Logging when you want continuous updates.
- Use Parameters for rare updates (like on start up or shut down).
- More info about Logging here: https://wiki.bitcraze.io/doc:crazyflie:client:pycfclient:index#logging
- More about the ToCs and Logging vs Parameters: here
- Implementation Details about Logging: here
It also wasn't immediately obvious what all the parameters were, and how to see the Logging or Parameter ToCs:
- You can see them by opening the
cfclient
Parameter and Logging tabs, and connecting a Bitcraze. - These are cleared once you disconnect.
Finally, once I could see them, it wasn't clear what each variable did:
- There's currently no good documentation for this from Bitcaze, so contact support or ask the forum.
- The position estimate from the LPS is stored in
kalman.stateX
,kalman.stateY
,kalman.stateZ
Here are a few good examples from crazyflie-lib-python
that helped me understand logging with the crazyflie:
example/basicLogging.py
example/autonomousSequence.py