# Problem with althold with range sensor

**URL:** <https://discuss.px4.io/t/problem-with-althold-with-range-sensor/13086>\
**Category:** Pixhawk\
**Created:** [September 25, 2019, 4:28pm UTC](https://discuss.px4.io/t/problem-with-althold-with-range-sensor/13086 "2019-09-25T16:28:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shobhit\_Mehrotra](https://discuss.px4.io/user_avatar/discuss.px4.io/shobhit_mehrotra/32/3976_2.png) [@Shobhit\_Mehrotra](https://discuss.px4.io/u/Shobhit_Mehrotra)\
**Post date:** [September 25, 2019, 4:28pm UTC](https://discuss.px4.io/t/problem-with-althold-with-range-sensor/13086/1 "2019-09-25T16:28:02Z")

</div>

Hi, we are trying to do a basic altitude hold using the leddar one lidar. We have the sensor enabled and EKF2 range aid enabled and the height mode set to use the range finder. However it seems like it bounces up and down quite a bit. Attached is he flight log. Any help would be greatly helpful!

[https://review.px4.io/plot\_app?log=dfbc2645-0f7d-425d-a67c-c7288fe0eb10](https://review.px4.io/plot_app?log=dfbc2645-0f7d-425d-a67c-c7288fe0eb10)

---

<div class="post-metadata">

**Author:** ![MaEtUgR](https://discuss.px4.io/user_avatar/discuss.px4.io/maetugr/32/2707_2.png) [@MaEtUgR](https://discuss.px4.io/u/MaEtUgR)\
**Post date:** [September 25, 2019, 5:35pm UTC](https://discuss.px4.io/t/problem-with-althold-with-range-sensor/13086/2 "2019-09-25T17:35:14Z")

</div>

Estimation seems to know that the altitude is constantly chaning

 ![estimate](https://discuss.px4.io/uploads/default/original/2X/c/c66000029435388c07af86bdd94de8f71a560d2b.png) I would first try to tune the z-axis velocity controller that means increasing `MPC_Z_VEL_P` and `MPC_Z_VEL_I` one after the other carefully testing with each small increment if it gets better or worse. In case these gains are too high the drone will oscillate up and down but much quicker than in your log.

One additional thing to note for your further testing is when flying with the range sensor there’s a threshold for the maximal velocity the measurements are still considered `EKF2_RNG_A_VMAX`. The conservative default is 1m/s. Same goes for maximum range sensor altitude `EKF2_RNG_A_HMAX` with default 5m.

---

<div class="post-metadata">

**Author:** ![MaEtUgR](https://discuss.px4.io/user_avatar/discuss.px4.io/maetugr/32/2707_2.png) [@MaEtUgR](https://discuss.px4.io/u/MaEtUgR)\
**Post date:** [September 25, 2019, 5:45pm UTC](https://discuss.px4.io/t/problem-with-althold-with-range-sensor/13086/3 "2019-09-25T17:45:12Z")

</div>

And before I forget there’s also a minimum range `EKF2_MIN_RNG` which came to my mind because you were neither flying fast nor high but rather close to the ground. Make sure the range finder you use can actually measure the minimum distance you set here it’s better to not use wrong data.

---

<div class="post-metadata">

**Author:** ![mcsauder](https://discuss.px4.io/user_avatar/discuss.px4.io/mcsauder/32/3949_2.png) [@mcsauder](https://discuss.px4.io/u/mcsauder)\
**Post date:** [October 2, 2019, 6:22pm UTC](https://discuss.px4.io/t/problem-with-althold-with-range-sensor/13086/4 "2019-10-02T18:22:23Z")

</div>

Hi @Shobhit_Mehrotra, looking at your flight log, I think you have a vibration problem that could cause what you are seeing as well as some of the rate controller overshoot that visible in your log. As a first step, I’d suggest balancing your propellers and doing what you can to vibration isolate your IMU/autopilot, then revisit all of your rate controller gains, particularly yaw. When those details are attended to the system will have more actuator margin to deal with altitude fluctuations.

 ![image](https://discuss.px4.io/uploads/default/original/2X/b/be2a20ae5a726792177a40c59d30abfc6d463d7b.png)  
 ![image](https://discuss.px4.io/uploads/default/original/2X/9/961703fcd4269f181608cfd6ed671b7e3eb282af.png)

---

<div class="post-metadata">

**Author:** ![Shobhit\_Mehrotra](https://discuss.px4.io/user_avatar/discuss.px4.io/shobhit_mehrotra/32/3976_2.png) [@Shobhit\_Mehrotra](https://discuss.px4.io/u/Shobhit_Mehrotra)\
**Post date:** [October 11, 2019, 7:24pm UTC](https://discuss.px4.io/t/problem-with-althold-with-range-sensor/13086/5 "2019-10-11T19:24:25Z")

</div>

Thanks so much mcsauder and matetugr! The issue was related to PID tuning and vibrations. We mounted our Pixhawk 4 on vibrations dampers. We adjusted pids and reduced the imu gyro cutoff to 20hz. Also one thing to note is that on v1.9…2 to use the lidar we had to adjust to terrain following
