From f3d55d821e661264d4cc8e23e6b22ccf7af808bb Mon Sep 17 00:00:00 2001 From: Ep Pravitra Date: Sun, 7 Jul 2024 09:36:33 +0700 Subject: [PATCH] SITL: fix json airspeed Airspeed calculation for JSON was not quite working because velocity_air_ef was not updated in SIM_JSON.cpp Update libraries/SITL/SIM_JSON.cpp Co-authored-by: Peter Hall <33176108+IamPete1@users.noreply.github.com> Update libraries/SITL/SIM_JSON.cpp Co-authored-by: Peter Hall <33176108+IamPete1@users.noreply.github.com> comment changes remove redundant airspeed calculation --- libraries/SITL/SIM_JSON.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libraries/SITL/SIM_JSON.cpp b/libraries/SITL/SIM_JSON.cpp index 95b51904c43dc..701d07621abf7 100644 --- a/libraries/SITL/SIM_JSON.cpp +++ b/libraries/SITL/SIM_JSON.cpp @@ -323,14 +323,15 @@ void JSON::recv_fdm(const struct sitl_input &input) airspeed_pitot = state.airspeed; } else { - // velocity relative to airmass in body frame - velocity_air_bf = dcm.transposed() * velocity_ef; + + // wind is not supported yet for JSON sim, assume zero for now + wind_ef.zero(); - // airspeed - airspeed = velocity_air_bf.length(); + // velocity relative to airmass in Earth's frame + velocity_air_ef = velocity_ef - wind_ef; - // airspeed as seen by a fwd pitot tube (limited to 120m/s) - airspeed_pitot = constrain_float(velocity_air_bf * Vector3f(1.0f, 0.0f, 0.0f), 0.0f, 120.0f); + // velocity relative to airmass in body frame + velocity_air_bf = dcm.transposed() * velocity_air_ef; // airspeed fix for eas2tas update_eas_airspeed();