# Raspberry pi and Attitude adjustment

**URL:** <https://discuss.bluerobotics.com/t/raspberry-pi-and-attitude-adjustment/9959>\
**Category:** Companion (Retired)\
**Tags:** ardusub, pymavlink\
**Created:** [June 22, 2021, 8:41am UTC](https://discuss.bluerobotics.com/t/raspberry-pi-and-attitude-adjustment/9959 "2021-06-22T08:41:20Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![Richard1](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@Richard1](https://discuss.bluerobotics.com/u/Richard1)\
**Post date:** [July 1, 2021, 3:18am UTC](https://discuss.bluerobotics.com/t/raspberry-pi-and-attitude-adjustment/9959/21 "2021-07-01T03:18:26Z")

</div>

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？

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [July 1, 2021, 10:02am UTC](https://discuss.bluerobotics.com/t/raspberry-pi-and-attitude-adjustment/9959/22 "2021-07-01T10:02:17Z")

</div>

> [@Richard1](#):
>
> 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.

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.

> [@Richard1](#):
>
> Is there a solution to this problem？

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`](https://docs.python.org/3/library/threading.html#threading.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](https://www.ardusub.com/developers/pymavlink.html#request-message-interval) if you need to, although that will also reduce those message frequencies when you run QGC.

---

<div class="post-metadata">

**Author:** ![Richard1](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@Richard1](https://discuss.bluerobotics.com/u/Richard1)\
**Post date:** [July 2, 2021, 1:43am UTC](https://discuss.bluerobotics.com/t/raspberry-pi-and-attitude-adjustment/9959/23 "2021-07-02T01:43:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [July 2, 2021, 7:59am UTC](https://discuss.bluerobotics.com/t/raspberry-pi-and-attitude-adjustment/9959/24 "2021-07-02T07:59:04Z")

</div>

Most messages are sent at the `--streamrate` parameter from the [mavproxy page](http://192.168.2.2:2770/mavproxy), which is [by default set to 10 (Hz)](https://github.com/bluerobotics/companion/blob/master/params/mavproxy.param.default), 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.

 ![QGC Mavlink inspector screenshot](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/e/e653fe4ababebfb2244866feedf0a3467c3ebe74.png)

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.

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [August 12, 2021, 8:31am UTC](https://discuss.bluerobotics.com/t/raspberry-pi-and-attitude-adjustment/9959/26 "2021-08-12T08:31:13Z")

</div>

A post was merged into an existing topic: [Information extraction on the Raspberry Pi stops automatically](https://discuss.bluerobotics.com/t/information-extraction-on-the-raspberry-pi-stops-automatically/10408/2)

[Previous page](https://discuss.bluerobotics.com/t/raspberry-pi-and-attitude-adjustment/9959.md?page=1)
