Terrain following not working on Pixhawk 4

I wanted to use the terrain following feature of arducopter using the GCS provided terrain data set, but it doesn´t seem to work on my pixhawk 4. I have set up everything as per the documentation.

The copter does load the terrain data and the current terrain height is displayed correctly. The mission I set up is a simple takeoff and fly to a waypoint up the mountain (both in TERRAIN Frame), but the copter only seems to use the relative (barometric) altitude. What am I missing?

Heres the log: https://1drv.ms/u/s!AiCBl-8nSkdeggJXhLmf1ZPCjBBV?e=tXZLAg

TERRAIN_FOLLOW=0 in your parameters. Do TERRAIN_FOLLOW=1

1 Like

The TERRAIN_FOLLOW parameter only controls how the copter behaves in RTL and Land modes, but not in Auto.

However just to make sure, I did just try to change the parameter to 1, but the results are the same:

I just wanted to be sure because of this.
CHeight is vehicle above terrain it should not be changed (or least vehicle should try to hold the altitude that you specified in the mission).
Vehicle should follow TerrH with the altitude offset you set in the mission.
Look at it or send us the log.
Also i would suggest to use the https://terrain.ardupilot.org/ and copy the files into the SD card if internet connection is not available in the field.
And why did you switch the flight mode back and forth between AUTO and LOITER (in the log you send)?
BTW, I used this function in one of my planes in a hilly region and it was working perfectly.

That´s what I wanted to show with the picture. In terrain following CHeight should be constant, but it´s not.

I already have a custom terrain data loaded in MissionPlanner from an airborne laser scanning project (so very accurate). No connection to the internet needed.

I switched to auto, but the vehicle did not climb up the mountain as expected, so I took control in Loiter to avoid crashing into the mountain. :wink: I also tried chnging the mission to see if it would make any difference, but it did not.

I have also succesfully used this feature on other copters, but they were all CubeBlacks. I suspect, that this might be an issue only related to the Pixhawk 4 hardware. What FC are you using?

It was MATEK F405-Wing but I don’t think this problem related to hardware. I looked at your mission and the altitude types of the commands are all Terrain which is OK. I was using the terrain data that ArduPilot provided.

In your successful flight, were you using your custom dataset or ArduPilot terrain dataset? You may try the default dataset but it has relatively low resolution. If it works with it, we may suspect that something wrong with the custom data (or autopilot could not be able to use it, but we are seeing the data in the log correctly anyway it is worth of shot).

I am suspecting that the TERRAIN_SPACING parameter may be high (you set 50 meters) for your case since you are saying you have a very accurate data.

There is no problem with the terrain data or the spacing, since the CHeight is always correct (from the logs and in the live telemetry data). I have since reduced the spacing to 30m, but the problem is with the copter not following this information in Auto mode.

In the next few days I´ll try if the copter uses it correctly in RTL.

Now I tried RTL with TERRAIN_FOLLOW=1, but also in this mode it only maintaians altitude above home point:

@rmackay9 Maybe you can help me out?

I’ve replied on the issue but we’ve got a bug in Copter-4.1 that means that BendyRuler and terrain following don’t work together. The issue is here. Hopefully we will have a fix for Copter-4.1 but in any case, I’m afraid the solution is to disable Bendy Ruler by setting OA_TYPE = 0.

Thanks Terrein works again after disabling obstacle avoidance. It´s a pity, that they don´t work together, would be quite important for BVLOS flights.