From a018bed042734d43ffe264aee527fd6a1db22039 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 9 Nov 2023 16:39:27 +1100 Subject: [PATCH] SITL: improve MegaSquirt simulator fidelity --- libraries/SITL/SIM_EFI_MegaSquirt.cpp | 8 +++++--- libraries/SITL/SIM_EFI_MegaSquirt.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/SITL/SIM_EFI_MegaSquirt.cpp b/libraries/SITL/SIM_EFI_MegaSquirt.cpp index 7cdc183b42..2935024ce0 100644 --- a/libraries/SITL/SIM_EFI_MegaSquirt.cpp +++ b/libraries/SITL/SIM_EFI_MegaSquirt.cpp @@ -41,16 +41,18 @@ void EFI_MegaSquirt::update() if (!sitl || sitl->efi_type != SIM::EFI_TYPE_MS) { return; } - float rpm = sitl->state.rpm[0]; + const float rpm = sitl->state.rpm[2]; + + tps = 0.9 * tps + 0.1 * (rpm / 7000) * 100; table7.rpm = rpm; table7.fuelload = 20; table7.dwell = 2.0; table7.baro_hPa = 1000; table7.map_hPa = 895; - table7.mat_cF = 3013; + table7.mat_cF = C_TO_F(AP::baro().get_temperature()) * 10; table7.fuelPressure = 6280; - table7.throttle_pos = 580; + table7.throttle_pos = tps * 10; table7.ct_cF = 3940; table7.afr_target1 = 148; diff --git a/libraries/SITL/SIM_EFI_MegaSquirt.h b/libraries/SITL/SIM_EFI_MegaSquirt.h index f957a296c7..813e22e5e6 100644 --- a/libraries/SITL/SIM_EFI_MegaSquirt.h +++ b/libraries/SITL/SIM_EFI_MegaSquirt.h @@ -96,6 +96,8 @@ private: uint8_t pad[128-67]; uint16_t fuelPressure; } table7; + + float tps; }; }