Can not get the anafi to move using the moveBy command

I am currently using the following code to try to fly the anafi. The anafi will connect takeoff, send the moveBy command, wait the 25 seconds, land and then disconnect. The anafi just will not move. I read that if may have problem in doors, so I took it out on the back porch and it still would not fly.

I get a moveByEnd with error code “Ok”.
The moveByEnd shows no change in the dx, dy, dz

I’m using a raspberry pi and with an olympe enviroment.

-- coding: UTF-8 --

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

drone = olympe.Drone(“192.168.42.1”)

print("\n\n connection command\n\n")
drone.connection()

print("\n\n Take off command\n\n")
drone(TakeOff() >> FlyingStateChanged(state=“hovering”, _policy=“wait”, _timeout=15)).wait()
print("\n\n",drone.get_state(FlyingStateChanged)[“state”],"\n\n")

print("\n\nMove by command\n\n")
drone(moveBy(0.5, 0, 0, 0) >> FlyingStateChanged(state=“hovering”, _policy=“wait”, _timeout=25)).wait()
print("\n\n",drone.get_state(FlyingStateChanged)[“state”],"\n\n")

print("\n\n Landing command\n\n")
drone(Landing()).wait()

print("\n\n Disconnect command\n\n")
drone.disconnection()

1 Like

Did you test your code on sphinx simulator and it worked there? See if this works.

dX = 4
dY = 0
dZ = 0
# Clear the screen.
os.system('clear')
print("################# Tell drone to moveby #################")
print("dX  =   ",dX)
print("dY  =   ",dY)
print("dZ  =   ",dZ)
print("#########################################################")
drone(
    # Example:   moveBy(dX,dY,dZ,dPsi,_timeout=20,_no_expect=False,_float_tol=(1e-07, 1e-09))
    # dPsi is drone rotation during move (angle in radians (pi rad = 180deg))	
    # If you tell the drone to rotate it can sometimes go crazy. Better to set to zero. 
    moveBy(dX,dY,dZ,dPsi=0)
    #  The moveBy command, issued above, waits for a moveByEnd event msg when the 
    #  drone has finished moving. For this reason I do not need to use a movebyEnd 
    #  command to see is the movebyEnd message has been sent. (is this correct ?) 
    #
    #  Once the drone finishes a moveBy motion it is supposed to enter the hovering state
    #  but it does not (a bug). So, force the drone into a hover state with PCMD command.  
    >> PCMD(1, 0, 0, 0, 0, 0)
    # Wait for drone to be in hovering state
    >> FlyingStateChanged(state="hovering", _timeout=5)
).wait().success()
1 Like