I bought 2 Crazyflies. They are too cool and I will use them in my Thesis. I can send a command to CF, But I have some problems with them.
1- How can I read Log data without using object ? (on the otherhand use basic python code.)
2- How can I read Z ranger deck ?
Code: Select all
import logging
import time
import logging
import time
from threading import Thread
import cflib
from cflib.crazyflie import Crazyflie
from cflib.crazyflie.log import LogConfig
logging.basicConfig(level=logging.ERROR)
values = [0,0,0]
cflib.crtp.init_drivers(enable_debug_driver=False)
cf = Crazyflie()
available = cflib.crtp.scan_interfaces()
print(available)
a = cf.open_link(available[0][0])
cf.commander.send_setpoint(0, 0, 0, 0)
print('Bağlandı!')
def position_callback(timestamp, data, logconf):
Roll = data['Roll']
Pitch = data['Pitch']
Yaw = data['Yaw']
print('Rot: ({}, {}, {})'.format(Roll, Pitch, Yaw))
log_conf = LogConfig(name='Read:', period_in_ms=100)
log_conf.add_variable('Roll', 'float')
log_conf.add_variable('Pitch', 'float')
log_conf.add_variable('Yaw', 'float')
a.cf.log.add_config(log_conf)
a.data_received_cb.add_callback(position_callback)
a.start()
while True:
Output_Value = [Roll,Pitch,Yaw]
print(Output_Value)
cf.commander.send_setpoint(0, 0, 0, 12000)
time.sleep(0.01)
cf.close_link()
print('Bağlantı Koptu')