# Altitude hold and depth hold in pymavlink

**URL:** <https://discuss.bluerobotics.com/t/altitude-hold-and-depth-hold-in-pymavlink/5686>\
**Category:** Blue Robotics Software\
**Tags:** pymavlink, positioning\
**Created:** [August 2, 2019, 5:25pm UTC](https://discuss.bluerobotics.com/t/altitude-hold-and-depth-hold-in-pymavlink/5686 "2019-08-02T17:25:39Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![williangalvani](https://avatars.discourse-cdn.com/v4/letter/w/6f9a4e/32.png) [@williangalvani](https://discuss.bluerobotics.com/u/williangalvani)\
**Post date:** [August 5, 2019, 1:34pm UTC](https://discuss.bluerobotics.com/t/altitude-hold-and-depth-hold-in-pymavlink/5686/2 "2019-08-05T13:34:11Z")

</div>

Hello Jinkun,

Yes, that commit disabled it as we didn’t think it was good enough.

> [@jinkun](#):
>
> What’s the easiest way to implement altitude hold assuming altitude is available? I could write a PID controller for that but it will be great if I can leverage existing functions in ArduSub.

You can revert that commit and try to improve the behavior.

> [@jinkun](#):
>
> Is there a way to change the desired depth value in pymavlink during depth hold mode without using a joystick?

I’m afraid that not right now. [SET\_POSITION\_TARGET\_GLOBAL\_INT](https://mavlink.io/en/messages/common.html#SET_POSITION_TARGET_GLOBAL_INT) and [SET\_POSITION\_TARGET\_LOCAL\_NED](https://mavlink.io/en/messages/common.html#SET_POSITION_TARGET_LOCAL_NED) Should be able to set a depth target, but they are only supported in [Guided or Auto](https://github.com/ArduPilot/ardupilot/blob/ArduSub-stable/ArduSub/GCS_Mavlink.cpp#L1577) modes right now. It should be possible to add support for this message to Depth Hold too.

> [@jinkun](#):
>
> When I changed the depth during depth hold mode, I noticed that the vehicle jerked a little bit as you can see from the figure. As a result, the vehicle didn’t hold the exact depth when I released the depth knob.

We recently worked on the depth hold controller to mitigate a behavior just like that. Are you running ArduSub 3.5.4?

---

_[View the full topic](https://discuss.bluerobotics.com/t/altitude-hold-and-depth-hold-in-pymavlink/5686)._
