MAVSDK-Python: goto_location results in the aircraft descending to 0m alt and crashing

I have tried the following multiple times, with varying altitudes and airframes (Iris and Plane). However each time this is called, the UAV seemingly just descends until it lands.

#!/usr/bin/env python3

import asyncio
from mavsdk import System, mission_raw

async def run():
    drone = System()
    await drone.connect(system_address="udp://:14540")

    print("Waiting for drone to connect...")
    async for state in drone.core.connection_state():
        if state.is_connected:
            print(f"Drone discovered with UUID: {state.uuid}")
            break
    
    await drone.action.goto_location(55.8688660,-4.2851267,40,0)

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run())

System:

  • Ubuntu 18.04 LTS
  • Gazebo 9
  • PX4 master

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 24 (3 by maintainers)

Most upvoted comments

Ok, good point @hamishwillee and @iwishiwasaneagle. In this case it I would suggest goto_location_home_relative_altitude 😃.

If it’s just a matter of preferences, I like 1 better šŸ˜‡:

  1. goto_location_absolute_altitude() and goto_location_relative_altitude()

EDIT: but then, how does ā€œhomeā€ and ā€œterrainā€ go in there?

One object-oriented way I could imagine would be to do:

goto_location(double lat, double lng, Altitude alt);

With Altitude being an abstract class, so you would have to instantiate one of AltitudeAboveTerrain, AltitudeAboveHome, AltitudeAboveSeaLevel or something like that. But we can’t generate that kind of stuff from our proto files, and I don’t know if that would generalize well to all languages šŸ¤”ā€¦

So I like option 2.

But ideally while I would default it to using home-based altitude I would not restrict it to home because if terrain becomes available a lot of people will prefer that (and some might want AMSL). So if you can have a default and use home for that would be ideal.

And yes, you’d then probably have RESULT_HOME_UNKNOWN or RESULT_TERRAIN_UNKNOWN returned based on the type used.

If you can’t support the options then perhaps multiple methods. In that case the home one would be goto and the other methods might be goto_amsl, goto_terrain or whatever. Don’t like that as much.

Ok, thanks for all that info, that’s very helpful. I had only tried iris before, not plane. I did a few tries and plane sometimes seemed to do the right thing and other times get too low and crash. For iris it now doesn’t work anymore but just seems to go sideways at a weird angle, and keep going forever. It’s very odd, I’m looking into it.

Hmm ok, so apparently something changed in PX4. Question now is whether that’s a bug in PX4 or in MAVDSK.