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 of 45..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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • 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)
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • 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)
      • Methods inherited from class crackers.kobots.parts.movement.LimitedRotator

        rem
      • Methods inherited from class crackers.kobots.parts.movement.Rotator

        move
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait