From eca039bd52196f83c744592e0896ed2235185ebf Mon Sep 17 00:00:00 2001 From: gguidone Date: Mon, 27 Jul 2026 10:15:36 +0200 Subject: [PATCH] fix(simulation): model reverse thrust for reversible motors in SIH hexacopter The SIH hexacopter dynamics squared the motor command (u_sq = u * u), which discards its sign, so a reversed (negative) command produced forward thrust instead of reverse. pwm_out_sim already emits signed [-1, 1] outputs for reversible motors, so only the plant model dropped the sign. Use a signed square (u * |u|) so a reversed command yields reverse thrust and the correspondingly flipped roll/pitch/yaw torque. Behaviour-neutral for non-reversible motors (u >= 0), which is the only regime the previous plain square could represent. --- src/modules/simulation/simulator_sih/sih.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/simulation/simulator_sih/sih.cpp b/src/modules/simulation/simulator_sih/sih.cpp index 12ccdc0d7ae..ff7a41db739 100644 --- a/src/modules/simulation/simulator_sih/sih.cpp +++ b/src/modules/simulation/simulator_sih/sih.cpp @@ -466,7 +466,7 @@ void Sih::generate_force_and_torques(const float dt) float u_sq[6]; for (int i = 0; i < 6; ++i) { - u_sq[i] = _u[i] * _u[i]; // quadratic thrust model, keep _u[i] intact for the filter + u_sq[i] = _u[i] * fabsf(_u[i]); } _T_B = Vector3f(0.0f, 0.0f, -_T_MAX * (+u_sq[0] + u_sq[1] + u_sq[2] + u_sq[3] + u_sq[4] + u_sq[5]));