diff --git a/src/modules/position_estimator_inav/position_estimator_inav_main.cpp b/src/modules/position_estimator_inav/position_estimator_inav_main.cpp index 58ffd438866a..114bdee530a2 100644 --- a/src/modules/position_estimator_inav/position_estimator_inav_main.cpp +++ b/src/modules/position_estimator_inav/position_estimator_inav_main.cpp @@ -410,7 +410,7 @@ int position_estimator_inav_thread_main(int argc, char *argv[]) /* wait for initial baro value */ bool wait_baro = true; - TerrainEstimator *terrain_estimator = new TerrainEstimator(); + TerrainEstimator terrain_estimator; thread_running = true; hrt_abstime baro_wait_for_sample_time = hrt_absolute_time(); @@ -1264,8 +1264,8 @@ int position_estimator_inav_thread_main(int argc, char *argv[]) } /* run terrain estimator */ - terrain_estimator->predict(dt, &att, &sensor, &lidar); - terrain_estimator->measurement_update(hrt_absolute_time(), &gps, &lidar, &att); + terrain_estimator.predict(dt, &att, &sensor, &lidar); + terrain_estimator.measurement_update(hrt_absolute_time(), &gps, &lidar, &att); if (inav_verbose_mode) { /* print updates rate */ @@ -1358,8 +1358,8 @@ int position_estimator_inav_thread_main(int argc, char *argv[]) global_pos.eph = eph; global_pos.epv = epv; - if (terrain_estimator->is_valid()) { - global_pos.terrain_alt = global_pos.alt - terrain_estimator->get_distance_to_ground(); + if (terrain_estimator.is_valid()) { + global_pos.terrain_alt = global_pos.alt - terrain_estimator.get_distance_to_ground(); global_pos.terrain_alt_valid = true; } else {