A backport of the upcoming (in 2020) WPILib PIDController.
Project description
wpilib-controller
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).
Installation
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
Example
from wpilib_controller import PIDController
# assume gyro is a gyro object created prior
controller = PIDController(1, 0, 0, measurement_source=gyro.getAngle)
controller.setInputRange(0, 360)
controller.setContinuous()
# setSetpoint is now called setReference
controller.setReference(180)
# elsewhere...
output = controller.update()
# do something with the output, for example:
motor.set(output)
Major differences
- The PID gains are no longer time dependent.
- This does not distinguish between displacement and rate “PID source types”. Instead this PIDController takes a function as its measurement source.
- The feedforward is calculated by a function passed into the PIDController.
- This provides a simple way of running a PID controller synchronously in your robot code (as opposed to having it run in a thread). Simply call the
update()
method which will give you the controller output.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wpilib-controller-0.5.tar.gz
(9.5 kB
view hashes)
Built Distribution
Close
Hashes for wpilib_controller-0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7da4f9b0bed06c289ed59a6fc9e2896f3e1f170aef6642092f724805e28f5fb |
|
MD5 | fbf412fcc1d90b325bb2d29000ad9990 |
|
BLAKE2b-256 | 141be821d3589c5b5c1ab43c69c1abd91d4f65f1b1932c901fa51cecc9d1bbd9 |