We seem to have some trouble getting the continuous rotation servo to stop moving. The servo should move when button A on Gamepad 1 is pressed and should stop when released. Here is the code snippet we have:
if (gamepad1.a ) {
// if the A button is pushed on gamepad1, increment the position of the servo.
linearPosition = linearSliderLeft.getPosition()+ linearDelta;
linearPosition = Range.clip(linearPosition, 0.2, 0.8);
linearSliderLeft.setPosition(linearPosition);
}
Should we have an else block in which we stop the servo with a setPosition call? We have tried setting it to 0.45, 0.5 and 0.55 but the servo still keeps moving.
There is not a whole lot of FTC traffic on CD, but as I see it’s been a while with no posts at all, I’ll post something that may or may not be helpful.
Caveat: I have not done any FTC. I have used “generic” continuous rotation servos, however, e.g. the ones on Boe Bots. If the FTC continuous servos are not like those, this will be useless.
Generic Continuous Rotation Servos either do not have a potentiometer, or have broken the link between it and the rotation shaft. The practical upshot is that it is a “servo” that thinks it is always at center. This means that the farther from center you try to “set” its position, the faster/harder it tries to go that direction. There should be some “set” value which results in the servo not rotating.
When you change the “position”, does the speed and/or direction of rotation change? If so, I suggest that you interpolate/extrapolate to where the wheel should not rotate, enter that value, and iterate until you get a non-rotating shaft. (This is known numerically as Newton’s Method for finding a root, if you want to Google more about it.)
If the speed does not change, I’d suggest verifying that you’re addressing the correct pin. If you’re sure of that, try another method to see if you’re really sending a good PWM signal to the port. This could be (for example) an oscilloscope, a regular servo, or a PWM motor controller like used in FRC. Hopefully the answer to that will give you a clue which way to go from there; if not, post your results and we’ll help you through it.
The servo will not rotate when set to about 0.5 (some servos behave differently than others, 0.49 worked fine for us). And like GeeTwo said, you can’t get position information from a continuous rotation servo, so you need some other method.
For 0.45 and 0.55, did the servo move in different directions? If so, the no-rotation spot is somewhere in between.
No, I would not expect this; I know that the Boe Bots CR servos are stationary when they do not receive a signal. Are you perhaps putting some sort of signal on port 6?
We ran into a similar thing, and I suspect (but do not know for sure) that when any servo is commanded to a position that all others not commanded go to position “0.0” - which for the CR servos makes them keep moving.
One of us has misread something. The way I read this:
That is, you programmed port 1 to move to 0.5, but did not program port 6.
Christopher’s speculation is that port 6 would be directed to position 0. If true, this would result in a full reverse for a CR servo, independent of the specific number programmed for port 1.