As I have indicated this method is OK for takeoff but don’t work for Landing as drift may occur in altitude estimation and UAV might hover some inch above the ground. Also it is not ‘clean’ as the drone does not know it’s a takeoff phase (not indicated in message)
The solution is to use SET_POSITION_TARGET_LOCAL_NED and ORing the bitmask with the value 0x2000 (land setpoint) or 0x1000 (Takeoff setpoint).
Thanks to ‘land setpoint bitmask’, even if the setpoint is above the real groud, the UAV will continue it’s descent until it reached the ground.
However it is a good idea to use current location for X and Y information (ensuring a vertical takeoff/landing)
It will move to the horizontal position you set but ignore the Z part of the setpoint as it will determine itself when its on the ground. To not get into a diagonal landing my recommendation is to first move to the landing spot on flight height and then engage the landing.
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.
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).
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
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?
Sorry I was in holiday and did not see your message 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 ?
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.
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 : https://github.com/PX4/Firmware/blob/master/Tools/mavlink_px4.py
I dont see any MAV_SET message as SET_POSITION_TARGET_LOCAL_NED.