mavlink / MAVSDK-Python

MAVSDK client for Python.
https://mavsdk.mavlink.io
BSD 3-Clause "New" or "Revised" License
327 stars 221 forks source link

GPS estimate doesn't work via MAVSDK-Python, but it works well from QGC #137

Closed ramgrandhi closed 4 years ago

ramgrandhi commented 5 years ago

Hello - It's a Question, i don't know how to label this one.

I'm trying to run takeoff_and_land.py from examples. Managed to connect pixhawk4 via USB/serial from python. However, it waits forever to obtain global position estimate. However, when I open up QGC - it was able to locate 7 satellites and has a decent position estimate established (see screenshot below).

Waiting for mavsdk_server to be ready... Connected to mavsdk_server! Waiting for drone to connect... Drone discovered with UUID: 354667xxxxxxxxx. Waiting for drone to have a global position estimate...

image

Appreciate your thoughts!

cheers, ram

ramgrandhi commented 5 years ago

Ah, now it works (after say 2-3 mins of waiting for GPS -- it says GPS OK :) -- I wasn't patient enough I guess. Sorry for that!

However, the issue is with Arming itself. It throws:

await drone.action.arm() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mavsdk/generated/action.py", line 230, in arm raise ActionError(result, "arm()") mavsdk.generated.action.ActionError: COMMAND_DENIED: 'Command denied'; origin: arm(); params: ()

Question: Why is it taking over 2-3 minutes for GPS lock. Are there any techniques which can bring it down? Like how QGC is figuring it out in near realtime?

Appreciate your thoughts!

cheers, ram

julianoes commented 5 years ago

The GPS information displayed in QGC is not necessarily what is required for PX4 to decide that the position estimate is good enough to fly. What counts is if PX4 has a global position estimate that is good enough and that's what MAVSDK tries to grab.

@maetugr is working on improving these preflight checks and how they are visualized.

Things that influence GPS signal:

ramgrandhi commented 5 years ago

Thanks @julianoes for describing what's behind why is_global_position_ok: False!

Would like to have more feedback/metadata on preflight checks as they are going on inside. Despite the time it takes before returning is_global_position_ok: True, in my case, I still get COMMAND_DENIED when trying to arm(). And, I looked for all possibilities that I can including disabling safety switch on GPS, disconnecting/reconnecting RC, reconnect with QGC and close QGC etc.

Interesting thing is, MAVSDK was able to upload mission but just could not arm().

Do you see any checklist that I'm missing here before arm() ?

Here is my log takeoff_and_land.py:

MacBook-Pro:mav research$ python3 takeoff.py Waiting for mavsdk_server to be ready... Connected to mavsdk_server! Waiting for drone to connect... ConnectionState: [uuid: 35466xxxx, is_connected: True] Drone discovered with UUID: 35466xxxx Waiting for drone to have a global position estimate... Health: [is_gyrometer_calibration_ok: True, is_accelerometer_calibration_ok: True, is_magnetometer_calibration_ok: True, is_level_calibration_ok: True, is_local_position_ok: True, is_global_position_ok: True, is_home_position_ok: True] <async_generator object Core.connection_state at 0x108389868> Global position estimate ok -- Arming COMMAND_DENIED: 'Command denied'; origin: arm(); params: () -- Taking off -- Landing

Thanks again!

cheers, ram

julianoes commented 5 years ago

I suggest you open QGC next to it when you try to arm and maybe you'll see status text messages indicating what is wrong? There are other preflight checks which might be triggering.

ramgrandhi commented 4 years ago

Good tip, @julianoes - Thanks!

It seems that I cannot test MavSDK APIs when my laptop is tethered to pixhawk4 (with GPS mounted). QGC shows up two errors as the main reasons for not arming.

1) USB check failed (as it is tethered) 2) Very low voltage check

I would like to check if I'm in the right direction to build/test my MavSDK programs on real hardware without disabling USB checks and tinkering voltage numbers.

My goal is to test my programs as close to the real target hardware (pixhawk4 with px4).

Please advise.

cheers, ram

ramgrandhi commented 4 years ago

Never mind @julianoes .. i'm going with using headless-Gazebo to test my programs.

Courtesy: blog post here.

julianoes commented 4 years ago

Courtesy: blog post here.

I don't see what you meant to link there.

For the USB and voltage checks there are circuit breakers: https://dev.px4.io/master/en/advanced/parameter_reference.html#circuit-breaker

ramgrandhi commented 4 years ago

Thanks for the inputs! This can be closed. I resolved the issue after fixing the errors which QGC was throwing.