Skip to main content

A backport of the upcoming (in 2020) WPILib PIDController.

Project description


A backport of the upcoming (in 2020) WPILib PIDController.

This is a backport of wpilibsuite/allwpilib#1300, which is planned to be merged for the 2020 season, for RobotPy.

@calcmogul has some in-progress docs on this.

Note that if you are moving from the old WPILib PIDController, your PID constants will need to change, as it did not consider the discretization period:

  • divide your Ki gain by 0.05, and
  • multiply your Kd gain by 0.05,
  • where 0.05 is the original default period (use the period you used otherwise).


For a computer with an internet connection:

pip install wpilib-controller

To install onto an offline roboRIO:

pip download wpilib-controller -d pip_cache  # with an internet connection
robotpy-installer install-pip wpilib-controller  # connected to your robot


from wpilib_controller import PIDController

controller = PIDController(1, 0, 0)
# setInputRange and setContinuous are now a single method
controller.enableContinuousInput(0, 360)


# elsewhere...

# assume gyro is a gyro object created prior
output = controller.calculate(gyro.getAngle())
# do something with the output, for example:

Major differences

  • The PID gains are no longer time dependent.
  • This PIDController expects a measurement as a parameter to calculate().
  • This PIDController runs synchronously in your robot code (as opposed to having it run in a thread). You must call calculate() and use its return value.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for wpilib-controller, version 0.7.1
Filename, size File type Python version Upload date Hashes
Filename, size wpilib_controller-0.7.1-py3-none-any.whl (12.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size wpilib-controller-0.7.1.tar.gz (10.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page