Servo

class wpilib.Servo(channel: int)

Bases: PWM

Standard hobby style servo.

The range parameters default to the appropriate values for the Hitec HS-322HD servo provided in the FIRST Kit of Parts in 2008.

Parameters:

channel – The PWM channel to which the servo is attached. 0-9 are on-board, 10-19 are on the MXP port

get() float

Get the servo position.

Servo values range from 0.0 to 1.0 corresponding to the range of full left to full right. This returns the commanded position, not the position that the servo is actually at, as the servo does not report its own position.

Returns:

Position from 0.0 to 1.0.

getAngle() float

Get the servo angle.

This returns the commanded angle, not the angle that the servo is actually at, as the servo does not report its own angle.

Returns:

The angle in degrees to which the servo is set.

getMaxAngle() float

Get the maximum angle of the servo.

Returns:

The maximum angle of the servo in degrees.

getMinAngle() float

Get the minimum angle of the servo.

Returns:

The minimum angle of the servo in degrees.

initSendable(builder: wpiutil._wpiutil.SendableBuilder) None
set(value: float) 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.

setAngle(angle: float) None

Set the servo angle.

The angles are based on the HS-322HD Servo, and have a range of 0 to 180 degrees.

Servo angles that are out of the supported range of the servo simply “saturate” in that direction. In other words, if the servo has a range of (X degrees to Y degrees) than angles of less than X result in an angle of X being set and angles of more than Y degrees result in an angle of Y being set.

Parameters:

angle – The angle in degrees to set the servo.

setOffline() None

Set the servo to offline.

Set the servo raw value to 0 (undriven)