From 3a37796eb268d35a84a548c1b09bf25c48abc5be Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 8 Jan 2024 13:07:46 +1100 Subject: [PATCH] SITL: move simulated height_agl into fdm structure allows value to be shipped via multicast to simulated peripherals --- libraries/SITL/SIM_Aircraft.cpp | 2 +- libraries/SITL/SITL.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libraries/SITL/SIM_Aircraft.cpp b/libraries/SITL/SIM_Aircraft.cpp index c718d76bd0..58b22308a0 100644 --- a/libraries/SITL/SIM_Aircraft.cpp +++ b/libraries/SITL/SIM_Aircraft.cpp @@ -490,7 +490,7 @@ float Aircraft::perpendicular_distance_to_rangefinder_surface() const { switch ((Rotation)sitl->sonar_rot.get()) { case Rotation::ROTATION_PITCH_270: - return sitl->height_agl; + return sitl->state.height_agl; case ROTATION_NONE ... ROTATION_YAW_315: return sitl->measure_distance_at_angle_bf(location, sitl->sonar_rot.get()*45); default: diff --git a/libraries/SITL/SITL.h b/libraries/SITL/SITL.h index 24dbdac91a..68b30ddeb9 100644 --- a/libraries/SITL/SITL.h +++ b/libraries/SITL/SITL.h @@ -92,6 +92,10 @@ struct sitl_fdm { // earthframe wind, from backends that know it Vector3f wind_ef; + + // AGL altitude, usually derived from the terrain database in simulation: + float height_agl; + }; // number of rc output channels @@ -152,9 +156,6 @@ public: // throttle when motors are active float throttle; - // height above ground - float height_agl; - static const struct AP_Param::GroupInfo var_info[]; static const struct AP_Param::GroupInfo var_info2[]; static const struct AP_Param::GroupInfo var_info3[];