Sending data to ardupilot using mavros

Hi, I have a companion computer (Khadas VIM3 with Ubuntu 20 and ROS) that receives data from an external positioning system using ROS. I already checked that the message with the position and attitude is received by the companion computer. The message has the following structure:

header:
seq: 3512
stamp:
secs: 1711108959
nsecs: 40662080
frame_id: “mocap”
pose:
position:
x: 2.5105512142181396
y: 0.8536890745162964
z: 0.30046969652175903
orientation:
x: 0.013071655295789242
y: 2.4529806978534907e-05
z: 0.3602283000946045
w: 0.9327725768089294

Assuming that this information is correct, how could I send it to Ardupilot? I suppose that it must be done with ROS, publishing the information over the serial port that connects Ardupilot and companion computer, but does it has to be in a specific format or structure?
The Ardupilot is configured to use external navigation, using no GPS or compass. I know the position is not received by the Ardupilot because MissionPlanner/mavros shows “VisualOdom: not healthy” error.

Use macros.

Yes, it needs to be in MAVLink format. Hence you must use mavros to convert between the two.

1 Like

Thanks, I managed to do it setting a relay node in the launch file.