RC_Channel: refactor stick_mixing to library

This commit is contained in:
Tom Pittenger 2019-05-01 13:43:27 -07:00 committed by Tom Pittenger
parent 11021bbaa9
commit fbe43dba5c
2 changed files with 22 additions and 0 deletions

View File

@ -359,6 +359,26 @@ bool RC_Channel::has_override() const
return is_positive(override_timeout_ms) && ((AP_HAL::millis() - last_override_time) < (uint32_t)override_timeout_ms);
}
/*
perform stick mixing on one channel
This type of stick mixing reduces the influence of the auto
controller as it increases the influence of the users stick input,
allowing the user full deflection if needed
*/
int16_t RC_Channel::stick_mixing(const int16_t servo_in)
{
float ch_inf = (float)(radio_in - radio_trim);
ch_inf = fabsf(ch_inf);
ch_inf = MIN(ch_inf, 400.0f);
ch_inf = ((400.0f - ch_inf) / 400.0f);
int16_t servo_out = servo_in;
servo_out *= ch_inf;
servo_out += control_in;
return servo_out;
}
//
// support for auxillary switches:
//

View File

@ -71,6 +71,8 @@ public:
void set_override(const uint16_t v, const uint32_t timestamp_us);
bool has_override() const;
int16_t stick_mixing(const int16_t servo_in);
// get control input with zero deadzone
int16_t get_control_in_zero_dz(void) const;