From 5480479e73de4de9287dc46360a8724912e27951 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 4 Nov 2018 16:31:04 +1100 Subject: [PATCH] HAL_SITL: fixed SITL example progs --- libraries/AP_HAL_SITL/SITL_State.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/AP_HAL_SITL/SITL_State.cpp b/libraries/AP_HAL_SITL/SITL_State.cpp index e9dad34fdf..251e3942d6 100644 --- a/libraries/AP_HAL_SITL/SITL_State.cpp +++ b/libraries/AP_HAL_SITL/SITL_State.cpp @@ -508,6 +508,11 @@ void SITL_State::set_height_agl(void) { static float home_alt = -1; + if (!_sitl) { + // in example program + return; + } + if (is_equal(home_alt, -1.0f) && _sitl->state.altitude > 0) { // remember home altitude as first non-zero altitude home_alt = _sitl->state.altitude;