Created
March 19, 2018 14:21
-
-
Save MaEtUgR/13ce0466e1aa0df9c968e953842db99f to your computer and use it in GitHub Desktop.
Mixer Roll Pitch Saturation Testing Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
roll = 0.7; | |
pitch = 0.8; | |
thrust = 0.9; | |
out = [thrust + 3*(roll + pitch); thrust + (-roll + pitch); thrust + 3*(roll - pitch); thrust + (-roll - pitch)] | |
max_out = max(out); | |
min_out = min(out); | |
delta_out_max = max_out - min_out; | |
roll_pitch_scale = 1; | |
boost = 0; | |
if delta_out_max <= 1 | |
if min_out < 0 | |
boost = -min_out; | |
elseif max_out > 1 | |
boost = -(max_out - 1); | |
end | |
else | |
roll_pitch_scale = 1 / (delta_out_max); | |
boost = 1 - ((max_out - thrust) * roll_pitch_scale + thrust) | |
boost1 = 1-thrust-roll_pitch_scale*(max_out - thrust) | |
boost2 = -thrust -roll_pitch_scale*(min_out - thrust) | |
boost_max = 1 - max_out * roll_pitch_scale | |
boost_min = -min_out * roll_pitch_scale | |
end | |
scatter([0 0], [0 1], 'filled', 'r'); | |
hold on | |
scatter([.05], thrust, 'filled', 'k'); | |
scatter([.1 .1 .1 .1], out', 'filled', 'b'); | |
scatter([.15 .15], [max_out min_out], 'filled', 'm'); | |
thrust = thrust + boost; | |
out2 = [thrust + 3*(roll + pitch)*roll_pitch_scale; thrust + (- roll + pitch)*roll_pitch_scale; thrust + 3*(roll - pitch)*roll_pitch_scale; thrust + (- roll - pitch)*roll_pitch_scale] | |
scatter([.2 .2 .2 .2], out2', 'filled', 'g'); | |
axis equal | |
hold off |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment