Mocap System TM : RTT too high for timesync MAVROS

Hello, I am trying to implement a motion capture system with my drone although I am having plenty of issues with its performance. The errors I am receiving on the mavros side can be seen:

I also receive a lost connection and heartbeat timeout. I am using a raspberry pi companion computer and it is connected to the flight controller via a USB. I checked the diagnostics which can be seen:

I also ran a flight which can be seen:

As seen from the flight log, it cant follow setpoints at all and is very wobbly. I know it may seem like the gains need to be tuned, but I have flown with this setup a few months ago and it was extremely smooth. I havnt been able to fly well since. The time stamping of the mocap data is synced and aligns with the local position. I have tried streaming the data at different rates (doesnt make a difference) and have played around with the ev_delay parameter. One thing in the flight log is there is estimator time slip (sometimes it is zero and doesn’t change flight at all). Externally I feel like things are fine I just think it is an internal problem i.e. communication between the flight controller and RPI with MAVROS (improper sync between flight controller and mavros). I have another drone that is the same and it has the same issues. Even when I use a different form of pose feedback I still have stability problems and those mavros errors. I seen something about fixing the errors here:
although I am unsure about implementing on PX4. I have explored all possibilities I can think of, any help would be appreciated.

I am using a raspberry pi companion computer and it is connected to the flight controller via a USB.

@ssmith-81 How are you connected to the flight controller? Is it just USB? You need to communicate via serial and use high baudrates to be able to inject reseanable external vision estimates

@Jaeyoung-Lim Hello, yes it is just usb with Mavros running onboard the rpi. Correct me if I am wrong but isn’t usb much fast then a serial connection? I am guessing the TM:RTT too high for time sync is the time from Mavros to the flight controller and back, which is taking too long? But why would a serial connection be better in this case instead of usb? Also those timeout errors occur on the Mavros side before I even begin streaming the external vision data from the mocap

@ssmith-81 It is still configured as a serial link on the autopilot side. I would check your baudrate

Hi @Jaeyoung-Lim . Just checking. It is configured in the parameters with mav_0_config (or that is the gcs channel I think)? I see mav_1 and mav_2 are disabled so I’m wondering what the channel is. The baudrate would be ser_??baud? Or mav??_rate? Lastly, what should these values be set to for proper communication to the fcu. I’m guessing baudrate is 921600 8N1 for the Mavros channel. Just not sure where that channel is.

@ssmith-81 No, telem1 is telem1 and not connected to the usb.

Is there a reason you are not using a serial link? It is generally not recommended you use the usb connection for offboard data communication

@Jaeyoung-Lim I am using a modified pixracer flight controller which has a usb-c port that I connect with a usb-usbc cable from pi. Through that I run Mavros which communicates to the fcu. The reason I use it is because it is the standard configuration provided by the company which is advised by the owners. But honestly it has been working very poorly so I would like to try a uart/serial communication. Firstly, how do I check the baudrate of the usb connection? Secondly, I have tried a serial communication between the pi and the fcu but it fails to reach connection, I must have things configured improperly. I set the mavlink 2 instance and connected the serial on telem2. Havnt gotten it to connect yet

Update: the serial connection still provides the heartbeat timeout on the mavros side. Not sure how to fix this

I flew with the serial link, it performed even worse and there is still heartbeat timeout errors. Not sure where to go from here.

@ssmith-81 Please share a log, otherwise it is hard to know what is going on

@ssmith-81 Which serial link are you using? As you can see in the log, the Exterbal vision messages seems to be invalid and include large timedelays

@ssmith-81 What is the rate your MoCap system is sending data? I have had better luck lowering that rate to 60 Hz for a first generation pixracer using an esp8266 chip talking to a computer over wifi.
(The only wifi connection that was not wired was the drone to the companion computer)

I am experiencing a similar issue but with the holybro kakute H7 using an esp8266 chip. The above fix did not consitently help with this setup.

Sorry for late response. I left the mocap publish rate as is, I tried lowering it at one point but it had no influence on performance or the errors. I retuned the drone using auto-tuning module, it flies a bit better. It is usable but not ideal, I still believe those errors are having an influence. I also changed the data transfer protocol from mocap to drone, may have helped some but like I said, flight still is not ideal.