A few questions about 2020 libraries

I am wondering if PIDBase and PIDController classes are implemented yet in robotpy 2020. I tried to use them, but get errors. In addition, I am having the same problem with the ShuffleBoard libraries.

Traceback (most recent call last):
  File "robot.py", line 5, in <module>
    from wpilib import PIDBase
ImportError: cannot import name 'PIDBase' from 'wpilib' (C:\Users\...\AppData\Local\Programs\Python\Python38\lib\site-packages\wpilib\__init__.py) 

Here are my installed versions…

Package                  Version
------------------------ ----------
astroid                  2.3.3
atomicwrites             1.3.0
attrs                    19.3.0
bcrypt                   3.1.7
cffi                     1.13.2
colorama                 0.4.3
cryptography             2.8
isort                    4.3.21
lazy-object-proxy        1.4.3
mccabe                   0.6.1
more-itertools           8.0.2
packaging                19.2
paramiko                 2.7.1
Pint                     0.9
pip                      20.0.2
pluggy                   0.13.1
py                       1.8.0
pycparser                2.19
pyfrc                    2020.0.2
pygame                   1.9.6
pylint                   2.4.4
PyNaCl                   1.3.0
pynetconsole             2.0.2
pynetworktables          2020.0.1
pyntcore                 2020.2.2.0
pyparsing                2.4.5
pytest                   5.3.2
robotpy-hal              2020.2.2.0
robotpy-halsim-gui       2020.2.2.0
robotpy-installer        2020.0.2
robotpy-navx             2020.1.0
robotpy-rev              2020.1.0
robotpy-rev-color        2020.1.0
robotpy-wpilib-utilities 2020.1.0
robotpy-wpiutil          2020.2.2.0
setuptools               41.2.0
six                      1.13.0
wcwidth                  0.1.7
wpilib                   2020.2.2.3
wrapt                    1.11.2

Has anyone got the Wpilib PID working? We were going to look into kinematics, but I wanted the team to understand PID first.


~Mr. R^2

Shuffleboard is a bit technically challenging, so we haven’t gotten around to it quite yet.

You’re not the first person to ask about old PIDController either. We initially only wrapped the new PIDController, but we need to wrap old PIDController for the old command framework too. I would personally recommend using the new PIDController though.

1 Like

Thank you. I totally understand, and this helps significantly. Can anyone point me to the docs for the new PID Controller?
The latest robotpy docs seem to point to the old one which is why I got confused.

The WPILibC docs will be your best bet at this point: https://first.wpi.edu/FRC/roborio/release/docs/cpp/classfrc2_1_1PIDController.html

Documentation will eventually be addressed, but nobody else has done it yet, and I’m still working on wrapping stuff.

1 Like

Is there any new links that are relevant to having the same problem as the original poster, except in Java, or is the link already referenced earlier still relevant for Java?

I can navigate the C++ and Java Docs without issue, but the imports were confusing me. However, I found this page…
And the controller section is helpful.

The import statement seems to be…
from wpilib.controller import PIDController
…but, I am still receiving the same error.
Does anyone have any thoughts? I will try in sim later and post if I figure anything out.

While I have to parse the docs to figure out how to use it, I ran the following command in terminal, and got the import to work.

       >>>from wpilib import controller

This was illuminating. I will post the full doc below in case anyone wants to see it here, but the import is a bit odd which is why we did not figure it out.
from wpilib.controller. import PIDController << I just edited this to work with version 2020.2.2.3 of wpilib.
Works. :smile_cat:
Now, I need to read through the docs to implement it, but I did verify that at least in sim, the import statement is working…

I cannot post the full doc because it is too long, but I will link to a Google Doc where I pasted it.

Good luck.
~Mr. R^2

Which version of wpilib do you have installed? On 2020.2.2.3, from wpilib.controller import PIDController should work.

1 Like

I just tried upgrading, and pip does not find anything newer than 2020.2.2.0. That was what I tried first.

What are you running to upgrade? https://pypi.org/project/wpilib/#files lists the appropriate releases.

py -m pip install -U wpilib should do it?

Thank you. I was running…
py -m pip install pyfrc
Then looking at older packages and updating them manually. wpilib itself was stuck at 2020.2.2.0 until I just uninstalled wpilib and reinstalled as you suggested.

Edit: After updating, the direct import worked. Thank you.

Recent versions of pip are happy to not upgrade your packages if you already have something installed and don’t explicitly ask it to, so you should do pip install -U whatever if you’re trying to upgrade.

1 Like

Yes, that his been annoying recently. Thanks. I will do that from now on…

I did have docs for my PIDController backport, if staring at the C++ docs is too confusing. I have no idea how up-to-date it is though. https://robotpy-wpilib-controller.readthedocs.io/en/latest/api.html

1 Like