How to reduce CPU usage of Mavproxy

Hello to all,
I was using Mavproxy in a raspberry pi 2 just to send the telemetry from the pixhawk serial port to the groundstation using UDP and a wifi link. The only other process running in the raspberry pi was gstreamer for FPV, and everything was working fine.
Now, I have moved to a raspberry pi Zero due to weight constraints, and have noticed a huge increase in the video latency (up to 7 seconds in the Zero, was less than 200ms before) due to the Mavproxy process using about 70% of CPU time… When I kill the Mavproxy process, the latency goes to normal again.
The thing is that I need Mavproxy for just relaying the telemetry. I have read in other forums that most of the CPU time is spent in parsing the mavlink packets, but I guess that I don’t need parsing for this application.
I would like to know if the parsing (or any other cpu intensive code) could be disabled with an easy modification of the Python code, which I haven’t been able to figure it out.
I found easy to disable the code to log the mavlink stream on disk, just putting a “return” in the first line of the “log_writer” function, and the CPU usage reduced to about 60%, but not enough.
Any help with this issue will be highly appreciated.

I have also tried using netcat or socat linux command to just connect the serial port to UDP packets, but for some reason, the telemetry is received but many mavlink messages are lost (the quality of the UDP link is about 30% according to mission planner when using netcat or socat, but 100% with no packet loss when using mavproxy).

Thankyou in advance for your help. Best regards!

1 Like

I’m seeing this issue too, exactly as you describe it, on my Pi Zero W.

There is an issue raised regarding MavProxy speed here:

Your code modification was a good idea. It sounds like a Pi3 will run it faster, too.

Are there any other solutions?

Mavproxy is a fantastic bit of software, but it’s not light-weight enough in it’s current form to run on a pi zero. If you’re just looking to relay/proxy mavlink, have a look at something like
It runs happily on a pi zero with very little cpu usage.

You can disable several unused modules. I was able to bring down load to usable levels on RPi Zero.
startup option –default-modules

I just installed Windows 10 on my Intel J3455 companion computer. Running Mavproxy with just the console window open, one master and one UDP output, eats up 40% CPU. Missionplanner connected to the FC is at 6% CPU, but I can not preconfigure telemetry forwarding. I now run cmavnode in WSL and it uses 1.5% max. I know, it is no full GCS, so it is not comparable, but the difference between “lightweight” Mavproxy and MP is surprising.