I've been attempting to fly a Crazyflie using a Flow Deck, an LPS deck (8 anchor setup), and with both attached simultaneously. When I fly using only the flow deck, the CF can follow my instructions fairly well (I'm testing with a python script, attached below), keeping very close to the predetermined instructions. When I fly with only the LPS deck, the CF is able to hover and reach a stable position in the air, but consistently veers off course and out of the area my anchors enclose (which I will confess is small, approximately 2x4x3m). When both boards are attached at once, the CF splits the difference - it still veers off course and sometimes leaves the enclosure, but still is clearly attempting to complete each step of the process.
This perplexes me, because I would have thought it would be better than the sum of its parts when both are attached - rather than the LPS deck hindering the Flow deck. Any thoughts on why this might be, or how I can get the two boards to cooperate?
Thanks!
Code: Select all
import logging
import time
import cflib.crtp
from cflib.crazyflie import Crazyflie
from cflib.crazyflie.log import LogConfig
from cflib.crazyflie.syncCrazyflie import SyncCrazyflie
from cflib.positioning.motion_commander import MotionCommander
URI = 'radio://0/100/2M/E7E7E7E701'
DEFAULT_HEIGHT = 0.5
is_deck_attached = True
logging.basicConfig(level=logging.ERROR)
position_estimate = [0, 0, 0]
def move_linear_simple(scf):
with MotionCommander(scf, default_height=DEFAULT_HEIGHT) as mc:
time.sleep(1)
mc.forward(1)
time.sleep(1)
mc.turn_left(90)
time.sleep(1)
mc.right(0.5)
time.sleep(1)
mc.left(0.5)
time.sleep(1)
mc.turn_right(90)
time.sleep(1)
mc.back(1)
time.sleep(1)
mc.up(0.5)
time.sleep(1)
mc.down(0.5)
time.sleep(2)
def take_off_simple(scf):
...
def log_pos_callback(timestamp, data, logconf):
'''print(data)'''
global position_estimate
position_estimate[0] = data['stateEstimate.x']
position_estimate[1] = data['stateEstimate.y']
position_estimate[2] = data['stateEstimate.z']
print("{",position_estimate[0], ",",position_estimate[1], ",",position_estimate[2], "}, ")
def param_deck_flow(name, value_str):
...
if __name__ == '__main__':
cflib.crtp.init_drivers()
with SyncCrazyflie(URI, cf=Crazyflie(rw_cache='./cache')) as scf:
scf.cf.param.add_update_callback(group='deck', name='bcFlow2',
cb=param_deck_flow)
time.sleep(1)
logconf = LogConfig(name='Position', period_in_ms=10)
logconf.add_variable('stateEstimate.x', 'float')
logconf.add_variable('stateEstimate.y', 'float')
logconf.add_variable('stateEstimate.z', 'float')
scf.cf.log.add_config(logconf)
logconf.data_received_cb.add_callback(log_pos_callback)
if is_deck_attached:
logconf.start()
move_linear_simple(scf)
logconf.stop()