-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sensors: use interpolation to set param from RC input #7676
Conversation
Jenkins test this please. |
This makes it non-linear over the full range. I'm not sure if that's more intuitive for others. If the zero value is close to min or max it will lead to very different scales to either side. |
@LorenzMeier Yes, technically it's piece-wise linear, so linear from minimum-to-center, then linear from center-to-maximum values. The advantage is that the interpolation is taken care of by the software; no need to set a scale value (essentially a slope). I would argue that this is more intuitive than requiring an end-user to calculate their own scale value, especially if they're gain tuning in the field and there's no clear indication of what the scale value does (specifically from the ground station). Below is an illustration wherein I set a range of values to tweak MC_PITCHRATE_D. Without knowing that "Scale" needs to be adjusted - QGC says "Scale (keep default)" - the only possible param values from the transmitter knob are essentially the min, center, and max values. Full disclosure, in this particular case, you do have some in-between values here, but as soon as rc_val >= +/-0.02, the param is at min/max. Of course, this isn't quite as bad if you're tuning with some larger numbers (e.g. MC_PITCHRATE_P - Indeed, you may have quite different scales on either side of the center (zero) value. However, this makes plenty of sense if you want to start tuning from the middle and perhaps you want to severely limit your tuning in one direction and leave a large range in the opposite direction. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Still interested in this? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Closing as stale. |
This PR changes the set_params_from_rc() function to use linear interpolation between the user-defined min, center, and max values based on the RC Input value. Since rc_val is essentially a percentage, and constrained from -1.0 to +1.0, all that's required to implement this is a small change to the "param_val" calculation as such:
Of course, this will be a change of philosophy in parameter tuning via RC input. In my personal case, while gain tuning a new airframe I set some values for MC_PITCHRATE_D assuming the parameter would interpolate between min, center, and max values. Since I left the "Scale" value to 1.0 and the derivative gains are so small, any small change in the RC Input away from the center input would immediately change the parameter from center to min or center to max. So the derivative gain didn't do anything as I increased the transmitter knob from min to its center, then just past half-way on the knob, the derivative gain immediately went from my min to my max value, causing some pretty wild behavior.
All that said, in my opinion, the presented change is a simpler approach to parameter tuning via RC input such that the end user doesn't need to figure out a "Scale" value for appropriate interpolation, rather the end user only needs to set min, center, and max values and the software will set the parameter accordingly.