AP_ServoRelayEvents: allow mavlink command of rcin scaled functions #25241
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow
MAV_CMD_DO_SET_SERVO
andMAV_CMD_DO_REPEAT_SERVO
to be used ona servo output set to an RCINnScaled function (i.e. k_rcinN_mapped).
Scaling is applied so that a commanded servo PWM of <=1000 maps to
SERVOn_MIN, a PWM of 1500 maps to SERVOn_TRIM, and a PWM of >=2000 maps to
SERVOn_MAX. Linear interpolation is performed between ranges.
This allows control of servos/hardware with reasonable/safe scaling applied by firmware and allows more functionality from mission scripts.
In our use case we have a variable aperture controlled by a hobby servo for releasing crop seeds. The scaling is controlled by the mechanical geometry and programmed in the autopilot firmware so that SERVOn_MIN is fully closed and SERVOn_MAX is fully open. By setting the servo function to an RC scaled value, we can have straightforward controls from both an RC controller programmed to send 1000-2000 on a knob and mission scripts with that same range without danger of going overrange and damaging the mechanism or servo. This concept should extend logically to many other types of actuators one may wish to attach which don't fall under e.g. camera or sprayer headings.
Tested on SITL (on top of master) and on a real copter (on top of Copter-4.4.1).