Hello, I am trying to get the values of the RC1, RC2…RC7 in real time as I am working on a GUI and a companion computer (Jetson Xavier NX). So my system is as follows:- Futaba receiver is connected to the OrangeCube+ in the RCIN pin and the I use a Gimbal so I have given RC1-RC5 for Gimbal control. The TELEM1 port of the Cube is connected to the Gimbal. TELEM2 is connected to my companion computer using FTDI cables (Serial-USB). I use RC6 and RC7 for my own function for my GUI application, like a trigger when the toggle switch in the RC controller is ON, the GUI performs an action. I need to read the real time values as serial data. How do I do that? I use Mission Planner firmware in my Orangecube+. The RC controller is already calibrated and I can successfully control my Gremsy Gimbal. So the RC signals reach the Gimbal through the OrangeCube+.
I tried it using a small code that I wrote.
from pymavlink import mavutil
# Configure the serial port
serial_port = '/dev/ttyUSB0' # Since we are using FTDI to serial port
baud_rate = 57600 # Set the baud rate according to your setup
# Start a connection listening the serial port
mavlink_connection = mavutil.mavlink_connection(serial_port, baud=baud_rate)
# Wait for the first heartbeat
# This sets the system and component ID of remote system for the link and prints it
mavlink_connection.wait_heartbeat()
print("Heartbeat from system (system %u component %u)" % (mavlink_connection.target_system, mavlink_connection.target_component))
#function to request the PARAM stream
def request_message_interval(master, message_input: str, frequency_hz: float):
message_name = "MAVLINK_MSG_ID_" + message_input
message_id = getattr(mavutil.mavlink, message_name)
master.mav.command_long_send(master.target_system, master.target_component, mavutil.mavlink.MAV_CMD_SET_MESSAGE_INTERVAL, 0, message_id, 1e6/ frequency_hz, 0, 0, 0, 0, 0)
print("Requested the message successfully.")
request_message_interval(mavlink_connection, "RC_CHANNELS_RAW", 1.0)
while True:
# Read a MAVLink message from TELEM2
message = mavlink_connection.recv_match(type= "RC_CHANNELS_RAW", blocking=True, timeout=0.1)
#print("Message received sucessfully")
print('Received',message)
if message:
print('Received',message)
# Extract RC channel values from the message
rc_channel_1 = message.chan1_raw
rc_channel_2 = message.chan2_raw
rc_channel_3 = message.chan3_raw
rc_channel_4 = message.chan4_raw
# Print the RC channel values received from TELEM1
print("RC Channel 1 (from TELEM1):", rc_channel_1)
print("RC Channel 2 (from TELEM1):", rc_channel_2)
print("RC Channel 3 (from TELEM1):", rc_channel_3)
print("RC Channel 4 (from TELEM1):", rc_channel_4)
The output I got is