I have created a proxy between QGC(Ground Control Station) and vehicle in Python. Here is the code:
gcs_conn = mavutil.mavlink_connection('tcpin:localhost:15795')
gcs_conn.wait_heartbeat()
print("Heartbeat from system (system %u component %u)" %(gcs_conn.target_system, gcs_conn.target_system))
vehicle = mavutil.mavlink_connection('tcp:localhost:5760')
vehicle.wait_heartbeat() # recieving heartbeat from the vehicle
print("Heartbeat from system (system %u component %u)" %(vehicle.target_system, vehicle.target_system))
while True:
gcs_msg = gcs_conn.recv_match()
if gcs_msg == None:
pass
else:
vehicle.mav.send(gcs_msg)
print(gcs_msg)
vcl_msg = vehicle.recv_match()
if vcl_msg == None:
pass
else:
gcs_conn.mav.send(vcl_msg)
print(vcl_msg)
I need to receive the messages from the QGC and then forward them to the vehicle and also receive the messages from the vehicle and forward them to the QGC. When I run the code I get this error.
is there any one who can help me?
If you print your message before sending you'll notice it always fails when you try to send a
BAD_DATAmessage type.So this should fix it (same for
vcl_msg):PD: I noticed that you don't specify
tcpas input or output, it defaults toinput. Than means both connections are inputs. I recommend setting up the GCS connection as output:gcs_conn = mavutil.mavlink_connection('tcp:localhost:15795', input=False)https://mavlink.io/en/mavgen_python/#connection_string