Moveby.py olympe code

Hi, everyone. Can anybody help me?
I’m new to olympe and i’m having problems with the moveby.py.
I copied the code available on the parrot website, but it’s giving some problem with the first assert, so it just takes off and doesn’t do anything else.

# -*- coding: UTF-8 -*-

import olympe
from olympe.messages.ardrone3.Piloting import TakeOff, moveBy, Landing
from olympe.messages.ardrone3.PilotingState import FlyingStateChanged

DRONE_IP = "10.202.0.1"

if __name__ == "__main__":
    drone = olympe.Drone(DRONE_IP)
    drone.connect()
    assert drone(TakeOff() >> FlyingStateChanged(state="hovering", _timeout=5)).wait().success()
    assert drone(moveBy(10, 0, 0, 0) >> FlyingStateChanged(state="hovering", _timeout=5)).wait().success()
    assert drone(Landing()).wait().success()
    drone.disconnect()

Traceback (most recent call last):
  File "./moveby.py", line 12, in <module>
    assert drone(TakeOff() >> FlyingStateChanged(state="hovering", _timeout=5)).wait().success()
AssertionError

Are you using a physical drone or the simulator ?

1 Like

dont put assert in front of your commands… it should works

2 Likes

No, i used virtual drone with de sphinx and olympe.

I will try this. Thanks.

This works, but i have a question. Why with the assert it doesn’t work, since the code I put comes from the parrot site of the topic moveby?

Hi,

Have you tried increasing the FlyingStateChanged timeout value?
Sphinx and olympe are not running in the same clock which could lead to real time issues.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.