# Autopilot with Compass

**URL:** <https://discuss.bluerobotics.com/t/autopilot-with-compass/3900>\
**Category:** QGroundControl\
**Created:** [December 12, 2018, 10:45pm UTC](https://discuss.bluerobotics.com/t/autopilot-with-compass/3900 "2018-12-12T22:45:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![fjmenese](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fjmenese](https://discuss.bluerobotics.com/u/fjmenese)\
**Post date:** [December 12, 2018, 10:45pm UTC](https://discuss.bluerobotics.com/t/autopilot-with-compass/3900/1 "2018-12-12T22:45:29Z")

</div>

Dear Community,  
Do you know how can I set up an autopilot to navigate just with the compass? I want the ROV to navigate 40 seconds north and then 40 seconds south. Is this possible? 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:** [December 13, 2018, 12:11am UTC](https://discuss.bluerobotics.com/t/autopilot-with-compass/3900/2 "2018-12-13T00:11:53Z")

</div>

Hi,

Yes, this is possible, take a look in [pymavlink](https://www.ardusub.com/developers/pymavlink.html). Also, take in mind that will not be precise since you don’t have velocity and position control.

---

<div class="post-metadata">

**Author:** ![fjmenese](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fjmenese](https://discuss.bluerobotics.com/u/fjmenese)\
**Post date:** [December 13, 2018, 1:00am UTC](https://discuss.bluerobotics.com/t/autopilot-with-compass/3900/3 "2018-12-13T01:00:41Z")

</div>

Dear Patrick,  
Thanks, I have been programing in Python, and I am able to make the ROV go forward or backwards, but I do not know how to read the compass(I do not know how it’s called in mavlink: heading or magnetometer). And then I would have to make it change direction and go forward. Please help!

---

<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:** [December 13, 2018, 11:50am UTC](https://discuss.bluerobotics.com/t/autopilot-with-compass/3900/4 "2018-12-13T11:50:37Z")

</div>

Hi Francisco,

Take a look in **Run pyMavlink on the surface computer** / **Run pyMavlink on the companion computer** examples, in both you can see the messages **VFR\_HUD** , **AHRS2** and **AHRS3**.  
You can also search for mavlink messages [here](https://mavlink.io/en/messages/ardupilotmega.html).

---

<div class="post-metadata">

**Author:** ![fjmenese](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fjmenese](https://discuss.bluerobotics.com/u/fjmenese)\
**Post date:** [December 13, 2018, 8:33pm UTC](https://discuss.bluerobotics.com/t/autopilot-with-compass/3900/5 "2018-12-13T20:33:47Z")

</div>

Thanks Patrick,  
Do you have an example on how to read them? I have found some for copters, but seem to be very complex.

---

<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:** [December 13, 2018, 8:42pm UTC](https://discuss.bluerobotics.com/t/autopilot-with-compass/3900/6 "2018-12-13T20:42:22Z")

</div>

Hi Francisco,

Take a look in the examples available in ardusub pymavlink documentation, the examples pointed in my previous answer shows how you can access it. I would recommend to read the entire webpage and learn from each example. If you are not familiar with python, I would also recommend to study it a bit more before doing such thing.

---

<div class="post-metadata">

**Author:** ![WaldoPepper](https://avatars.discourse-cdn.com/v4/letter/w/41988e/32.png) [@WaldoPepper](https://discuss.bluerobotics.com/u/WaldoPepper)\
**Post date:** [December 14, 2018, 1:33pm UTC](https://discuss.bluerobotics.com/t/autopilot-with-compass/3900/7 "2018-12-14T13:33:54Z")

</div>

Dumb question from my side:

Can I use any of the QGroundControl planning functionalities to program such kind of task? I know this approach is seriously lacking on the (no-GPS) positioning part, but will any kind of dead reckoning work?

---

<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:** [December 14, 2018, 3:11pm UTC](https://discuss.bluerobotics.com/t/autopilot-with-compass/3900/8 "2018-12-14T15:11:47Z")

</div>

There is no built in support for dead reckoning of any sort. See [here](https://www.ardusub.com/operators-manual/flight-modes.html).

You will have to write a program to command the vehicle to do what you want, as @patrickelectric suggested.

---

<div class="post-metadata">

**Author:** ![fjmenese](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fjmenese](https://discuss.bluerobotics.com/u/fjmenese)\
**Post date:** [December 15, 2018, 12:54am UTC](https://discuss.bluerobotics.com/t/autopilot-with-compass/3900/9 "2018-12-15T00:54:00Z")

</div>

Guys, Thanks for your help.

Could it be the case that mavlink for ardu Sub does not have a human reading parameter for heading?

[https://raw.githubusercontent.com/ardupilot/ardupilot/ArduSub-stable/ArduSub/Parameters.cpp](https://raw.githubusercontent.com/ardupilot/ardupilot/ArduSub-stable/ArduSub/Parameters.cpp)

---

<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:** [December 15, 2018, 1:33pm UTC](https://discuss.bluerobotics.com/t/autopilot-with-compass/3900/10 "2018-12-15T13:33:20Z")

</div>

Hi Francisco,

> [@fjmenese](#):
>
> Could it be the case that mavlink for ardu Sub does not have a human reading parameter for heading?

Sorry but your questions is not clear. Can you explain what do you want to do or accomplish ? And what is your idea of “reading parameter for heading” ? What this parameter should configure in the ROV ?

---

<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:** [December 15, 2018, 5:39pm UTC](https://discuss.bluerobotics.com/t/autopilot-with-compass/3900/11 "2018-12-15T17:39:29Z")

</div>

> [@fjmenese](#):
>
> Could it be the case that mavlink for ardu Sub does not have a human reading parameter for heading?

There is a difference between ‘Mavlink messages’ and ‘ArduPilot Parameters’. The parameters are settings that the user controls. The mavlink messages are what you want to look at for a heading, you can see those in the suggestion that @patrickelectric gave:

> [@Autopilot with Compass](https://discuss.bluerobotics.com/t/autopilot-with-compass/3900/4):
>
> Hi Francisco, Take a look in Run pyMavlink on the surface computer/Run pyMavlink on the companion computer examples, in both you can see the messages VFR\_HUD, AHRS2 and AHRS3. You can also search for mavlink messages [here](https://mavlink.io/en/messages/ardupilotmega.html).
