From 7c2d13c5711301c3ccb828ceb03fd0b8b96e1ce3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 May 2020 16:12:09 +1000 Subject: [PATCH] SITL: added simulation of pressure altitude for multicopter this gives us a ceiling of 5.4km above sea level for the default copter --- libraries/SITL/SIM_Frame.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/SITL/SIM_Frame.cpp b/libraries/SITL/SIM_Frame.cpp index 96a9c834a1..7e5a3aef28 100644 --- a/libraries/SITL/SIM_Frame.cpp +++ b/libraries/SITL/SIM_Frame.cpp @@ -18,6 +18,7 @@ #include "SIM_Frame.h" #include +#include #include @@ -314,14 +315,17 @@ void Frame::calculate_forces(const Aircraft &aircraft, { Vector3f thrust; // newtons + // scale thrust for altitude + float scaling = thrust_scale * AP::baro().get_air_density_ratio(); + for (uint8_t i=0; ivibe_motor)) { - rpm[i] = sqrtf(mthrust.length() / thrust_scale) * AP::sitl()->vibe_motor * 60.0f; + rpm[i] = sqrtf(mthrust.length() / scaling) * AP::sitl()->vibe_motor * 60.0f; } }