Anafi Work - Olympe moveTo drone just hovers and doesn't change position

Tried multiple variations of this code to get the drone to move a short distance using moveTo , drone takes off and just hovers , here is the code

assert drone(
      TakeOff()
      >> FlyingStateChanged(state="hovering", _timeout=5)
  ).wait().success()
  drone(
      moveTo(39.685558101, -105.121048201, 3,mode.orientation_mode.to_target,0.0)
      >> moveToChanged(status=status.DONE)
      >> FlyingStateChanged(state="hovering", _timeout=5)
  ).wait().success()
  assert drone(Landing()).wait().success()

drone.disconnect()

Logs:

2022-01-20 17:55:58,643 [INFO] olympe.drone.ANAFI-G055619 - _send_command_impl - ardrone3.Piloting.moveTo(latitude=39.685558101, longitude=-105.121048201, altitude=3.0, orientation_mode=‘to_target’, heading=0.0) has been sent to the device
2022-01-20 17:55:58,833 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=16)
2022-01-20 17:55:58,834 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=16)
2022-01-20 17:55:59,072 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=17)
2022-01-20 17:55:59,210 [INFO] olympe.drone.ANAFI-G055619 - _link_quality_cb - Link quality: tx=54, rx=100, rx_useful=97
2022-01-20 17:55:59,249 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=17)
2022-01-20 17:55:59,249 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - wifi.rssi_changed(rssi=-54)
2022-01-20 17:55:59,371 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=14)
2022-01-20 17:55:59,373 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=14)
2022-01-20 17:56:00,094 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - wifi.rssi_changed(rssi=-53)
2022-01-20 17:56:00,476 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=15)
2022-01-20 17:56:00,684 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=15)
2022-01-20 17:56:00,889 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=14)
2022-01-20 17:56:01,093 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=14)
2022-01-20 17:56:01,170 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=15)
2022-01-20 17:56:01,171 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=15)
2022-01-20 17:56:01,173 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - wifi.rssi_changed(rssi=-52)
2022-01-20 17:56:02,095 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - wifi.rssi_changed(rssi=-51)
2022-01-20 17:56:02,663 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=14)
2022-01-20 17:56:02,935 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=14)
2022-01-20 17:56:03,069 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=15)
2022-01-20 17:56:03,344 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=15)
2022-01-20 17:56:03,370 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=16)
2022-01-20 17:56:03,371 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=16)
2022-01-20 17:56:04,164 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - wifi.rssi_changed(rssi=-52)
2022-01-20 17:56:04,212 [INFO] olympe.drone.ANAFI-G055619 - _link_quality_cb - Link quality: tx=-1, rx=100, rx_useful=100
2022-01-20 17:56:04,667 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=15)
2022-01-20 17:56:04,982 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=15)
2022-01-20 17:56:05,801 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.PilotingState.moveToChanged(latitude=39.685558101, longitude=-105.121048201, altitude=3.0, orientation_mode=‘TO_TARGET’, heading=0.0, status=‘ERROR’)
2022-01-20 17:56:06,000 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=16)
2022-01-20 17:56:06,002 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=16)
2022-01-20 17:56:06,107 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - wifi.rssi_changed(rssi=-51)
2022-01-20 17:56:07,873 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=17)
2022-01-20 17:56:08,054 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=17)
2022-01-20 17:56:08,273 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=16)
2022-01-20 17:56:08,465 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=16)
2022-01-20 17:56:08,659 [INFO] olympe.drone.ANAFI-G055619 - _send_command_impl - ardrone3.Piloting.Landing() has been sent to the device
2022-01-20 17:56:08,664 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=15)
2022-01-20 17:56:08,665 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=15)
2022-01-20 17:56:08,723 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.PilotingState.FlyingStateChanged(state=‘landing’)
2022-01-20 17:56:08,726 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - follow_me.state(mode=‘none’, behavior=‘idle’, animation=‘none’, animation_available=’’)
2022-01-20 17:56:08,727 [INFO] olympe.drone.ANAFI-G055619 - _disconnected_cb - Disconnected from device: ANAFI-G055619
2022-01-20 17:56:08,728 [INFO] olympe.drone.ANAFI-G055619 - _disconnection_impl - disconnected from device: b’192.168.42.1’
2022-01-20 17:56:08,729 [INFO] olympe.drone.ANAFI-G055619 - disconnect - Disconnection with the device OK. IP: b’192.168.42.1’
2022-01-20 17:56:08,730 [INFO] olympe.pdraw.ANAFI-G055619 - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-5
2022-01-20 17:56:08,744 [INFO] olympe.drone - _on_device_removed - <olympe.arsdkng.cmd_itf.DisconnectedEvent object at 0x7efdddaebac0>
2022-01-20 17:56:08,746 [INFO] olympe.scheduler - _destroy_pomp_loop - Pomp loop has been destroyed: subscribers_thread
2022-01-20 17:56:08,746 [INFO] olympe.backend - _destroy - Manager has been destroyed
2022-01-20 17:56:08,746 [INFO] olympe.backend - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-1
2022-01-20 17:56:08,820 [INFO] olympe.drone.ANAFI-G055619 - _on_device_removed - <olympe.arsdkng.cmd_itf.DisconnectedEvent object at 0x7efdc1047bb0>
2022-01-20 17:56:08,836 [INFO] olympe.drone.ANAFI-G055619 - _on_device_removed - <olympe.arsdkng.cmd_itf.DisconnectedEvent object at 0x7efdc0f741f0>
2022-01-20 17:56:08,838 [INFO] olympe.scheduler - _destroy_pomp_loop - Pomp loop has been destroyed: subscribers_thread
2022-01-20 17:56:08,839 [INFO] olympe.backend - _destroy - Manager has been destroyed
2022-01-20 17:56:08,839 [INFO] olympe.backend - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-2
2022-01-20 17:56:08,916 [INFO] olympe.pdraw.ANAFI-G055619 - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-4
2022-01-20 17:56:08,922 [INFO] olympe.media.ANAFI-G055619 - _shutdown - olympe.media shutdown
2022-01-20 17:56:08,923 [INFO] olympe.media.ANAFI-G055619 - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-3

