mavlink/MAVSDK-docs

takeoff command denied

Closed this issue · 5 comments

I've been trying to run the takeoff_and_land.py example on a live drone. The drone connects, it arms briefly (1-3 sec), then the motors stop and the result is COMMAND_DENIED: origin: takeoff(): params().
I can takeoff and even run missions directly from QGC without issue. Seems there's something QGC is doing that the example code is not.

Do you have a GPS signal?

Can you check if you can arm with QGC or if it shows any warnings/errors?

yes, 15 sats. I can arm with QGC, takeoff and run missions. - no warnings

Question: I see a set_takeoff_altitude action, but it is not set in the example. Is there a default altitude?

Ok, sorry to bombard with messages, pls. let me know if I'm breaking etiquette.
I added a sleep(5) after action.arm() and added messages before and after the takeoff command. Now it stays armed (motors spinning) until the takeoff command is issued, then the motors stop. Motors should spool up when takeoff is issued. Looks like script continues into landing mode after the sleep(10). I no longer get a COMMAND_DENIED message. Here's the output messages:

C:\AgVueApp>python takeoff_and_land.py
Waiting for mavsdk_server to be ready...
Connected to mavsdk_server!
Waiting for drone to connect...
Drone discovered with UUID: 255
Waiting for drone to have a global position estimate...
Global position estimate ok
-- Arming
-- Taking off - THIS IS BEFORE TAKEOFF COMMAND
-- Taking off STILL- THIS IS AFTER TAKEOFF COMMAND--
-- Landing
Press any key to continue . . .

As a side note, it stays in LAND mode after landing and will not arm again until the mode is reset in QGC or through an RC TX (much easier to flip a mode switch on the RC TX).
Thanks for your help!

I'm an idiot - was running Ardupilot, didn't realize MAVSDK only supports PX4. Loaded PX4 and all is well!