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
controller = PIDController(1, 0, 0)
# setInputRange and setContinuous are now a single method
controller.enableContinuousInput(0, 360)
controller.setSetpoint(180)
# elsewhere...
# assume gyro is a gyro object created prior
output = controller.calculate(gyro.getAngle())
# do something with the output, for example:
motor.set(output)
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.
Metadata
Release files for wpilib-controller 0.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wpilib-controller-0.7.1.tar.gz | 10.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wpilib_controller-0.7.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.8 kB
Release files / wpilib-controller-0.7.1.tar.gz
| Download URL | wpilib-controller-0.7.1.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cfdb9ed0b99efe22999db7b9c334b6a68e6886f3b336de3d078d41be0c503d3e
|
|
BLAKE2b-256 checksum How to use checksums |
2a2e6a8b8c538072460743a5d0ba3b5e7923c4065954b23065daaf92a5887723
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.22.0
|
Release files / wpilib_controller-0.7.1-py3-none-any.whl
| Download URL | wpilib_controller-0.7.1-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ffbc0085dd5c3151177c8479e354e1af8bb67f9e159ccec39b9f8f6e3d4d05fa
|
|
BLAKE2b-256 checksum How to use checksums |
2dd8ab30f4030a7e7e4c774f051a76317cbfc0939c49323696056a31de62a5fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.22.0
|