simple question python code

Discussions about all things Bitcraze
Post Reply
crazyflying
Beginner
Posts: 20
Joined: Thu Oct 26, 2017 3:24 pm

simple question python code

Post 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
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: simple question python code

Post 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.
crazyflying
Beginner
Posts: 20
Joined: Thu Oct 26, 2017 3:24 pm

Re: simple question python code

Post 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
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: simple question python code

Post by tobias »

Kristoffer just pushed a simplified API :D . Have a look in this example.
Jens_Lee
Member
Posts: 40
Joined: Sun Nov 19, 2017 8:14 pm

Re: simple question python code

Post 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.
kristoffer
Bitcraze
Posts: 630
Joined: Tue Jun 30, 2015 7:47 am

Re: simple question python code

Post by kristoffer »

I just want to compliment the new Motion Commander
Thanks! I'm happy you liked it!
Post Reply