Terrain following in Auto may hit terrain

Dear all,

When I tested terrain following, I noticed that the vehicle decreases its altitude and even crashes on the ground. I guess that this issue is related to a fixed issue.

This issue could be reproduced as following steps:
./Tools/autotest/sim_vehicle.py -v ArduCopter --console -w --speedup=10 -L Karuizawa

  1. GUIDED
  2. arm throttle
  3. takeoff 30
  4. module load message
  5. message SET_POSITION_TARGET_GLOBAL_INT 0 1 0 11 3576 363215670 1386596701 30 0 0 0 0 0 0 0 0
  6. Set the current altitude to 40 meters above terrain by increasing throttle
  7. message SET_POSITION_TARGET_GLOBAL_INT 0 1 0 11 3576 363130895 1386620578 30 0 0 0 0 0 0 0 0
  8. The vehicle keeps decreasing its altitude and then crashes on the ground as shown in the below figures.

Test version: 5dea87ae4118b0811af2c102c551d76edca0b484
Log: https://drive.google.com/file/d/1UXXgxVNZJ2RV2nZQDR60o0LFbxrMB9he/view?usp=sharing

Edit: This issue still occurs even if the vehicle uses a Rangefinder on SITL.

1 Like

Hi @KimHyungSub,

I’ve reproduced the problem so we will look into it. Maybe we have a bug in how the terrain offset is initialised when entering Guided mode because the issue only seems to occur if the vehicle is switched to AltHold momentarily.

This portion of the instructions you’ve kindly posted are critical to seeing the bug

Set the current altitude to 40 meters above terrain by increasing throttle

@rmackay9
Thank you for quick feedback!
I also found two other cases related to the terrain following.

The first case could be reproduced as following steps:

  1. param set RTL_ALT 8000
  2. GUIDED
  3. arm throttle
  4. takeoff 80
  5. module load message
  6. message SET_POSITION_TARGET_GLOBAL_INT 0 1 0 11 3576 363215670 1386596701 80 0 0 0 0 0 0 0 0
  7. The vehicle just keeps increasing its altitude.
    image

The second case could be reproduced as following steps:

  1. param set RTL_ALT 8000
  2. GUIDED
  3. arm throttle
  4. takeoff 30
  5. module load message
  6. message SET_POSITION_TARGET_GLOBAL_INT 0 1 0 11 3576 363215670 1386596701 30 0 0 0 0 0 0 0 0
  7. message SET_POSITION_TARGET_GLOBAL_INT 0 1 0 11 3576 363215670 1387596701 30 0 0 0 0 0 0 0 0
  8. mode RTL
  9. The vehicle is stuck in a location as shown in below figures.
    image
1 Like

Thanks!!

1 Like

@KimHyungSub,

I’ve tested Leonard’s fix (linked above) and it seems to resolve the problem. Since you’re quite handy with SITL testing maybe you want to give it a try as well? I will probably merge it in an hour or two in either case but feedback would be very welcome!

1 Like

Thanks @Leonardthall @rmackay9

I have tested the fixed version.
It seems likely to me that the fixed version resolves the problem!
However, RTL mode still leads to an issue. Maybe, this issue comes from another root cause.

./Tools/autotest/sim_vehicle.py -v ArduCopter --console -w --speedup=10 -L Karuizawa

  1. param set RTL_ALT 8000
  2. GUIDED
  3. arm throttle
  4. takeoff 30
  5. module load message
  6. message SET_POSITION_TARGET_GLOBAL_INT 0 1 0 11 3576 363215670 1386596701 30 0 0 0 0 0 0 0 0
  7. message SET_POSITION_TARGET_GLOBAL_INT 0 1 0 11 3576 363130895 1386620578 30 0 0 0 0 0 0 0 0
  8. mode RTL
  9. The vehicle stuck in a position.
1 Like

@KimHyungSub,

Great, thanks for testing.

For RTL you’ll need to set RTL_ALT_TYPE = 1 (Terrain) to cause it to do terrain following on its return home.

1 Like