Using an ESP32 programmed using Arduino to interact with CrazyFlie MotionCommander API #1552
Replies: 1 comment 1 reply
-
Hi, There are, as far as I know, no ready-to-use library to control the Crazyflie over BLE from an ESP32. However the BLE protocol is documented and it is possible to achieve what you want. The BLE protocol is documented there: https://www.bitcraze.io/documentation/repository/crazyflie2-nrf-firmware/master/protocols/ble/. With this you should be able to send CRTP packets to the Crazyflie. Then, you will need to send motion commander commander packets. Even though you will have to build and send low level CRTP packet, as long as you only want motion command and are not interested in log and param for example, things should be as simple as sending a single type of packet. For motion command you need to send the "Hover" setpoint, this setpoint contains an absolute height and velocity X/Y commands. This is what the motion commander is generating: https://www.bitcraze.io/documentation/repository/crazyflie-firmware/master/functional-areas/crtp/crtp_generic_setpoint/#hover. The binary encoding of such packet would look like:
|
Beta Was this translation helpful? Give feedback.
-
I have been using an ESP32 breadboard design that I have named EEK: ESP32 Educational Kit (also have a PCB version of this) to fly a Tello drone. The software has been created with the Arduino IDE (latest 2.x version)
I recently adapted this hardware and software to communicate with a Python wrapper running on my host (using a Mac but Windows should also work) that uses the CrazyFlie radio dongle to relay control control commands coming from the EEK to the CrazyFlie. I have made several videos:
https://www.youtube.com/watch?v=WoIX1UGRwKo
https://www.youtube.com/watch?v=ems_P97hSn0
https://www.youtube.com/watch?v=1DGKaakXH4k
that demonstrate the work. The third video does not show the EEK but an Arduino Uno R4 board enclosed in a 3D printed case with a PCB hat plugged into the R4 exposing programmable buttons used to fly the CrazyFlie. This version is also based on one used to fly the Tello.
The EEK hardware allows ordinary gamepads like the Sony PS4 and Xbox controllers to serve as the interface to the ESP32 software that then sends MotionCommander calls through the Python relay program.
What I would like is some assistance with is the adaptation of the MCU hardware/software to use Bluetooth to send MotionCommander calls to the CrazyFlie and bypass the Python relay program. I know the iOS bitcraze App can use BLE to fly the CrazyFlie and the ESP32 is capable of BLE. I did not see examples about how to make this work if it's possible. I want granular control at the level provided in the MotionCommander API rather than sending direct micro control commands/packets to the Flie.
Does anyone have a suggestion where to go to see some code that might lead to a direct connection from my controller to the CrazyFlie?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions