Rescale TradHeli roll_out and pitch_out into the min and max ranges to provide linear motion across the input range instead of stopping when the input hits the constrain value. These calculations are based on an assumption of the user specified roll_max and pitch_max coming into this equation at 4500 or less, and based on the original assumption of the total g.heli_servo_x.servo_out range being -4500 to 4500.

Signed-off-by: Robert Lefebvre <robert.lefebvre@gmail.com>
This commit is contained in:
Robert Lefebvre 2012-03-01 22:04:45 -05:00
parent ee5e331f3c
commit e49c2d2871
1 changed files with 9 additions and 0 deletions

View File

@ -141,6 +141,15 @@ static void heli_move_swash(int roll_out, int pitch_out, int coll_out, int yaw_o
pitch_out = constrain(pitch_out, (int)-g.heli_pitch_max, (int)g.heli_pitch_max); pitch_out = constrain(pitch_out, (int)-g.heli_pitch_max, (int)g.heli_pitch_max);
coll_out = constrain(coll_out, 0, 1000); coll_out = constrain(coll_out, 0, 1000);
coll_out_scaled = coll_out * heli_collective_scalar + g.heli_collective_min - 1000; coll_out_scaled = coll_out * heli_collective_scalar + g.heli_collective_min - 1000;
// rescale roll_out and pitch-out into the min and max ranges to provide linear motion
// across the input range instead of stopping when the input hits the constrain value
// these calculations are based on an assumption of the user specified roll_max and pitch_max
// coming into this equation at 4500 or less, and based on the original assumption of the
// total g.heli_servo_x.servo_out range being -4500 to 4500.
roll_out = (-g.heli_roll_max + (float)( 2 * g.heli_roll_max * (roll_out + 4500.0)/9000.0));
pitch_out = (-g.heli_pitch_max + (float)(2 * g.heli_pitch_max * (pitch_out + 4500.0)/9000.0));
// rudder feed forward based on collective // rudder feed forward based on collective
#if HIL_MODE == HIL_MODE_DISABLED // don't do rudder feed forward in simulator #if HIL_MODE == HIL_MODE_DISABLED // don't do rudder feed forward in simulator