ArduPilot / ardupilot

ArduPlane, ArduCopter, ArduRover, ArduSub source
http://ardupilot.org/
GNU General Public License v3.0
11.1k stars 17.67k forks source link

Plane/Copter/Rover: add custom failsafe support using Lua scripts #12064

Open CodingGhost opened 5 years ago

CodingGhost commented 5 years ago

Issue details

ArduPilot should have a way to set custom failsafe actions, at least failsafe servo/pwm positions for outputs. an example usecase would be: I have a beeper connected to a pwm output, and want it to beep at a failsafe event. Currently there is no way that I know to do this. with a custom failsafe action, one could set the PWM value for the beeper to the desired values.

Version

all

Platform

[ ] All [ ] AntennaTracker [ x ] Copter [ x ] Plane [ ] Rover [ ] Submarine

Airframe type

Flying wing

Hardware type

Matek F405-Wing

Logs

..-..

khancyr commented 5 years ago

Hello,

Thanks for the idea. That is interesting. It shouldn't be hard to implement but hard to use because of current failsafe handling.

krzysztofkuczek commented 5 years ago

Great idea, it should also handle situation where RC signal is lost (e.g. sbus failsafe flag is set). There should be possible at least to keep rc channel value, or overwrite by defined value.

rmackay9 commented 5 years ago

I think we should probably handling this in Lua scripts. So this would be a new failsafe action that triggers a script. The script would likely need to be in a specific filename to work. I might change the title to make this more clear

Mogway28 commented 4 years ago

Similar problem https://github.com/ArduPilot/ardupilot/issues/13362

joneseym commented 3 years ago

Here's a specific use case for this. Small long-range FPV quads can have trouble getting enough separation between high power VTx and the GPS module. This can make the GPS reception poor when the VTx is powered. If the VTx is switched by a relay output it would be very nice to have the VTx automatically switched off on RC failsafe to provide the best chance of a successful RTL.

CodingGhost commented 3 years ago

thats a brilliant Idea!

as AP is getting CRSF support, you wouldnt even need a relay on TXses with SA/CRSF

CodingGhost commented 2 years ago

is there any update on this?

rmackay9 commented 2 years ago

@CodingGhost,

The only update is that I've recently added an EKF failsafe override for Copter implemented in Lua. It's not a full flexible solution though.

Script: https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_Scripting/examples/copter-deadreckon-home.lua Test flight: https://www.youtube.com/watch?v=KKShYheW4J0 SITL testing: https://www.youtube.com/watch?v=esM0EqMH_BE

gregorymemory99 commented 1 year ago

Hi, I want to adapt this for plane (which I think will not be too difficult). But there are a few things I'm not 100% sure about. One is the comments under 'Testing that it does not require RC' - are these failsafe parameters only needed for testing or also for real flight? Secondly, the 'lean' (parameter DR_FLY_ANGLE) - in the comments it says 'Most vehicles reach maximum speed at 22deg' - is this just copters, or planes etc too? I have tried to research on this online but found no suggestions on best lean angle for speed. Thanks!