How do I output "MAV_LANDED_STATE" using Python?

I’ve reached the last major roadblock (I think) in my project. Here’s my sequence of events:

  1. Run Python script. Identify initial altitude. (Motors are not armed.)
  2. Manually lower quadcopter from side of building. When current altitude is (initial altitude - 1.0) activate servo.
  3. Script.Sleep for 5 seconds
  4. Arm motors
  5. Script.Sleep for 5 seconds.
  6. Begin Land mode
  7. Print roll and pitch upon landing
    My problem is that step 6- land mode- is not working.
    Script.ChangeMode(“Land”) and Script.ChangeMode(“LAND”) do not work. In fact the motors stop spinning immediately (several pause lengths were tested before activating land mode- it was definitely the setting of the land mode that stopped the motors).
    I’m about to try:
    MAV.doCommand(MAVLink.MAV_CMD.DO_LAND_START, 0, 0, 0, 0, 0, 0, 0)
    However, I thought it would be helpful to output the MAV_LANDED_STATE, because it could be that the landed mode is detecting that the quad has already landed and therefore shuts down the motors. Part of me is concerned that the negative altitude (since I’m lowering it from the side of a building) is the problem. I just don’t know how to print out the landed state using Python, so if anyone could help me with that line I’d appreciate it.
    If the doCommand doesn’t work, I might try writing my own landing sequence code. I don’t think it’d be too hard- I just need to make sure it stabilizes along the way while I adjust the throttle.
1 Like

Didi you get the codes for auto landing?

currently my project is on pixhawk. i need to get the landing code. if you get this working, kindly share the landing codes with me.

my email id is

Hi @AdamWex and @rijun034,

So, you are using a python script on the Mission Planner panel right?

Here you can see an available MAVLink commands that could be type in (MAVLink.MAV_CMD.)
Please see from the line 563.

At first, I would recommend you to use this command:
MAV.doCommand(MAVLink.MAV_CMD.LAND_LOCAL, 0, 0, 0, 0, 0, 0, 0)