Setting alternative flight mode on radio failsafe

Hi all,

I’d like to be able to set the flight mode of my copter via a script upon loss of radio signal. I realize that this is what FS_THR_ENABLE=0 is for, but the problem is that the method I’m using to detect radio loss (rc:has_valid_input()) requires this parameter to be >0, since the failsafe is what triggers the detection. What I’d like to know is:

  1. Scripting aside, is there a way to set a radio failsafe flight mode other than RTL or Brake/Land? I understand it might seem counter intuitive, but even if I could set it to Stabilize (or ideally, not change the flight mode at all) this would accomplish what I’m trying to do.
  2. Is there any way to detect radio loss in lua other than has_valid_input()? All my problems would be solved if the detection within the script didn’t need to rely on the failsafe being activated. I’d just like to detect the loss without triggering the failsafe, and then let the script run.

Thanks in advance!

Why not use regular failsafe configuration?

It’s just not what I’m trying to do. I’m testing a script that switches to a different receiver if the primary one fails, and I don’t want it to return or land unless that fails as well.

Then I would suggest decoding primary receiver using Lua and RC override bindings. If you stop waiting overrides when the primary receiver fails secondary will take over and if it isn’t available RC failsafe will occur.

Interesting, could you elaborate? I’m not quite understanding what the overrides would do.

Override the secondary receiver.

Oh, I see. That wouldn’t work for my setup unfortunately… I’m literally powering off the primary receiver and powering on the secondary, they’re both hooked up to the same UART. The script controls the power switch.

You might need to use multiple inputs if you want the controller to know which is being used.

Have you looked at these docs?