We are using a pixhawk cube with PX4 1.8.2.
Also we have a companion computer that connected through UART to the pixhawk.
Using mavros we do all communication.
Our algorithm of the end of landing:
we sent the velocity vector to the copter using /mavros/setpoint_raw/local
after copter reached a desired point we sent MAV_CMD_COMPONENT_ARM_DISARM
we continue to send the velocity setpoints
we are waiting on the /mavros/state topic to get armed: False state
after we get disarmed copter we stop to send velocity setpoints
And usually all goes well, but sometime we get Failsafe enabled: no offboard.
It’s ok, but failsafe is configured to return to home and copter try to rich 20m height inside landing box. So, it can easily lead to crash.
Our short investigation shown, that PX4 processed the command MAV_CMD_COMPONENT_ARM_DISARM and told to mavros that copter is disarmed. But it looks like here is some race conditions, and some parts of PX4 still think that copter is armed.
Reading the docs, it sounds like you’ll get this warning if you stop sending setpoints while you’re still in offboard mode. Any reason not to land in LAND mode/are you sure you’re out of offboard mode before you stop sending setpoints?
Thanks for your answer!
Yes, you are right and copter still in OFFBOARD mode, but it’s reported disarm.
In my opinion, if copter is sending “disarmed” state, so it shouldn’t do any other things, like triggering failsafe, should it?
The reason is we are doing very precise landing, so we need to do it using setpoint and offboard mode.
Probably not - but I’m not an expert. But assuming that in the first instance you just want a solution so you can keep on working … I’d try setting the mode to HOLD or similar before stopping offboard mode. An alternative is to try set https://docs.px4.io/en/advanced_config/parameter_reference.html#COM_OBL_RC_ACT to LAND - so if there is a timeout the vehicle won’t failsafe to RTL behaviour.
@JulianOes Can you answer these questions, or suggest someone else?
Should failsafes be disabled when landed and disarmed? Specifically I would expect the offboard mode to not trigger an RTL failsafe in this case.
Is there a preferred mode to switch offboard mode out of when landed in order to put it into an “idle” state?
I also can add, that one of the last messages in our ROS-logs is the log from mavros: FCU: DISARMED by arm/disarm component command. And I’m not sure, but it seems, that PX4 has processed MAV_CMD_COMPONENT_ARM_DISARM, but it didn’t done a disarm completely.
With a first glance, I’ve not found any evidences, that here is no race conditions. Sorry for my insistence, but could you explain me, where is the grantees in the code, that disarming and failsafe can’t happens simultaneously?
Oh, yes, I’ve wrote the code that can easily reproduce the situation, when a failsafe is enabled even if a copter reported a disarm.
It’s happens every time, if you stop sending the setpoints, but do not change a flight mode from OFFBOARD.
In this case, event if internally vehicle_status.armed_state != ARMED, firmware will trigger the failsafe.
If you have a code, that can flight by setpoints in offboard mode, just do this:
Takeoff by setpoint
Send ARM_DISARM to disarm copter
Wait for state.armed = false from /mavros/state topic.
Stop sending setpoins
And see the result.
I think, it relates to my previous replay.
Hope it’ll help @JulianOes