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)
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 š:
EDIT: but then, how does āhomeā and āterrainā go in there?
One object-oriented way I could imagine would be to do:
With
Altitude
being an abstract class, so you would have to instantiate one ofAltitudeAboveTerrain
,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, notplane
. I did a few tries andplane
sometimes seemed to do the right thing and other times get too low and crash. Foriris
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.