Servos in FTC
Overview
Servos provide precise, limited-range movement for arms, claws, and similar mechanisms. Standard servos move to a position and hold it. Continuous rotation servos spin like motors.
Standard vs Continuous Rotation
| Feature | Standard Servo | Continuous Rotation (CRServo) |
|---|---|---|
| Control | setPosition(0.0 to 1.0) — position |
setPosition(0.0) reverse, 0.5 stop, 1.0 forward |
| Use Cases | Arms, claws, precise angles | Intake rollers, spinners |
| Config | Servo | CRServo |
Basic Servo Use
Position values 0.0–1.0 represent the servo’s range. Check manufacturer specs for actual angular range.
private Servo clawServo;
@Override
public void runOpMode() {
clawServo = hardwareMap.get(Servo.class, "claw_servo");
clawServo.setPosition(0.5); // Initial position
waitForStart();
while (opModeIsActive()) {
if (gamepad1.a) clawServo.setPosition(0.0);
else if (gamepad1.b) clawServo.setPosition(1.0);
telemetry.addData("Position", clawServo.getPosition());
telemetry.update();
}
}
Multiple Servos and Gradual Movement
Initialize each servo with a unique hardware map name. For smooth motion, change position in small increments over time. Keep positions within 0.0–1.0 to avoid damage.
Gradual Movement Example
Move servo to target in steps.
double current = clawServo.getPosition();
double target = 1.0;
double step = 0.02;
while (Math.abs(current - target) > 0.01 && opModeIsActive()) {
current += (current < target ? step : -step);
current = Math.max(0.0, Math.min(1.0, current));
clawServo.setPosition(current);
sleep(20);
}