AP_Motors: use the right constrain() function
This commit is contained in:
parent
d5875676b1
commit
2c05030fb1
@ -382,7 +382,7 @@ void AP_MotorsHeli::init_swash()
|
||||
collective_max = 2000;
|
||||
}
|
||||
|
||||
collective_mid = constrain(collective_mid, collective_min, collective_max);
|
||||
collective_mid = constrain_int16(collective_mid, collective_min, collective_max);
|
||||
|
||||
// calculate throttle mid point
|
||||
throttle_mid = ((float)(collective_mid-collective_min))/((float)(collective_max-collective_min))*1000.0f;
|
||||
@ -472,13 +472,13 @@ void AP_MotorsHeli::move_swash(int16_t roll_out, int16_t pitch_out, int16_t coll
|
||||
// coming into this equation at 4500 or less, and based on the original assumption of the
|
||||
// total _servo_x.servo_out range being -4500 to 4500.
|
||||
roll_out = roll_out * _roll_scaler;
|
||||
roll_out = constrain(roll_out, (int16_t)-roll_max, (int16_t)roll_max);
|
||||
roll_out = constrain_int16(roll_out, (int16_t)-roll_max, (int16_t)roll_max);
|
||||
|
||||
pitch_out = pitch_out * _pitch_scaler;
|
||||
pitch_out = constrain(pitch_out, (int16_t)-pitch_max, (int16_t)pitch_max);
|
||||
pitch_out = constrain_int16(pitch_out, (int16_t)-pitch_max, (int16_t)pitch_max);
|
||||
|
||||
// scale collective pitch
|
||||
coll_out = constrain(coll_in, 0, 1000);
|
||||
coll_out = constrain_int16(coll_in, 0, 1000);
|
||||
if (stab_throttle){
|
||||
coll_out = coll_out * _stab_throttle_scalar + stab_col_min*10;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ void AP_MotorsMatrix::output_armed()
|
||||
_reached_limit = AP_MOTOR_NO_LIMITS_REACHED;
|
||||
|
||||
// Throttle is 0 to 1000 only
|
||||
_rc_throttle->servo_out = constrain(_rc_throttle->servo_out, 0, _max_throttle);
|
||||
_rc_throttle->servo_out = constrain_int16(_rc_throttle->servo_out, 0, _max_throttle);
|
||||
|
||||
// capture desired roll, pitch, yaw and throttle from receiver
|
||||
_rc_roll->calc_pwm();
|
||||
@ -256,7 +256,7 @@ void AP_MotorsMatrix::output_armed()
|
||||
// clip motor output if required (shouldn't be)
|
||||
for( i=0; i<AP_MOTORS_MAX_NUM_MOTORS; i++ ) {
|
||||
if( motor_enabled[i] ) {
|
||||
motor_out[i] = constrain(motor_out[i], out_min, out_max);
|
||||
motor_out[i] = constrain_int16(motor_out[i], out_min, out_max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ void AP_MotorsTri::output_armed()
|
||||
int16_t out_max = _rc_throttle->radio_max;
|
||||
|
||||
// Throttle is 0 to 1000 only
|
||||
_rc_throttle->servo_out = constrain(_rc_throttle->servo_out, 0, _max_throttle);
|
||||
_rc_throttle->servo_out = constrain_int16(_rc_throttle->servo_out, 0, _max_throttle);
|
||||
|
||||
if(_rc_throttle->servo_out > 0)
|
||||
out_min = _rc_throttle->radio_min + _min_throttle;
|
||||
|
Loading…
Reference in New Issue
Block a user