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.
This commit is contained in:
gguidone authored and Matthias Grob committed 2026-07-28 16:41:01 +02:00
1 parent b9355ef83e
commit eca039bd52
1 file changed
+1 -1
+1 -1
View File
@@ -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]));