Servos
NextServo is a lightweight wrapper around a standard FTC servo (ServoImplEx) that gives you a more user-friendly interface for controlling position and PWM range.
Creating a NextServo
Section titled “Creating a NextServo”There are two main ways to construct a NextServo, depending on what you desire.
// By Lynx Module and port, recommendedval armServo = NextServo(RobotController.controlHub, 0)
// Using a configuration nameval armServo = NextServo("armServo") // By Lynx Module and port, recommendedNextServo armServo = new NextServo(RobotController.controlHub(), 0);
// Using a configuration nameNextServo armServo = new NextServo("armServo");All constructors accept two optional parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
cacheTolerance |
Double |
0.01 |
Minimum change in position required before a new value is written to the servo. |
direction |
NextMotor.Direction |
FORWARD |
Initial direction of the servo. |
position
Section titled “position”NextServo has a positionable property in the range [0.0, 1.0] as a Double.
This is what will set your servo to actually move.
armServo.position = 0.5armServo.setPosition(0.5);pwmRange
Section titled “pwmRange”PwmControl.PwmRange is the servo’s PWM range configuration.
Get or set directly, or use setPwmRange for a more convenient two-argument setter.
setPwmRange(lower, upper)
Section titled “setPwmRange(lower, upper)”Sets the PWM range of the servo.
| Parameter | Type | Description |
|---|---|---|
lower |
Double |
Lower bound of the PWM range, in microseconds. |
upper |
Double |
Upper bound of the PWM range, in microseconds. |
armServo.setPwmRange(500.0, 2500.0)armServo.setPwmRange(500.0, 2500.0);
