Class ExpansionHubCRServo
java.lang.Object
org.wpilib.hardware.expansionhub.ExpansionHubCRServo
- All Implemented Interfaces:
AutoCloseable
This class controls a specific servo in continuous rotation mode hooked up to an ExpansionHub.
-
Constructor Summary
ConstructorsConstructorDescriptionExpansionHubCRServo(int usbId, int channel) Constructs a continuous rotation servo at the requested channel on a specific USB port. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes a servo so another instance can be constructed.booleanGets if the underlying ExpansionHub is connected.voidsetEnabled(boolean enabled) Sets if the servo output is enabled or not.voidsetFramePeriod(Time framePeriod) Sets the frame period for the servo.voidsetPulseWidth(Time pulseWidth) Sets the raw pulse width output on the servo.voidsetPWMRange(int minPwm, int maxPwm) Sets the PWM range for the servo.voidsetReversed(boolean reversed) Sets whether the servo is reversed.voidsetThrottle(double value) Set the servo throttle.
-
Constructor Details
-
ExpansionHubCRServo
Constructs a continuous rotation servo at the requested channel on a specific USB port.- Parameters:
usbId- The USB port ID the hub is connected tochannel- The servo channel
-
-
Method Details
-
close
Closes a servo so another instance can be constructed.- Specified by:
closein interfaceAutoCloseable
-
setThrottle
Set the servo throttle.Throttle values range from -1.0 to 1.0 corresponding to full reverse to full forward.
- Parameters:
value- Throttle from -1.0 to 1.0.
-
setPulseWidth
Sets the raw pulse width output on the servo.- Parameters:
pulseWidth- Pulse width
-
setEnabled
Sets if the servo output is enabled or not. Defaults to false.- Parameters:
enabled- True to enable, false to disable
-
setFramePeriod
Sets the frame period for the servo. Defaults to 20ms.- Parameters:
framePeriod- The frame period
-
isHubConnected
Gets if the underlying ExpansionHub is connected.- Returns:
- True if hub is connected, otherwise false
-
setReversed
Sets whether the servo is reversed.This will reverse setThrottle().
- Parameters:
reversed- True to reverse, false for normal
-
setPWMRange
Sets the PWM range for the servo. By default, this is 600 to 2400 microseconds.Maximum must be greater than minimum.
- Parameters:
minPwm- Minimum PWMmaxPwm- Maximum PWM
-