High Level Commander Questions

Discussions about autonomous flight in general, regardless of positioning method
Post Reply
DM7299
Member
Posts: 31
Joined: Sat Jun 05, 2021 6:04 pm

High Level Commander Questions

Post by DM7299 »

Hello,

I've been working with the Motion Commander to fly my CFs with a fair amount of success, but need to convert my code to use the HL Commander instead. I had some difficulties, though, and wanted to ask for pointers on how to set up the HL Commander to receive inputs midway through a flight - for example, logging the CF's position or checking proximity with the multiranger. How would I do this?

If it helps, I've attached a bit of sample code from one of the demos. What could be done to this code to make it log over time? I think I could use that kind of example to sort through the rest of it myself.

Code: Select all

def simple_sequence():
    with SyncCrazyflie(uri, cf=Crazyflie(rw_cache='./cache')) as scf:
        with PositionHlCommander(scf) as pc:
            pc.forward(1.0)
            pc.left(1.0)
            pc.back(1.0)
            pc.go_to(0.0, 0.0, 1.0)
Thank you!
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: High Level Commander Questions

Post by kimberly »

Hi!

So you are currently using the position high-level commander which is a wrapper around the high level commander class in python. The position HL commander will execute pc.forward(1.0) for example, blocks the rest of the script until the crazyflie has actually achieved the 1 meter (or technically, the amount of time to reach the 1 meter). So here you can't do much within the same loop as this script is running. So there are two things you can do:

1- Keep using the PositionHLCommander and setup Asynchronous logging (so that runs in a seperate loop). However, if you want to make a statemchine like of approach, as the crazyflie reacts on the multiranger input, this might not be handy to do.
1- Use the nonblocking functions of the HLcommander class (Check out this example and setup the logging in between of the commands.

How to setup sync or async logging, I would recommend looking at the logging tutorial on the cflib repository
Post Reply