Using this portion of Code https://github.com/mavlink/c_uart_interface_example/ and HITL quadcopter (jmavsim) on the pixhawk, I've managed to have a raspberry pi (without ROS) communicating with the autopilot.
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).
Thank you for your help and advices