Class ServoRotator
-
- All Implemented Interfaces:
-
crackers.kobots.parts.movement.Actuator
public class ServoRotator extends LimitedRotator
Servo, with software limits to prevent over-rotation.
The physicalRange is the range of the servo target in degrees, and the servoRange is the range of the servo itself, in degrees. For example, a servo that rotates its target 180 degrees, but only requires a 90-degree rotation of the servo, would have a physicalRange of
0..180
and a servoRange of45..135
. This allows for gear ratios and other mechanical linkages. Note that if the servoRange is inverted, the servo will rotate backwards relative to a positive angle.Each "step" is controlled by the delta parameter (degrees to move the servo, default
1
). Since this movement is done in "whole degrees" (int), there will be rounding errors, especially if the gear ratios are not 1:1. Note that using a[delta] != 1
may cause the servo to "seek" when the ranges do not align well and that may also cause the servo to never actually reach the target.
-
-
Field Summary
Fields Modifier and Type Field Description private final Integer
current
private final IntRange
physicalRange
-
Constructor Summary
Constructors Constructor Description ServoRotator(ServoDevice theServo, IntRange servoRange)
Alternate constructor where the "gear ratio" is 1:1 (servo move == physical move). ServoRotator(ServoDevice theServo, IntRange physicalRange, IntRange servoRange, Integer delta)
-
Method Summary
Modifier and Type Method Description Integer
getCurrent()
final IntRange
getPhysicalRange()
Boolean
rotateTo(Integer angle)
Figure out if we need to move or not (and how much) -
-
Method Detail
-
getCurrent
Integer getCurrent()
-
getPhysicalRange
final IntRange getPhysicalRange()
-
-
-
-