Skip to content

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.

There are two main ways to construct a NextServo, depending on what you desire.

// By Lynx Module and port, recommended
val armServo = NextServo(RobotController.controlHub, 0)
// Using a configuration name
val armServo = 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.

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.5

PwmControl.PwmRange is the servo’s PWM range configuration. Get or set directly, or use setPwmRange for a more convenient two-argument setter.

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)