I’ve played a little around and I wanted to send long command with MAV_CMD_LAND_LOCAL and MAV_CMD_TAKEOFF_LOCAL instructions.
At beginning of the program I send a ‘null NED’ SET_POSITION_TARGET_LOCAL_NED at 4Hz whith a drone DISARMED.
This allow the Offboard mode to be enabled (as seen in QGC) then I arm it by MAV_CMD_COMPONENT_ARM_DISARM (still OK)
Then I stop sending SET_POSITION_TARGET_LOCAL_NED and start sending MAV_CMD_TAKEOFF_LOCAL command at 4Hz but the Autopilot leave offboard mode.
My intend was to send the MAV_CMD_TAKEOFF_LOCAL command at 4Hz until the status reported by EXTENDED_SYS_STATE indicates MAV_LANDED_STATE_IN_AIR. Then send SET_POSITION_TARGET_LOCAL_NED at 4Hz (like in the example) and finaly MAV_CMD_LAND_LOCAL at 4Hz until EXTENDED_SYS_STATE report MAV_LANDED_STATE_ON_GROUND to finally disarm the drone
If i don’t send SET_POSITION_TARGET_LOCAL_NED (during takeoff phase, and I suspect it will be the same for landing), the px4 leave the offboard mode.
What are valid command for offboard mode ? Is there some other commands for autmatic takeoff/landing in offboard mode ?
Takeoff is not so much of a trouble as I can use NED coordonate the ask for an altitude to be reached, the more troublesome is landing as a setpoint with ‘down’ value set to 0 let my UAV hover at 10cm from the ground (observed once with a F450).
I believe in order for offboard control mode to be enabled, offboard_control_mode ORB messages need to be continually published.
These messages are published by the mavlink receiver whenever the pixhawk receives either SET_POSITION_TARGET_LOCAL_NED messages, SET_ATTITUDE_TARGET, or SET_ACTUATOR_CONTROL_TARGET messages.
In other words, unless your companion computer regularly sets a target position, attitude, or motor input, then the vehicle will exit offboard control mode.
If you need to stay in offboard control mode, try publishing attitude targets, where you can simply command the attitude to some vector, such as [0,0,0]
I was afrad this was the reason. You’re giving me an Idea, I can keep sending SET_POSITION_TARGET_LOCAL_NED during takeoff/land phases with a bitmask telling to consider none of the information inside the message (or juste Yaw angle) and check if sending MAV_CMD_TAKEOFF_LOCAL at same time allows me to takeoff
By sending SET_POSITION_TARGET_LOCAL_NED messages with bitmask with value 0xFFFF, it allows me to stay in offboard mode.
However, I’m now facing a new trouble as it seems the MAV_CMD_TAKEOFF_LOCAL is not supported (QGC report Takeoff local command not supported and the led of pixhawk blink red as it does when it reject an improper flight mode)
I’ve tried with PX4 1.4.1 and 1.4.4. Perhaps there is another Takeoff/Land command I might use and that is working with offboard flight mode ?
I have had success getting the vehicle to takeoff by raising the altitude seetpoint in the local ned message
E.g
setpoint.z = -3;
then arm the vehicle.
It should shoot up like a rocket.
You won’t get to monitor the status unless you observe the position relative to the starting position
One more note, for effectiveness I would recommend resetting the setpoint target position to the current position similar to this
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