mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-22 07:44:03 -04:00
RC_Channel: refactor stick_mixing to library
This commit is contained in:
parent
11021bbaa9
commit
fbe43dba5c
@ -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:
|
||||
//
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user