Offboard automatic TakeOff / Landing using MAV_CMD_LAND/TAKEOFF_LOCAL


This will surely prove useful.

Wow, a lot of good information in this thread. Just a thought. If you are using LPE (which is the default in the latest firmware release), then you might want to add an optical flow to avoid any drifting.

That is something to consider.

Do you know the altitude range of the optical flow in meters?

If you happen to know anything about the “hidden bitmasks” related to setpoint modes, could you consider adding some input in this thread.

I would like some clarity on the topic.


We only use it for indoor test-flights, but I believe the altitude range is 5 meters.

No, I didn’t know about those “hidden bitmasks” either. I’m curious about that too so you might want to post that question in the PX4 Gitter as well.

Sounds Good,

My goal was to get a complete description in one place, So myself/future users don’t have to go searching everywhere.

Thanks again,


Did you reach this goal and posted the complete description?

1 Like

@tdo Do you set the is_takeoff_sp once or do you keep it enable until it reaches the desired_altitude (target.z)?

0b0001110111111000 vs 0b0000110111111000

I do set the is_takeoff_sp at takeoff and keep it until I reach at least 3 meters (even if the target z given is higher than 3 meters). At that point (3 meters), I switch to a ‘normal’ SET_POSITION_TARGET_LOCAL_NED message (without using the extra bitfield functionnality).

Here is my takeoff bitfield

(0x1000 | 0b110111000011)

Have you successfully flown your drone indoor?

Hi, happy to see this convenient way to realize takeoff/landing in offboard mode but that seems doesn’t work for me. I tried these bitmasks as you said. When I used this bitfield to takeoff,

the drone in JMAVSIM didn’t move. I expect the drone will take off to the default altitude. The target position was set as follows:
target.x = current.x
target.y = current.y
target.z = current.z

I really need your help, thank you.


From some time now I do use this bitfield for taking off (work with version 1.6.5) : (0x1000 | 0b100111000000)
For target.z you can try current.z - 5; (this will request a takeoff point 5 meters above the current location, as the z axis in inversed).

Are you in correct offboard mode. To do so you have to send a HEARTBEAT at 2Hz and a request to switch to offboard mode MAV_CMD_NAV_GUIDED_ENABLE.

And then you also need to arm the drone using MAV_CMD_COMPONENT_ARM_DISARM. These two command are ‘long command’ type.

Hope this will help you. I’ll be glad to help you if it’s not the case

Thank you,
I can arm the drone and takeoff, but I can not land as you said “even if the setpoint is above the real groud, the UAV will continue it’s descent until it reached the ground”. I set the LAND bitmask and target.z = current.z, but the drone do not land and hovering at current.z potion. Whether I need other configuration?

Thank you very much,
I finally land succeed using the bitmask by changing (0x2000 | 0b110111000011) to (0x2000 | 0b110111000111).

Sorry I was in holiday and did not see your message :frowning: my bad. I do use the same bitfield you have provided for landing with px4 1.6.5. ((0x2000 | 0b110111000111)).

Did you tried it on newer version of the px4 firmware ?

Thank you

Yes I tried it on px4 1.7.0.

Hi, i am also trying to landing/takeoff using the masking bits but havent been successful. i am able to move the drone using /setpoint_raw/local topic (movement via both position and velocity works). but when i set the landing bit 0x2000 or takeoff bit, the drone stays at the same spot. here is my setpoint_raw msg for landing (the drones hovers at a fixed point). not sure what i am doing wrong.

  seq: 476
secs: 1536097946
nsecs: 216237762
  frame_id: ''
coordinate_frame: 1
type_mask: 11719
  x: 0.0
  y: 0.0
  z: 0.0
  x: 0.0
  y: 0.0
  z: -1.0
  x: 0.0
  y: 0.0
  z: 0.5
yaw: 0.0
yaw_rate: 0.0

Hey, i am new to dronekit.
I am working on flying the quad using NED as i want to test the drone indoors. I am able to change the mode and arm the vehicle, but i cant seem to find a message to take off using NED. and altitude.
I dont see any command referenced in the :
I dont see any MAV_SET message as SET_POSITION_TARGET_LOCAL_NED.

Can you please help me out.

1 Like

Indoor, use Mavros or dronecore. Dronekit is awesome for normal missions management and fast applications outdoor.

1 Like

Hey Alexis, Thanks a lot for replying.
I see that dronecore does not have a Python API yet or am I missing something?

Not yet, mavros can but you’ll need a lot of deps.

Dronecore can already be used with python but not yet officially released