How to Read Status of RC using MAVLink messages?

HI, I want to check if the RC is connected to the Flight Controller using MAVLink messages.
I have tried the following code:

def sys_status(self):
		syst=self.ardupilot.recv_match(type='SYS_STATUS', blocking=True, timeout=2).to_dict()
		return syst

It prints the following output:

{'mavpackettype': 'SYS_STATUS', 'onboard_control_sensors_present': 325188671, 'onboard_control_sensors_enabled': 306281519, 'onboard_control_sensors_health': 17890335, 'load': 25, 'voltage_battery': 0, 'current_battery': -1, 'battery_remaining': -1, 'drop_rate_comm': 0, 'errors_comm': 0, 'errors_count1': 0, 'errors_count2': 0, 'errors_count3': 0, 'errors_count4': 0}

How can I know if the rc is connected. Also what is the meaning if these values:325188671, 306281519 and 17890335? How can I infer from this about rc connection is present?

Have a look at their meaning here: Messages (common) · MAVLink Developer Guide

The values that this has generated does not match the values given in the description. This is the reason I asked here.
For example:

'onboard_control_sensors_health': 17890335

The nearest value to this, according to the definition are:
16777216 [MAV_SYS_STATUS_LOGGING]
33554432 [MAV_SYS_STATUS_SENSOR_BATTERY]
which sensor health is it talking about?
https://mavlink.io/en/messages/common.html#MAV_SYS_STATUS_SENSOR

The field is a bitmask.

Ok but my main question is how can I get to know if the RC is connected?

@Vidyul_Shah check below bit mask about RC status

65536 MAV_SYS_STATUS_SENSOR_RC_RECEIVER 0x10000 RC receiver

I just want to know how to write a program that will tell me about

65536 MAV_SYS_STATUS_SENSOR_RC_RECEIVER 0x10000 RC receiver
What mavlink message should I send or receive, thats my main question?
What can be the structure of the program?

I am using STATUSTEXT message as of now to know about the failsafe or rc throttle. But its message frequency is 0.0 hz. I tried sending the command to chenge the frequency but I think it is not allowed to do so. What are the other ways that I can get to know rc connection status?

Are you still looking for a way to detect RC loss? If so maybe you can monitor the RC_CHANNELS_SCALED or RC_CHANNELS_RAW messages, if their values (for example the throttle channel) fall below the minimum you know the RC is lost.
These messages you should also be able to request at a higher rate.

I have set the throttle_fs_value to 950 and thr_failsafe to enabled. I am only getting RC_CHANNELS mavlink message. So, suppose I give full throttle, one of the channel shows 1985 and I immediately switch off the RC. Now this value is set for rest of the mavlink messages that I am getting. It does not go to near 1500 or below 1000 but stays at 1985 until I restart the RC.
What values should I set or where I can trigger or read values to check connection of RC with the PIXHAWK using MAVLink?

what message are you reading is it MAVLINK_MSG_ID_RC_CHANNELS_RAW or MAVLINK_MSG_ID_RC_CHANNELS_SCALED?

Interesting, I would have expected the throttle channel to drop.

If we go back to the previous idea to check SYS_STATUS, did it also not correctly reflect the RC state?
If you check the RC receiver flag, something like this:

onboard_control_sensor_health = 17890335
flag_rc_receiver = 0x10000

if (onboard_control_sensor_health & flag_rc_receiver) == flag_rc_receiver:
    print("RC available")
else:
    print("RC not available")

Maybe also check what the other fields (onboard_control_sensors_present and onboard_control_sensors_enabled) give.

(I don’t have a drone with me at the moment, otherwise I could also have tested it)

1 Like

I was able receive only this!

Ok thank you I will try and update here if it works.