ExpansionHubServo
- class wpilib.ExpansionHubServo(usbId: SupportsInt | SupportsIndex, channel: SupportsInt | SupportsIndex)
Bases:
pybind11_objectThis class controls a specific servo in positional/servo mode hooked up to an ExpansionHub.
Constructs a servo at the requested channel on a specific USB port.
@sa ExpansionHubCRServo if the servo is in continuous rotation mode
- Parameters:
usbId – The USB port ID the hub is connected to
channel – The servo channel
- isHubConnected() bool
Gets if the underlying ExpansionHub is connected.
- Returns:
True if hub is connected, otherwise false
- setAngle(angle: wpimath.units.degrees) None
Sets the servo angle.
Servo angles range defaults to 0 to 180 degrees, but can be changed with setAngleRange().
- Parameters:
angle – Position in angle units. Will be clamped to be within the current angle range.
- setAngleRange(minAngle: wpimath.units.degrees, maxAngle: wpimath.units.degrees) None
Sets the angle range for the SetAngle call. By default, this is 0 to 180 degrees.
Maximum angle must be greater than minimum angle.
- Parameters:
minAngle – Minimum angle
maxAngle – Maximum angle
- setEnabled(enabled: bool) None
Sets if the servo output is enabled or not. Defaults to false.
- Parameters:
enabled – True to enable, false to disable
- setFramePeriod(framePeriod: wpimath.units.microseconds) None
Sets the frame period for the servo. Defaults to 20ms.
- Parameters:
framePeriod – The frame period
- setPWMRange(minPwm: wpimath.units.microseconds, maxPwm: wpimath.units.microseconds) None
Sets the PWM range for the servo. By default, this is 600 to 2400 microseconds.
Maximum must be greater than minimum.
- Parameters:
minPwm – Minimum PWM
maxPwm – Maximum PWM
- setPosition(value: SupportsFloat | SupportsIndex) None
Set the servo position.
Servo values range from 0.0 to 1.0 corresponding to the range of full left to full right.
- Parameters:
value – Position from 0.0 to 1.0.
- setPulseWidth(pulseWidth: wpimath.units.microseconds) None
Sets the raw pulse width output on the servo.
- Parameters:
pulseWidth – Pulse width
- setReversed(reversed: bool) None
Sets whether the servo is reversed.
This will reverse both SetPosition() and SetAngle().
- Parameters:
reversed – True to reverse, false for normal