There was a lot of discution about the servo mapper this week-end and we did not seem to found a consensus how to fix the problem related the it's usage.
To have the servo service work properly, the user should be able to
map the range they are using to the position the servo should take
modify the limits a servo should have
Set and get any parameters about the servo in the range they are using (input)
The problem with the current implementation of the mapper is that the limits (min/max) are set on the output wich lead to many confusion and logic problems
by example, if I have a map(0,90,90,180)
If I want to limits the range from 0-90 to 10-90... I must use servo.setMin(100)!!!
and if the map is more complex, like (45,135,38,140) I have to make a manual computation to find how I must set the limits
It also make it hard to compare the position of the servo with it's min/max
So I really think the limits should be set using the Input value
But fixing that potentially break some backward compatibility.
Some path of solution have been proposed or my understanding of what proposed
Leave it that way: don't break any script, but will always make services that modify servo position hard to do and be solid in all situation
Remove the mapper and use gain/shift parameters: I'm not against the idea, but not convince it's easy to use in all the situation. By example how do I replicate what a map(45,135,38,140) do with the gain/shift parameters? I need to do manual computation to find the right parameters?
Keep it this way, but have getMin reverse map the setMin. That will help fixing the problem of comparing position to min/max, but can still be very confusing.
What I think is the best solutions is to remove the setMin/setMax and replace them with more explicit method like setMinInput, setMaxOutput etc. That will break scripts that can potentially have problem with the map setting, but better have the script not run than use bad parameters and burn servo or break part. The new setMin/max methods will also compute their counter part (Input/Output) by mapping or reversemapping the value. by example with a map(0,90,90,180), a setMinInput(10) will be the same as doing setMinOutput(100). That will also have the flexibility to apply the limits to the range we want (Input or Output), but I still beleive that using it on the Input value is much more better