ardupilot
ardupilot copied to clipboard
Heli Motors: Make servo linearisation scheme generic
Our current servo linearisation scheme assumes a max servo horn angle of 50 deg. As is demonstrated in the Matlab plots below an assumed angle can make the error from linear more exacerbated than the uncorrected output, if the particular vehicle does not have a servo horn range of 50 deg.
The linearisation parameter has been renamed and a param conversion added. There will be no change in behaviour when upgrading. On the off-chance somebody has accidently enabled the linearisation with a param value > 1, the resulting scaled param value will be caught by a pre-arm check.
The plots below show a series of different scenarios with the "actual" servo range indicated in the plot titles. Plots on the left show the vertical position of the servo horn, assuming a horn length of 1 cm (for illustrative purposes only). The plot on the right then gives the error from linear. As can be seen, in some cases the error in the current corrected case can actually be larger than the non-linearised case. In all cases, adding this degree of customisation in the parameter allows us to remove that error from the linearisation.
I have moved the arming checks down into swashplate library as suggested. I figured that this is slightly easier to do with the swashplate _instance variable that is introduced in this PR: https://github.com/ArduPilot/ardupilot/pull/26606
As it stands this PR won't build and is dependant upon the above PR.
I have rebased now that #26606 is in. From my perspective this is ready for another review.
@MattKear So are you saying that there are servos with angle range greater than +/-50 deg for pwm range of 1000 to 2000? I'm asking cause I don't know. How will users know if their servo arm angle range is not +/- 50 deg?