Skip to main content

Unit 9 Mastery Quiz: Servo Control


I. Conceptual Questions

1. Positional vs. Velocity Logic: Why must the programmer use the setPosition() method for a standard servo instead of setPower(), and what physical behavior does this method command from the Control Hub?

Show answer

setPosition() commands the servo to move to a specific angular coordinate (a fraction from 0.0 to 1.0 of its total travel) using PWM signals. Standard servos contain an internal feedback circuit that drives the motor until the output shaft reaches the target angle and then holds it there. They are positional devices, not velocity-driven like DC motors — setPower() is not part of the Servo interface at all.


2. Mechanical Safeguarding: Why is implementing scaleRange() in the init() method considered a critical safety standard for mechanisms like internal gates or scoring latches?

Show answer

It prevents mechanical binding. By constraining the software limits to match the physical hard stops of the mechanism, you prevent the servo from ever being commanded past its safe range. Without it, a setPosition(1.0) call could drive the servo into its physical barrier, causing a current spike that strips internal gears and can damage the Control Hub port from sustained overcurrent.


3. Logical Abstraction: When dealing with a dual-servo mirrored assembly, why is using setDirection(Servo.Direction.REVERSE) technically superior to manually calculating the inverse position (e.g., 1 - position) in the loop() method?

Show answer

Using setDirection(REVERSE) provides logical abstraction at the hardware level. It ensures that identical position commands always produce symmetrical physical behavior regardless of which method or OpMode issues them, with no mental overhead for the programmer. Manual inversion with 1 - position must be remembered and correctly applied at every single call site throughout the codebase, and a single omission breaks the mechanism silently.


4. Signal Conflict (Jitter): Why is it technically dangerous to call setPosition() multiple times for the same hardware object within different if branches of a single loop() cycle?

Show answer

Sending multiple conflicting position commands within a single 50Hz update period causes servo jitter — the servo rapidly oscillates between competing target angles because the hardware controller receives contradictory instructions faster than it can physically execute them. This mechanical oscillation strains the servo gears and produces erratic behavior. Using an else if chain guarantees exactly one unambiguous command per cycle.


5. Hardware Class Distinction: Why does the SDK require a CRServo to be instantiated using CRServo.class rather than the standard Servo.class, and how does this change the available control methods for the programmer?

Show answer

Type safety — a CRServo is treated as a continuously spinning motor by the SDK and uses setPower() for velocity control, whereas a positional Servo uses setPosition() for angular control. They are distinct hardware classes with different underlying control interfaces. Instantiating a CR servo as a Servo would compile without error but crash at runtime when the incompatible method is called on the wrong hardware type.


II. Debug the Code

The following code is intended to program a mirrored claw mechanism. The right_claw servo is mounted upside down. Both servos should move to 1.0 when gamepad1.a is pressed. Identify and fix the 2 errors.

package org.firstinspires.ftc.teamcode;

import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.Servo;

@TeleOp(name="Claw_Sync_Debug")
public class ClawSync extends OpMode {

private Servo leftClaw;
private Servo rightClaw;

@Override
public void init() {
leftClaw = hardwareMap.get(Servo.class, "left_claw");
rightClaw = hardwareMap.get(Servo.class, "right_claw")
rightClaw.setDirection(Servo.Direction.REVERSE);
}

@Override
public void loop() {
if (gamepad1.a) {
leftClaw.setPosition(1.0);
rightClaw.setPower(1.0);
}
}
}
Show answers

Error 1 — Syntax Error: The hardwareMap.get() call for rightClaw in init() is missing a semicolon (;) at the end of the statement.

rightClaw = hardwareMap.get(Servo.class, "right_claw"); // ← semicolon added

Error 2 — Logic Error: The programmer is calling rightClaw.setPower(1.0) on a standard Servo object. Positional servos do not support the setPower() method — that belongs to CRServo and DcMotor. The correct method for a standard servo is setPosition():

rightClaw.setPosition(1.0); // ← setPosition, not setPower

Ready to move on?

Sign in with Google to save your progress with Telemark, or continue without saving.