BRAKE mode (in SITL) not braking?

I was testing the behavior of the BRAKE flight mode in SITL, and I’m not sure I understand what’s going on.

If you take a look at the figure below, you can see that the vehicle moves from GUIDED into STABILIZE flight mode while the throttle is at 0% and begins to fall. Shortly thereafter, I switch the vehicle into BRAKE flight mode, but rather than braking, CTUN.DAlt begins to track CTUN.Alt exactly, and the vehicle falls as if BRAKE mode was not active.

I’ve made the log file available if anyone wants to take a look. I’m confused by this behavior and would appreciate your help figuring out what is going on. Thanks!

Lars,

So what you’re seeing there is a result of the ap.auto_armed flag. This flag acts like a latch stopping the motors from spinning up unless the pilot has raised the throttle stick above zero or a take-off command has been issued. It’s a long standing safety measure to stop vehicles from flying up into people’s faces (and it’s worked!).

The auto_armed flag goes to false (meaning motors won’t spin) when the vehicle is disarmed or while in manual modes (stabilize or acro) with zero throttle.
https://github.com/ArduPilot/ardupilot/blob/master/ArduCopter/system.cpp#L439

In all the various flight modes you’ll see checks that this flag is true, if not it returns immediately (i.e. does nothing).
https://github.com/ArduPilot/ardupilot/blob/master/ArduCopter/Copter.h#L268

The resetting of the desired altitude to the regular altitude is so that if the throttle is raised, it uses the current altitude as the target.

Hope that helps. It’s possible some of this logic could be changed but we would need to be sure that it doesn’t result in a safety issue.

This wasn’t it (if you look at the log, the throttle was raised above zero)…

…but this was the problem here. I was zeroing the throttle in STABILIZED mode. Thanks for the pointers; that helped out tremendously!

I’ve been testing in simulation a simple dronekit-python-based script that implements a “safety net” feature: putting the vehicle into BRAKE mode if it loses altitude too quickly, and optionally enforcing a minimum altitude for manual flight modes.

1 Like