# BlueROV2 Heading value does not update

**URL:** <https://discuss.bluerobotics.com/t/bluerov2-heading-value-does-not-update/3751>\
**Category:** Blue Robotics Software\
**Created:** [November 15, 2018, 11:49pm UTC](https://discuss.bluerobotics.com/t/bluerov2-heading-value-does-not-update/3751 "2018-11-15T23:49:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![wahhajz](https://avatars.discourse-cdn.com/v4/letter/w/c77e96/32.png) [@wahhajz](https://discuss.bluerobotics.com/u/wahhajz)\
**Post date:** [November 15, 2018, 11:49pm UTC](https://discuss.bluerobotics.com/t/bluerov2-heading-value-does-not-update/3751/1 "2018-11-15T23:49:26Z")

</div>

Hello, I have written a very simple script to print out the current heading every second. The issue is when I call the function in MAVProxy command line, it prints the same value each iteration. Please take a look at my code as seen in the attached image, and let me know why it is not working.  
Thanks.

 ![00%20PM](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/6/6ad8996b9aa431c829b115e2945a6348b8cb9c04.png)

---

<div class="post-metadata">

**Author:** ![jwalser](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/jwalser/32/2234_2.png) [@jwalser](https://discuss.bluerobotics.com/u/jwalser)\
**Post date:** [November 15, 2018, 11:53pm UTC](https://discuss.bluerobotics.com/t/bluerov2-heading-value-does-not-update/3751/2 "2018-11-15T23:53:20Z")

</div>

The code in cmd\_Heading is blocking. No other code in mavproxy will run while you are in this loop, so no mavlink packets are parsed during this time and the value never updates.

---

<div class="post-metadata">

**Author:** ![jwalser](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/jwalser/32/2234_2.png) [@jwalser](https://discuss.bluerobotics.com/u/jwalser)\
**Post date:** [November 15, 2018, 11:53pm UTC](https://discuss.bluerobotics.com/t/bluerov2-heading-value-does-not-update/3751/3 "2018-11-15T23:53:54Z")

</div>

Try just printing the heading in mavlink\_packet every time you assign it.

---

<div class="post-metadata">

**Author:** ![wahhajz](https://avatars.discourse-cdn.com/v4/letter/w/c77e96/32.png) [@wahhajz](https://discuss.bluerobotics.com/u/wahhajz)\
**Post date:** [November 16, 2018, 12:27am UTC](https://discuss.bluerobotics.com/t/bluerov2-heading-value-does-not-update/3751/4 "2018-11-16T00:27:55Z")

</div>

My goal is to print the current heading every second until the ROV reaches a target heading, given by an amount to turn.  
For example if my current heading is 90 degrees and I want to turn 90 degrees and print the current heading every second until it reaches 180 degrees, how can I go about this? Since it seems to block the MAVlink packets from being parsed.  
Thanks.

 ![07%20PM](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/e/ed376e0f947ca262dce7e7cfb641b787e6ddaba6.png)

---

<div class="post-metadata">

**Author:** ![patrickelectric](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/patrickelectric/32/2162_2.png) [@patrickelectric](https://discuss.bluerobotics.com/u/patrickelectric)\
**Post date:** [November 16, 2018, 11:17am UTC](https://discuss.bluerobotics.com/t/bluerov2-heading-value-does-not-update/3751/5 "2018-11-16T11:17:28Z")

</div>

Please, remove `time.sleep`, loops or any other function that is expensive.  
Doing such thing freezes the code.

---

<div class="post-metadata">

**Author:** ![jwalser](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/jwalser/32/2234_2.png) [@jwalser](https://discuss.bluerobotics.com/u/jwalser)\
**Post date:** [November 20, 2018, 2:29pm UTC](https://discuss.bluerobotics.com/t/bluerov2-heading-value-does-not-update/3751/6 "2018-11-20T14:29:30Z")

</div>

You should write your own program that runs seprately (and in a different thread) from mavproxy. Instead of making a mavproxy module, make a script that reads the mavlink stream. Use mavproxy to send the mavlink stream to your script via udp.

Another option is to use the idle\_task hook for your module, this will be called whenever there is free time. Then you can just check if one second has passed before you print. (Look for blink without delay example for arduino for an idea of how to write non blocking code).

---

<div class="post-metadata">

**Author:** ![wahhajz](https://avatars.discourse-cdn.com/v4/letter/w/c77e96/32.png) [@wahhajz](https://discuss.bluerobotics.com/u/wahhajz)\
**Post date:** [November 20, 2018, 4:32pm UTC](https://discuss.bluerobotics.com/t/bluerov2-heading-value-does-not-update/3751/7 "2018-11-20T16:32:19Z")

</div>

Hi Jacob, do you have any resources I can use to learn how to use mavproxy to send the mavlink stream to my script via UDP? I am unfamiliar with this, thanks.

---

<div class="post-metadata">

**Author:** ![patrickelectric](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/patrickelectric/32/2162_2.png) [@patrickelectric](https://discuss.bluerobotics.com/u/patrickelectric)\
**Post date:** [November 21, 2018, 11:26am UTC](https://discuss.bluerobotics.com/t/bluerov2-heading-value-does-not-update/3751/8 "2018-11-21T11:26:18Z")

</div>

Hi wahhaj,

You can check the official python documentation here: [UdpCommunication - Python Wiki](https://wiki.python.org/moin/UdpCommunication)

---

<div class="post-metadata">

**Author:** ![jwalser](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/jwalser/32/2234_2.png) [@jwalser](https://discuss.bluerobotics.com/u/jwalser)\
**Post date:** [November 21, 2018, 3:53pm UTC](https://discuss.bluerobotics.com/t/bluerov2-heading-value-does-not-update/3751/9 "2018-11-21T15:53:05Z")

</div>

Check the mavproxy option `--out`

You may use it to send to a local process by `--out=udpout:0.0.0.0:5555` (udp port 5555).  
[http://ardupilot.github.io/MAVProxy/html/getting\_started/starting.html](http://ardupilot.github.io/MAVProxy/html/getting_started/starting.html)
