# How to change the Target Altitude

**URL:** https://discuss.bluerobotics.com/t/how-to-change-the-target-altitude/9931
**Category:** ArduSub
**Tags:** ardusub
**Created:** [June 18, 2021, 6:37am UTC](https://discuss.bluerobotics.com/t/how-to-change-the-target-altitude/9931 "2021-06-18T06:37:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cxs](https://avatars.discourse-cdn.com/v4/letter/c/dfb087/32.png) [@cxs](https://discuss.bluerobotics.com/u/cxs)
#### Post date: [June 18, 2021, 6:37am UTC](https://discuss.bluerobotics.com/t/how-to-change-the-target-altitude/9931/1 "2021-06-18T06:37:39Z")

</div>

HI，  
I am a Chinese student and I know about ardusub recently.I want to know how can I use the built-in PID controller in QgroundControl to achieve depth control and How can I input the depth that I want to set?  
Thanks a lot

---

<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: [June 21, 2021, 1:35am UTC](https://discuss.bluerobotics.com/t/how-to-change-the-target-altitude/9931/2 "2021-06-21T01:35:52Z")

</div>

Hi @cxs, welcome to the forum! 🙂

> [@cxs](#):
>
> I want to know how can I use the built-in PID controller in QgroundControl to achieve depth control

QGroundControl (QGC) doesn’t do any actual control - it sends mavlink messages to ArduSub about what’s desired, and ArduSub uses various control loops to achieve that. For depth control you can use QGC to tell ArduSub to enter “depth hold” mode, which then uses a PID loop to maintain the depth the ROV was at just after the last pilot throttle input. When controlling the ROV via QGC it has to actually be at the depth you want to maintain in order to set that as the target depth.

> [@cxs](#):
>
> How can I input the depth that I want to set?

You can either pilot the ROV to the desired depth and turn on depth hold mode in QGC, or you can use mavlink messages directly to set the target depth.

To set the depth using mavlink you should be able to use the [`SET_POSITION_TARGET_GLOBAL_INT`](https://mavlink.io/en/messages/common.html#SET_POSITION_TARGET_GLOBAL_INT) message while in depth hold mode (there’s support for it in the [ArduSub source](https://github.com/ArduPilot/ardupilot/blob/Sub-4.0/ArduSub/GCS_Mavlink.cpp#L657-L717)). I couldn’t find a more recent example than @williangalvani’s [gist](https://gist.github.com/Williangalvani/78859b23d6eebdd899a1c2a5ece20804) from a while ago, so I’m not sure if that code will actually work in ArduSub \>=4.0 (it was written for a specific version of ArduSub 3.6), but I’ll try to see if we can get an updated version added to our [pymavlink documentation](https://www.ardusub.com/developers/pymavlink.html). I’ve created a GitHub issue about it here:

> <https://github.com/bluerobotics/ardusub-gitbook/issues/195>
>
> \[ArduSub supports\](https://github.com/ArduPilot/ardupilot/blob/Sub-4.0/ArduSub/G…CS\_Mavlink.cpp#L657-L717) setting the target depth in depth hold mode using the \[\`SET\_POSITION\_TARGET\_GLOBAL\_INT\`\](
> https://mavlink.io/en/messages/common.html#SET\_POSITION\_TARGET\_GLOBAL\_INT) message. I couldn't find a more recent usage example than @Williangalvani's \[gist\](https://gist.github.com/Williangalvani/78859b23d6eebdd899a1c2a5ece20804) from a while ago, so I'm not sure if that code will actually work in ArduSub \>=4.0 (it was written for a specific version of ArduSub 3.6), but it would be good if we could clean that up and add an example to our docs.
