"Save the plane" routine in my custom flight mode?

I’m writing a custom flight mode. I’m looking for a routine to call to save my plane if my flight mode finds the plane to be in trouble, ie a bad orientation, low airspeed or low altitude.

Basically, I’d like to check for the above conditions, kick out of my flight mode and call a routine to right the plane, get it up to a proper airspeed and altitude.

How would one do this ?

Have you seen ArduPlanes training mode? You can set up with a minimum altitude geofence also.


Thanks for the reply.

Yes I did see it, but that mode still relies on the pilot. I’d like a recovery mode that is totally automatic, without pilot input. My flight mode is totally auto, no pilot inputs.

The new flight mode should take the airplane from nearly crashing to say loitering or something. Kick out of my flight mode, kick into the “save” flight mode and save the plane from crashing.

Thoughts ?

I don’t understand the use case. You want to be flying in a manual mode and this new mode will take over and loiter if you nearly crash?

Any existing auto throttle mode will save the aircraft thanks to the airspeed control and the stall prevention.


The use case is that something goes wrong or I make a programming error in my crazy flight mode.

In mode::update I want to check various things like airspeed, altitude and orientation. If something goes wrong with my code and the airplane gets out of control, I want to call a routine independent of mine to rescue it.

Thanks for the tip on auto throttle mode. I think loiter with STALL_PREVENTION enabled would be a good start.

So if my aircraft is corkscrewing to the ground and I switch modes to loiter with STALL_PREVENTION enabled, it will save the aircraft ?

Ah I see, you want to save it if your flight mode does bad. I thought the saving it was the new flight mode.Yeah I should think loiter will save most things.

SITL is a great way to test new modes, realflight lets you try out crazy things also.


The plane will not easy to crash if you set up right,but you can’t rely on FC,because it’s un reliable sometimes.All the crash for me is the FC malfunction witch will get everythings bad no matter what mode of your plane and how you set things up.so you can’t leave your plane flight and go to somewhere have smoking ,you must always pay attention at the plane,you must change to manual mode when you thinks the plane is not right ,trust me ,the FC is not so reliable in the market right now .