First of all a huge thanks to the cf developers for giving us an open source quadcopter, this is an awesome project! I am an computer science student and currently working on using gesture recognition to control my crazyflie 2.0. I am using a BLE device for gesture recognition but I am struggling with creating a custom input interface.
My goal is to read data sent from the BLE device, convert it into control input for the cfclient and then send it to the crazyflie. I already achieved reading data from the input device in a python script, however I am struggling to create a custom input interface which is being recognized by the cfclient. I tried copying some of the example code (leapmotion and wiimote) but never succeeded to get the BLE device being recognized as an input device.
Did anyone else try to create a custom input interface and ran into similar problems? What requirements does the input interface have to meet in order to be recognized by the cfclient? Would be great if somebody could point me in the right direction as I am pretty much stuck right now
cheers,
schmiddes
This is the code that reads data from the BLE device:
Code: Select all
import binascii
import bluepy
from bluepy import btle
#DELEGATE CLASS FOR NOTIFICATION
class MyDelegate(btle.DefaultDelegate):
def __init__(self):
btle.DefaultDelegate.__init__(self)
#BLE DEVICE SETTINGS
ble_uuid = btle.UUID("7ac71000-503d-4920-b000-acc000000001")
service_uuid = btle.UUID("bea5760d-503d-4920-b000-101e7306b000")
p = btle.Peripheral("BE:A5:7F:31:69:56")
p.setDelegate(MyDelegate())
#CHARACTERISTICS LIST
bleService = p.getServiceByUUID(service_uuid)
for ch in bleService.getCharacteristics():
print str(ch)
#OBTAIN DATA FROM CHARACTERISTIC
bleSensorValue = bleService.getCharacteristics(ble_uuid)[0]
val = bleSensorValue.read()
print "Characteristic value: ", binascii.b2a_hex(val)
#WAIT FOR NOTIFICATIONS
try:
while True:
#if p.waitForNotifications(1.0):
print "Characteristic value: ", binascii.b2a_hex(bleSensorValue.read())
continue
except:
print("Terminated")