LPS + Flow Deck flies worse than just the Flow Deck

All discussions related to the Loco Positioning system
Post Reply
DM7299
Member
Posts: 31
Joined: Sat Jun 05, 2021 6:04 pm

LPS + Flow Deck flies worse than just the Flow Deck

Post by DM7299 »

Hello,

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()
kimberly
Bitcraze
Posts: 852
Joined: Fri Jul 06, 2018 11:13 am

Re: LPS + Flow Deck flies worse than just the Flow Deck

Post by kimberly »

Hi!

There have been some reported issues with flowdeck and positioning deck (see this issue). But I'm not sure if you are seeing the same thing.

Could you perhaps just leave your crazyflie not flying and still on the ground, and look at the cfclient plotter tab (how to reach it you can see here). If you could produce a plot with the stateEstimate.x/y/z (see here how to make a logconfig) with the crazyflie with only the locodeck, and one with both the flowdeck and locodeck
DM7299
Member
Posts: 31
Joined: Sat Jun 05, 2021 6:04 pm

Re: LPS + Flow Deck flies worse than just the Flow Deck

Post by DM7299 »

Here's a trio of plots. I also realized I didn't mention - I currently have the setup on TDoA2.

This plot shows when only the LPS deck is attached - the position estimate fluctuates wildly.
Screen Shot 2021-07-09 at 11.34.06 AM.png
This plot is for when only the flow deck is attached - as expected, it has started itself at zero, and some values have begun to drift over time.
Screen Shot 2021-07-09 at 11.36.13 AM.png
This plot shows when both are attached together. Quite frankly, this seems reasonable - the z axis is solidly positioned, and x and y only fluctuate within the expected 10 cm of variance.
Screen Shot 2021-07-09 at 11.31.10 AM.png
Does this help answer any questions?
DM7299
Member
Posts: 31
Joined: Sat Jun 05, 2021 6:04 pm

Re: LPS + Flow Deck flies worse than just the Flow Deck

Post by DM7299 »

Another update: After testing the CF a few times and starting the code with it pointed in different directions, I've found that it always tends towards the same area when it drifts, moving out of the zone enclosed by the anchors towards where I have the Crazyradio set up. The radio may be a coincidence, but it's worth noting that it isn't that the CF always drifts left or always drifts right - it always drifts toward a specific side of the enclosure.
kimberly
Bitcraze
Posts: 852
Joined: Fri Jul 06, 2018 11:13 am

Re: LPS + Flow Deck flies worse than just the Flow Deck

Post by kimberly »

Ah I can see an potential problem with your last approach, of restarting the code in different directions.

The LPS system needs the Crazyflie to be initialized with the x axis to the front (see here the Crazyflie's coordinate system). This has to be done because the LPS system can not estimate yaw and this is purely done based on the onboard IMU (see here also the tutorial).

Is this indeed what is happening? or did I misunderstand you?
DM7299
Member
Posts: 31
Joined: Sat Jun 05, 2021 6:04 pm

Re: LPS + Flow Deck flies worse than just the Flow Deck

Post by DM7299 »

You're absolutely right! I'd forgotten one of the more basic rules, and had been starting my CFs pointed in all different directions. I'll make a few flights and see if the drift remains.
kimberly
Bitcraze
Posts: 852
Joined: Fri Jul 06, 2018 11:13 am

Re: LPS + Flow Deck flies worse than just the Flow Deck

Post by kimberly »

Ah no worries, i've made this mistake myself so many times, now with the LH system the yaw is already included, so everytime I switch back I forget that basic rule as well :D

Anyway, give us an update indeed !
DM7299
Member
Posts: 31
Joined: Sat Jun 05, 2021 6:04 pm

Re: LPS + Flow Deck flies worse than just the Flow Deck

Post by DM7299 »

Posting back here to update: when pointed in the correct direction, the Flow deck + LPS deck drones fly well! It seems a little less stable than the drones that only use the flow deck, but it remains within the 10 cm tolerance, and is worth it for the added functionality of understanding its position in space.
Post Reply