Servo

class wpilib.Servo(channel)[source]

Bases: wpilib.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.

Constructor.

  • By default kDefaultMaxServoPWM ms is used as the maxPWM value
  • By default kDefaultMinServoPWM ms is used as the minPWM value
Parameters:channel (int) – The PWM channel to which the servo is attached. 0-9 are on-board, 10-19 are on the MXP port.
get()[source]

Get the servo position.

Servo values range from 0.0 to 1.0 corresponding to the range of full left to full right.

Returns:Position from 0.0 to 1.0.
Return type:float
getAngle()[source]

Get the servo angle.

Assume that the servo angle is linear with respect to the PWM value (big assumption, need to test).

Returns:The angle in degrees to which the servo is set.
Return type:float
getServoAngleRange()[source]
kDefaultMaxServoPWM = 2.4
kDefaultMinServoPWM = 0.6
kMaxServoAngle = 180.0
kMinServoAngle = 0.0
set(value)[source]

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 (float) – Position from 0.0 to 1.0.
setAngle(degrees)[source]

Set the servo angle.

Assumes that the servo angle is linear with respect to the PWM value (big assumption, need to test).

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:degrees (float) – The angle in degrees to set the servo.