Rangefinder for terrain

Hi dears, I have a quadcopter with cube flight controller (Copter 4.1-Dev).
I setting TERRAIN_ENABLE to 1 and rangefinder for maxbotix and also RNGFND1_ORIENT for down. The sensor detects the distance to the ground But it doesn’t change altitude when it sees an obstacle.
Is there a setting I did not make?

Log file : https://gofile.io/d/zzbo8A

1 Like

Did you read: https://ardupilot.org/copter/docs/terrain-following-manual-modes.html

Yes, I read.
As I said, I set the TERRAIN_ENABLE parameter and the rangefinder settings, it only shows the distance value but has no effect.
Please check from the log

It seems like the rangefinder is working.
What were the unexpected behaviors of the vehicle you saw?

ًRight , But doesn’t change altitude when it sees an obstacle

You were always increasing the throttle while flying above the obstacle and I could not understand whether the vehicle following the terrain or not.
From only looking at barometers and rangefinder measurements, I could have said that the vehicle successfully following the terrain but seeing the RC3 inputs, I have some doubts.
To see if the rangefinder is working or not, arm the vehicle and takeoff to the altitude = obstacle height + 5 meters.
Then fly through above the obstacle while maintaining the throttle at 50% (in other words, don’t play with the throttle).
Do this multiple times and land.
Send us the log.
Then we can clearly see if the terrain following is working or not using the rangefinder.
Also, which rangefinder module are you using?

Also TERRAIN_FOLLOW=0 in your parameters.

Thanks, I will let you know.
Is it necessary to set TERRAIN_FOLLOW in modes such as Loiter?

Prepare a mission with four points similar to a “+” sign, with the obstacle in the center and altitude around 1m. Arrange the points order so as to pass twice over the obstacle. Copy and paste the four points so as to repeat that many times in the mission. Set WPNAV_SPEED=80 (very low).

See this and this. On many passes over the obstacle it is clear that height increases the obstacle height, thanks to the rangefinder.

1 Like

This test is on the loiter and sensor is enabled but has no climb.
The sensor is gy-us42


You still have terrain follow set to 0.
And why you are not following the instructions here?
Do you have a v2 version or the previous one?
Also, @Webillo suggested a very good test scenario, do that!

Yes, it is GY-US42v2.
I set the rangefinder to PWM. (Shows distance values correctly)
One question, what is the effect of setting terrain follow? (Affects on loiter mode?)

Please look at this wiki page.
From my knowledge, the terrain_enable parameter only enables the vehicle to request terrain data from GCS (if the SD card does not contain the corresponding terrain data).
terrain_follow enables the vehicle to follow the terrain based on rangefinder measurements (at lower altitudes) and terrain data (at high altitudes).

1 Like

Thanks, I will let you know.

1 Like

Hello to all,
In the following of @hassani’s question, I searched the code for terrain altitude in the source of ardupilot V4.1.0-dev, the result surprised me.
As much as I get there is a function in “ardupilot\libraries\AC_WPNav\AC_WPNav.cpp” that sets the boolean which determine whether to use the downward rangefinder or not and it is set_wp_destination, but I couldn’t find anywhere in the code that a suitable parameter passed to this function. The default is false(in AC_WPNav.h) and nowhere else it isn’t called with the terrain_alt parameter except in “ardupilot\ArduCopter\mode_zigzag.cpp” (image below). Can anyone tell me how to drone will know that it should use terrain alt, please?!

did you solve this problem?