AP_Motors: Fix up after RC_Channels refactor
Further to refactor of RC_Channel class which included adding get_xx set_xx methods, change reads and writes to the public members to calls to get and set functionsss old public member(int16_t) get function -> int16_t set function (int16_t) (expression where c is an object of type RC_Channel) c.radio_in c.get_radio_in() c.set_radio_in(v) c.control_in c.get_control_in() c.set_control_in(v) c.servo_out c.get_servo_out() c.set_servo_out(v) c.pwm_out c.get_pwm_out() // use existing c.radio_out c.get_radio_out() c.set_radio_out(v) c.radio_max c.get_radio_max() c.set_radio_max(v) c.radio_min c.get_radio_min() c.set_radio_min(v) c.radio_trim c.get_radio_trim() c.set_radio_trim(v); c.min_max_configured() // return true if min and max are configured Because data members of RC_Channels are now private and so cannot be written directly some overloads are provided in the Plane classes to provide the old functionality new overload Plane::stick_mix_channel(RC_Channel *channel) which forwards to the previously existing void stick_mix_channel(RC_Channel *channel, int16_t &servo_out); new overload Plane::channel_output_mixer(Rc_Channel* , RC_Channel*)const which forwards to (uint8_t mixing_type, int16_t & chan1, int16_t & chan2)const; Rename functions RC_Channel_aux::set_radio_trim(Aux_servo_function_t function) to RC_Channel_aux::set_trim_to_radio_in_for(Aux_servo_function_t function) RC_Channel_aux::set_servo_out(Aux_servo_function_t function, int16_t value) to RC_Channel_aux::set_servo_out_for(Aux_servo_function_t function, int16_t value) Rationale: RC_Channel is a complicated class, which combines several functionalities dealing with stick inputs in pwm and logical units, logical and actual actuator outputs, unit conversion etc, etc The intent of this PR is to clarify existing use of the class. At the basic level it should now be possible to grep all places where private variable is set by searching for the set_xx function. (The wider purpose is to provide a more generic and logically simpler method of output mixing. This is a small step)
This commit is contained in:
parent
ba9462d13d
commit
daec4ea10e
@ -348,8 +348,8 @@ void AP_MotorsHeli::reset_swash_servo(RC_Channel& servo)
|
||||
servo.set_range_out(0, 1000);
|
||||
|
||||
// swash servos always use full endpoints as restricting them would lead to scaling errors
|
||||
servo.radio_min = 1000;
|
||||
servo.radio_max = 2000;
|
||||
servo.set_radio_min(1000);
|
||||
servo.set_radio_max(2000);
|
||||
}
|
||||
|
||||
// update the throttle input filter
|
||||
|
@ -162,6 +162,6 @@ void AP_MotorsHeli_RSC::write_rsc(float servo_out)
|
||||
// ToDo: We should probably use RC_Channel_Aux to avoid this problem
|
||||
return;
|
||||
} else {
|
||||
RC_Channel_aux::set_servo_out(RC_Channel_aux::k_heli_rsc, servo_out * 1000.0f);
|
||||
RC_Channel_aux::set_servo_out_for(RC_Channel_aux::k_heli_rsc, servo_out * 1000.0f);
|
||||
}
|
||||
}
|
||||
|
@ -154,12 +154,12 @@ int16_t AP_Motors::calc_pwm_output_1to1(float input, const RC_Channel& servo)
|
||||
}
|
||||
|
||||
if (input >= 0.0f) {
|
||||
ret = ((input * (servo.radio_max - servo.radio_trim)) + servo.radio_trim);
|
||||
ret = ((input * (servo.get_radio_max() - servo.get_radio_trim())) + servo.get_radio_trim());
|
||||
} else {
|
||||
ret = ((input * (servo.radio_trim - servo.radio_min)) + servo.radio_trim);
|
||||
ret = ((input * (servo.get_radio_trim() - servo.get_radio_min())) + servo.get_radio_trim());
|
||||
}
|
||||
|
||||
return constrain_int16(ret, servo.radio_min, servo.radio_max);
|
||||
return constrain_int16(ret, servo.get_radio_min(), servo.get_radio_max());
|
||||
}
|
||||
|
||||
// convert input in 0 to +1 range to pwm output
|
||||
@ -173,9 +173,9 @@ int16_t AP_Motors::calc_pwm_output_0to1(float input, const RC_Channel& servo)
|
||||
input = 1.0f-input;
|
||||
}
|
||||
|
||||
ret = input * (servo.radio_max - servo.radio_min) + servo.radio_min;
|
||||
ret = input * (servo.get_radio_max() - servo.get_radio_min()) + servo.get_radio_min();
|
||||
|
||||
return constrain_int16(ret, servo.radio_min, servo.radio_max);
|
||||
return constrain_int16(ret, servo.get_radio_min(), servo.get_radio_max());
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user