Raspberry pi and Attitude adjustment

Well,i try to extract data from PC and pi.I tested it by rotating the pix.I found that data latency is high when i run the code on pc. About thirty seconds.I think the data is meaningless under such high latency.Is there a solution to this problem?

That’s likely a combination of the sleep time, and the time it takes to print the values (Windows is particularly slow at printing things). On my Mac it took about 8 seconds for the data to reflect a change in the position, rather than your 30.

I changed it to use 50ms delay instead of 100 (using time.sleep(0.05)) and the updates become practically instant. Since we’re using blocking=True though, it will always have at least the minimum wait between messages, so if you want you can just remove the time.sleep line entirely (which is likely useful if you’re doing some processing or something with the readings).

While removing the sleep should be sufficient for now, if you end up doing some processing or other operations that take longer than the minimum time between subsequent messages that you’re interested in then it’s probably a good idea to implement a separate python Thread that receives the mavlink messages as fast as possible, and then you can just work off the latest data. It’s also possible to reduce the message frequency if you need to, although that will also reduce those message frequencies when you run QGC.

Well,I don’t have a thorough understanding of how the program works.Removing time.sleep does works.
I want to know what is the default frequency of message.I know that the higher the frequency, the smaller the period.The higher frequency means higher sensitivity to angle changes.But we cannot make the time interval between two messages less than the time interval for information processing.
So what is the default and maximum frequency of message?

Most messages are sent at the --streamrate parameter from the mavproxy page, which is by default set to 10 (Hz), so the default period of the ATTITUDE message is 0.1s.

Note that QGroundControl has a MAVLink Inspector tab where you can check the current frequencies of any and all mavlink message types being sent to the top computer.

I’m not sure what the exact ‘maximum’ frequency would be since it depends a lot on the hardware you’re running mavproxy on, and what else you’re running on it. I wouldn’t recommend setting the general streamrate much higher than it is, although increasing the rate of an individual message would hopefully not cause too much CPU usage.

A post was merged into an existing topic: Information extraction on the Raspberry Pi stops automatically