SITL: change for AP::terrain as a pointer

This commit is contained in:
Andrew Tridgell 2021-04-07 19:49:52 +10:00
parent 483ed19662
commit 7b9826cdce
2 changed files with 3 additions and 3 deletions

View File

@ -63,7 +63,7 @@ Aircraft::Aircraft(const char *frame_str) :
sitl->ahrs_rotation_inv = sitl->ahrs_rotation.transposed();
}
terrain = &AP::terrain();
terrain = AP::terrain();
// init rangefinder array to -1 to signify no data
for (uint8_t i = 0; i < RANGEFINDER_MAX_INSTANCES; i++){

View File

@ -178,9 +178,9 @@ void ShipSim::send_report(void)
bool have_alt = false;
#if AP_TERRAIN_AVAILABLE
auto &terrain = AP::terrain();
auto terrain = AP::terrain();
float height;
if (terrain.enabled() && terrain.height_amsl(loc, height, true)) {
if (terrain != nullptr && terrain->enabled() && terrain->height_amsl(loc, height, true)) {
alt = height * 1000;
have_alt = true;
}