LUA read parameter from mavlink (AUX Failsafe)

Hello all,

I am looking for information how I can get failsafe parameter from mavlink to lua script.

I didn’t find any information here: Messages (common) · MAVLink Developer Guide

there is example which i found in wiki :

– check EKF failsafe –
local fs_ekf = vehicle:has_ekf_failsafed()

But I’m looking for RC failsafe.

Is there any option to figure it out ?

Why not reading RCIN?
Here is an example:

Check PWM values on some RC input channels, and if input goes below some value on a channel, assume that the vehicle has an RC failsafe.

if i know well. Rc values after failsafe stay at the same level as last connection status.

In arducopter is option to set throttle failsafe value and that is solution for me but i am not sure if is it safe.

@rmackay9 @xfacta

It depends what your particular receiver does for failsafe.

OK i see,

maybe in other world.

I want to creat LUA’s script which allows me to overwrite pwm after failsafe. I’m looking for way where i can find information how can i read messages from pixhawk or read mavlink, or something else which can help me to figure it out :slight_smile:

Failsafe is a trigger for my script

What I mean is some receivers handle failsafe (loss of signal) differently.

  • Some hold channels as they are
  • Some cease all outputs
  • Some have a completely configurable output (eg: reduce throttle, pitch down, roll left) or no output

So you will have to determine what your receiver does, maybe configure it to no output, and work your LUA scripting (reading PWM from an input and writing PWM to another channel) based on that.

Also the throttle failsafe value in Ardupilot is for an INPUT - that is “what PWM value on the throttle RC input is deemed to be lost signal” . It’s not something Ardupilot outputs under a failsafe condition.

To be more precise. My transmitter is MX16 pro (foxtech),

I’m looking for solution only for RC lost, after lost of communication my receiver hold channels as they are.

After RC failsafe I want to set PWM output for my gimbal and extra payload.

Reciver is connected to pixhawk via SBUS.

In first idea i want to read pixhawk messages and after find failsafe word, I want to trigger my lua script. But as I know lua can’t read this kind of message or I can’t find solution for it.

If your receiver holds all channels and gives no indication of signal loss (such as reduced or zero output on throttle channel) then you REALLY need to look at using a different receiver.

If it does indicate signal loss in some way (such as throttle channel) then the LUA script above should be adaptable for your purpose.

What does your transmitter/receiver actually do in the event of signal loss?
Connect up to MissionPlanner with the transmitter turned on, go to the RC Calibration page - observe what happens when you switch off the transmitter.

EDIT
Foxtech manuals specify that a receiver exists and it works off 7.2 volts or more but that’s it - not any details on binding or failsafes or anything other than some antenna position basics.
See if you can get more information from them.

I wrote an email to foxtech for more info,

There is my message tab from pixhawk, as you can see pixhawk give me a flag, but nothing more.

There is video from radio tab, there is no change after transmitter fail.

SBUS has this data format, including indication of failsafe

SBUS header (0x0F)
16 servos (11 bits each) packed together into 22 bytes.
Final byte showing if failsafe activated, plus channels 17,18
SBUS final byte (0x00)

So a receiver wont necessarily alter any of the “servo” channels, such as dropping the throttle channel.
This could depend on your transmitter/receiver combination and the manufacturer.
The Frsky and other brands have procedures to specify “no pulses” or different actions on signal loss, so maybe if Foxtech have more detailed documentation that might help.

Unfortunately I cant see how Ardupilot indicates radio failsafe in any way that’s detectable to the outside world - except via mavlink and a separate telemetry radio, which is not appropriate in this case.

It could be possible to detect the RC failsafe by LUA scripting, but I don’t know how myself.
There’s been a couple of feature requests for similar things, like setting a servo PWM for some failsafe, but none have ever progressed so far.
I can certainly see how that would be useful though.

Thank you for help, maybe i find other solution.