Page 1 of 1

simple question python code

Posted: Fri Nov 03, 2017 2:21 pm
by crazyflying
how can i get this to loop like a void loop in c++ arduino ?


at the end of this code figure of 8 it stops .but id like it to loop it there something simple i can add or does python not do that?

how can i loop this code forever https://github.com/bitcraze/crazyflie-l ... nceSync.py

regards batman in disguiese

merci les mec ciao

Re: simple question python code

Posted: Mon Nov 06, 2017 1:17 pm
by tobias
I would say it is pretty sime in python but you need the indentation to be correct. I've added a loop to run the figure 8 five times below:

Code: Select all

if __name__ == '__main__':
    # Initialize the low-level drivers (don't list the debug drivers)
    cflib.crtp.init_drivers(enable_debug_driver=False)

    with SyncCrazyflie(URI) as scf:
        cf = scf.cf

        cf.param.set_value('kalman.resetEstimation', '1')
        time.sleep(0.1)
        cf.param.set_value('kalman.resetEstimation', '0')
        time.sleep(2)

        for y in range(10):
            cf.commander.send_hover_setpoint(0, 0, 0, y / 25)
            time.sleep(0.1)

        for figure8loop in range (5):
            for _ in range(20):
                cf.commander.send_hover_setpoint(0, 0, 0, 0.4)
                time.sleep(0.1)

            for _ in range(50):
                cf.commander.send_hover_setpoint(0.5, 0, 36 * 2, 0.4)
                time.sleep(0.1)

            for _ in range(50):
                cf.commander.send_hover_setpoint(0.5, 0, -36 * 2, 0.4)
               time.sleep(0.1)

        for _ in range(20):
            cf.commander.send_hover_setpoint(0, 0, 0, 0.4)
            time.sleep(0.1)

        for y in range(10):
            cf.commander.send_hover_setpoint(0, 0, 0, (10 - y) / 25)
            time.sleep(0.1)

        cf.commander.send_stop_setpoint()
Remember though that the flow deck positioning isn't absolute which means the errors will build op and it will slowly drift away from its initial path.

Re: simple question python code

Posted: Thu Nov 23, 2017 4:14 pm
by crazyflying
ok and one last question haha...

as questions just seem to make more questions...

i have also seen that you were able to up the speed it runs the figure of eight how did you do this?

making the delay smaller or larger thrust more pitch yaw?

if i make a sequence how do i make it quicker?imagine i am using the example/flowsequency.py how to make it go faster than it does out of the box?

thanks man

Re: simple question python code

Posted: Mon Nov 27, 2017 4:00 pm
by tobias
Kristoffer just pushed a simplified API :D . Have a look in this example.

Re: simple question python code

Posted: Mon Nov 27, 2017 4:04 pm
by Jens_Lee
tobias wrote: Mon Nov 27, 2017 4:00 pm Kristoffer just pushed a simplified API :D . Have a look in this example.
I just want to compliment the new Motion Commander. I just ran my first tests, using the Flow deck, and it's a treat to do fairly complicated flightpaths with very few lines. My only notice is that the takeoff velocity seems a bit on the low side, as I've been drifting alot taking off. Changed it to 0.4 and that seems to help. Could just be random though.

Re: simple question python code

Posted: Tue Nov 28, 2017 9:18 am
by kristoffer
I just want to compliment the new Motion Commander
Thanks! I'm happy you liked it!