Flow Deck Read Current Altitude

Post here to get support
Post Reply
willv
Beginner
Posts: 7
Joined: Fri Jul 06, 2018 2:28 pm

Flow Deck Read Current Altitude

Post by willv » Mon Jul 30, 2018 4:05 pm

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.

arnaud
Bitcraze
Posts: 1750
Joined: Tue Feb 06, 2007 12:36 pm

Re: Flow Deck Read Current Altitude

Post by arnaud » Thu Aug 02, 2018 2:28 pm

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.

willv
Beginner
Posts: 7
Joined: Fri Jul 06, 2018 2:28 pm

Re: Flow Deck Read Current Altitude

Post by willv » Fri Aug 03, 2018 5:30 pm

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:
                time.sleep(0.001)
                print('wait')
            if num == 0:
                getNextPos(currentPos)
            while nextPos[0] == 0 or nextPos[1] == 0 or nextPos[2] == 0:
                time.sleep(0.001)
                print('wait2')
            #poshold(cf,1,nextPos[num])

            if time.time() > endTime:
                break
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?

Post Reply