DiffyServo
The DiffyServo
class provides easy control over two servos, allowing for differential control. This class is part of the org.gentrifiedApps.gentrifiedAppsUtil.classExtenders.servo
package.
Constructor
There are multiple constructors available to initialize the DiffyServo
class:
Basic Initialization:
DiffyServo diffyServo = new DiffyServo(hardwareMap, "leftServo", "rightServo");hardwareMap
: The hardware map of the robot.leftServo
: The name of the left servo.rightServo
: The name of the right servo.
With Directions:
DiffyServo diffyServo = new DiffyServo(hardwareMap, "leftServo", "rightServo", Servo.Direction.FORWARD, Servo.Direction.REVERSE);leftDirection
: The direction of the left servo.rightDirection
: The direction of the right servo.
With Idle Position:
DiffyServo diffyServo = new DiffyServo(hardwareMap, "leftServo", "rightServo", 0.5);idlePosition
: The idle position of the servos.
Full Initialization:
DiffyServo diffyServo = new DiffyServo(hardwareMap, "leftServo", "rightServo", Servo.Direction.FORWARD, Servo.Direction.REVERSE, 0.5);
Methods
setPosition
Sets the position of the servos to the current values of lPos
and rPos
.
rotateDown
Rotates both servos down by the specified position.
rotateUp
Rotates both servos up by the specified position.
rotateLeft
Rotates the servos to the left by the specified position (opposite directions).
rotateRight
Rotates the servos to the right by the specified position (opposite directions).
applyPreset
Uses a DiffyPreset
to set the left and right positions.