Page 1 of 1

Flow Deck Read Current Altitude

Posted: Mon Jul 30, 2018 4:05 pm
by willv
I'm wondering if it is possible to communicate to the computer during flight the current height of the drone using the flow deck.

EDIT: I see that within the client when connected, the altitude is displayed real time, so I guess I'm wondering how I would access that height within python.

One way I can think of is to use the logger; I can get the logger to return the height data but I'm not sure how to return that data while still flying the drone.

Re: Flow Deck Read Current Altitude

Posted: Thu Aug 02, 2018 2:28 pm
by arnaud
Crazyflie has a log subsystem that is designed to do exactly this kind of things.

Where do you want the height?

In the client you can create log blocks and plot them or record them in a CSV file. If you want the height in your own program you have the option of either making your own control script or making a tab in the graphical client to get the height during manual flight.

Re: Flow Deck Read Current Altitude

Posted: Fri Aug 03, 2018 5:30 pm
by willv
My goal is to autonomously control the heights of multiple drones based on the current height reading of some of the other drones. (using the python scripts)

Code: Select all

log_config = LogConfig(name='Height', period_in_ms=1000)
log_config.add_variable('stateEstimate.z', 'float')
with SyncLogger(scf, log_config) as logger:
        endTime = time.time() + 10
        for log_entry in logger:
            data = log_entry[1]
            currentPos[num] = data['stateEstimate.z']

            while currentPos[0] == 0 or currentPos[1] == 0 or currentPos[2] == 0:
            if num == 0:
            while nextPos[0] == 0 or nextPos[1] == 0 or nextPos[2] == 0:

            if time.time() > endTime:
This worked for me. However, I was to have differing period_in_ms and poshold times, but for log_entry in logger iterates through the logger, thus taking the next log file, not the most recent. Is there a way to more easily find the most recent log file in logger (maybe iterate through to the end?)? Or a way to instead of using the logger to just send the current height reading back to the control pc?