Skip to content

Commit f67843e

Browse files
committed
Copter: use terrain alt for precland if rangefinder is unavailable
1 parent ecb843b commit f67843e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ArduCopter/precision_landing.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ void Copter::init_precland()
1515

1616
void Copter::update_precland()
1717
{
18-
float final_alt = current_loc.alt;
18+
int32_t height_above_ground_cm = current_loc.alt;
1919

20-
// use range finder altitude if it is valid
20+
// use range finder altitude if it is valid, else try to get terrain alt
2121
if (rangefinder_alt_ok()) {
22-
final_alt = rangefinder_state.alt_cm;
22+
height_above_ground_cm = rangefinder_state.alt_cm;
23+
} else if (terrain_use()) {
24+
current_loc.get_alt_cm(Location_Class::ALT_FRAME_ABOVE_TERRAIN, height_above_ground_cm);
2325
}
2426

25-
copter.precland.update(final_alt);
27+
copter.precland.update(height_above_ground_cm);
2628
}
2729
#endif

0 commit comments

Comments
 (0)