Class ServoSetup
A servo is a small motor that turns to a position you choose (0 to 1) and holds it there.
Servo claw = ServoSetup.get(hardwareMap, "claw")
.reversed()
.range(0.20, 0.75) // 0 now means 0.20 and 1 means 0.75
.done();
This does NOT move the servo. A servo moves the first time you set a position.
How far 0 to 1 turns it. The hub tells a servo where to go with a pulse: 600 microseconds
(us) for position 0 and 2400 us for 1 (the FTC SDK's normal range). Most FTC servos can take
500 to 2500 us, so the normal range leaves a little of their turn unused: a goBILDA 2000 servo
(300 degrees over 500-2500 us) turns 270 degrees over 0 to 1. fullRange() widens the pulse
to 500-2500 us, so 0 to 1 turns it all 300 degrees. Docs: docs/modules/hardware.md#full-range.
Each step hands back the same ServoSetup (return this) so the next step can follow.
Tutorial 02 (docs/tutorials/02-motors-and-servos.md) shows servos in a full program.
Docs: docs/modules/hardware.md
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe pulse for position 1 withfullRange().static final doubleThe pulse for position 0 withfullRange(): what goBILDA, REV and Axon servos accept.static final doubleThe FTC SDK's normal pulse for position 1, microseconds (PwmControl.PwmRange.usPulseUpperDefault).static final doubleThe FTC SDK's normal pulse for position 0, microseconds (PwmControl.PwmRange.usPulseLowerDefault). -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckPulse(double lowUs, double highUs) Checks a pulse range: 100 to 3000 microseconds, low below high.com.qualcomm.robotcore.hardware.Servodone()Gives you the servo.Uses the servo's whole turn: positions 0 to 1 send 500 to 2500 microseconds instead of the SDK's normal 600 to 2400.static ServoSetupStarts the setup for a servo in the configuration.static ServoSetupof(com.qualcomm.robotcore.hardware.Servo servo) Starts the setup for a servo you already have.pulseRange(double lowUs, double highUs) Sets the pulse the hub sends for positions 0 and 1 (seefullRange()for the usual one).range(double min, double max) Limits the servo to part of its travel.reversed()Position 0 and 1 swap ends.static booleansetPulseRange(com.qualcomm.robotcore.hardware.Servo servo, double lowUs, double highUs) Sets a servo's pulse range if it can (a servo on a REV Control or Expansion Hub, or a Servo Hub, can: it is aPwmControl).
-
Field Details
-
SDK_PULSE_LOW_US
public static final double SDK_PULSE_LOW_USThe FTC SDK's normal pulse for position 0, microseconds (PwmControl.PwmRange.usPulseLowerDefault).- See Also:
-
SDK_PULSE_HIGH_US
public static final double SDK_PULSE_HIGH_USThe FTC SDK's normal pulse for position 1, microseconds (PwmControl.PwmRange.usPulseUpperDefault).- See Also:
-
FULL_PULSE_LOW_US
public static final double FULL_PULSE_LOW_USThe pulse for position 0 withfullRange(): what goBILDA, REV and Axon servos accept.- See Also:
-
FULL_PULSE_HIGH_US
public static final double FULL_PULSE_HIGH_USThe pulse for position 1 withfullRange().- See Also:
-
-
Method Details
-
get
Starts the setup for a servo in the configuration.- Parameters:
hardwareMap- the OpMode'shardwareMapname- the servo's configuration name- Returns:
- the start of the chain
- Throws:
IllegalArgumentException- with the list of real servo names if the name is wrong
-
of
Starts the setup for a servo you already have.- Parameters:
servo- the servo to set up- Returns:
- the start of the chain
-
reversed
Position 0 and 1 swap ends. Use when a servo is mounted mirrored. -
range
Limits the servo to part of its travel. After this, position 0 meansminand position 1 meansmax. Use it so code can never drive the servo into the frame.- Parameters:
min- 0 to 1, the real position used for 0max- 0 to 1, the real position used for 1 (must be bigger than min)
-
fullRange
Uses the servo's whole turn: positions 0 to 1 send 500 to 2500 microseconds instead of the SDK's normal 600 to 2400. A goBILDA 2000 servo then turns 300 degrees over 0 to 1 instead of 270. Do it BEFORE you measure positions (the Servo Finder has the same switch): the same position number points somewhere else after the change. A servo that cannot change its pulse (not on a REV hub) keeps the normal range: checksetPulseRange(com.qualcomm.robotcore.hardware.Servo, double, double)'s answer if you need to know.Servo wrist = ServoSetup.get(hardwareMap, "wrist").fullRange().done();- Returns:
- this setup, for the next step
-
pulseRange
Sets the pulse the hub sends for positions 0 and 1 (seefullRange()for the usual one).- Parameters:
lowUs- microseconds for position 0, e.g. 500 (100 to 3000)highUs- microseconds for position 1, e.g. 2500 (more than lowUs, at most 3000)- Returns:
- this setup, for the next step
- Throws:
IllegalArgumentException- for numbers outside those ranges
-
setPulseRange
public static boolean setPulseRange(com.qualcomm.robotcore.hardware.Servo servo, double lowUs, double highUs) Sets a servo's pulse range if it can (a servo on a REV Control or Expansion Hub, or a Servo Hub, can: it is aPwmControl). Does not move it.- Parameters:
servo- the servolowUs- microseconds for position 0 (100 to 3000)highUs- microseconds for position 1 (more than lowUs, at most 3000)- Returns:
- true if it was set; false if this servo cannot change its pulse (it keeps its range)
- Throws:
IllegalArgumentException- for numbers outside those ranges
-
checkPulse
public static void checkPulse(double lowUs, double highUs) Checks a pulse range: 100 to 3000 microseconds, low below high.- Parameters:
lowUs- microseconds for position 0highUs- microseconds for position 1- Throws:
IllegalArgumentException- when they are not
-
done
public com.qualcomm.robotcore.hardware.Servo done()Gives you the servo. Always end the chain with this.- Returns:
- the servo, set up (it has not moved yet)
-