Hi @GavinatorK ,

I believe you need to specify the lat, long, and altitude you wish to reach when checking the state with moveToChanged, otherwise the default will be None for all three of those parameters. Try the following below.

    drone(TakeOff()).wait().success()
    
    drone(
        moveTo(39.685558101, -105.121048201, 3.0, mode.orientation_mode.to_target, 0.0)
        >> moveToChanged(latitude=39.685558101, longitude= -105.121048201, altitude=3.0, orientation_mode=mode.orientation_mode.to_target, status='DONE', _policy='wait')
    ).wait().success()

    drone(Landing()).wait().success()
    drone.disconnect()

Hi @teiszler

I was facing the same problem as OP and I tried ur solution. It didn’t work. The drone still hovers at the takeoff point and after a while just lands and disconnects. Do u hv any idea how to resolve this?

Hi @pravardhan ,

What does the output from the Olympe script look like? There are often log statements that indicate what is happening such as the command being received or issues like magnetic perturbations interfering. If the drone takes off, that indicates that you are connecting to the drone and at least the initial TakeOff command is successful. Can you paste in the Olympe output from running your script?

Hi @teiszler Thanks for your reply. I finally got it working. I don’t know what fixed it but I am guessing increasing the timeout helped. I am running sphinx simulator and it doesn’t run in real time so maybe that was the issue?
Anyway I am pasting my code here in case others face similar issue.

import olympe
import os
from olympe.messages.ardrone3.Piloting import TakeOff, moveBy, Landing, moveTo
from olympe.messages.ardrone3.PilotingState import FlyingStateChanged, moveToChanged
from olympe.enums import move

DRONE_IP = os.environ.get("DRONE_IP", "10.202.0.1")

def test_moveby2():

    drone = olympe.Drone(DRONE_IP)
    drone.connect()
    
    drone(
        TakeOff()
        >> FlyingStateChanged(state="hovering", _timeout=500)
    ).wait().success()

    drone(
        moveTo(48.880389100008024, 2.3714913999945955, 10.0, move.orientation_mode.to_target, 0.0)
        >> moveToChanged(latitude=48.880389100008024, longitude= 2.3714913999945955, altitude=10.0, orientation_mode=move.orientation_mode.to_target, status='DONE', _policy='wait')
    ).wait().success()

    drone(Landing()).wait().success()

    drone.disconnect()


if __name__ == "__main__":
    test_moveby2()
1 Like

Hi @pravardhan ,

Glad you got it working. I am not certain that checking for the hovering state is necessary. The simulator (well at least the 1.8 version with Gazebo), should show you the simulation rate at the bottom. Sometimes if the scene is very complicated this can drop to something like 0.5 which means it is running at half the speed of real time, but if you are using a minimal scene it is usually much closer to 1.0x.

Also, the proper etiquette would be to let @GavinatorK accept the solution since he opened the thread, rather than accept it on his behalf :slight_smile:

Hi @teiszler Thanks for ur help :smile:. I didn’t accept the solution tho, maybe someone else did. Anyway I removed it so OP can accept it.

Hi @teiszler

Thanks for your response, I have tried your code above and @pravardhan’s variation with hovering state. my result is still the same, Drone hovers in place and lands , Here are some observations from Log

2022-01-31 11:56:46,398 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - rth.takeoff_location(latitude=39.6856299999966, longitude=-105.12105283332957, altitude=2.0, fixed_before_takeoff=1)

_send_command_impl - ardrone3.Piloting.moveTo(latitude=39.685558101, longitude=-105.121048201, altitude=3.0, orientation_mode=‘to_target’, heading=0.0) has been sent to the device

2022-01-31 11:56:53,564 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - ardrone3.PilotingState.moveToChanged(latitude=39.685558101, longitude=-105.121048201, altitude=3.0, orientation_mode=‘TO_TARGET’, heading=0.0, status=‘ERROR’)
2022-01-31 11:56:53,857 [INFO] olympe.drone.ANAFI-G055619 - _recv_cmd_cb - wifi.rssi_changed(rssi=-51)

Note that this is in my backyard and working with a distance of about 25ft from take off to move to location.

i can give it a try later today in a park nearby with larger distance and see if it makes a difference.

Did you calibrate the drone using FreeFlight prior to testing? I was thinking it could be magnetic perturbations, but usually that prevents you from even taking off. The fact that it takes off, refuses to perform the moveTo and then lands is interesting. If it were to take off, and then just hover and never do anything after that, I would inquire as to whether or not you have the FreeFlight app open while you are sending commands via Olympe. This caused a similar problem for us when we were starting out. We would start the Olympe script and the drone would take off, but it would only move very slightly or not at all and then just stay put. This is because the FreeFlight app, if it is open, will acquire manual control and interrupt the script. This happens even if you aren’t actively using the controls in FreeFlight because the app maintains a heartbeat with the drone as long as the application is open.

2 Likes

Let me step outside and test a moveBy, it will confirm if that indeed is the case.

@teiszler you were spot on with your last explanation. when i ran the code with MoveBy which was previously working, it didn’t work , so I re calibrated the drone, camera, shut off the app and tried again, everything works like a charm

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.