Lots of progress with robotpy 2020, thank you all for your hard work!
I ported our team’s 2019 robotpy code to the 2020 release. I’m in a windows conda 3.8 env I made just for robotpy, and other than ipython I installed only the following:
pip install -U pyfrc --pre
pip install -U robotpy-commands-v1 robotpy-ctre robotpy-navx robotpy-rev robotpy-rev-color
which after a pip list currently gives me the following relevant packages:
pyfrc 2020.0.0
pynetworktables 2020.0.1
pyntcore 2020.1.2.2
robotpy-commands-v1 2020.1.2.2
robotpy-ctre 2020.0.1
robotpy-hal 2020.1.2.3
robotpy-halsim-gui 2020.1.2.2
robotpy-installer 2020.0.2
robotpy-navx 2020.0.1
robotpy-rev 2020.0.0
robotpy-rev-color 2020.0.1
robotpy-wpilib-utilities 2020.0.2
robotpy-wpiutil 2020.1.2.2
wpilib 2020.1.2.3
I can get the sim window up, I can deploy to the rio, and I can send data back from the spark max controllers, get data from the color sensor and the navx. Every number shows up fine on shuffleboard via putNumber. That’s all good, indicating that the old subsystems work fine. Most of my problems were in figuring out when to import commands, subsystems and buttons from wpilib.command, which basically involved changing a lot of wpilb imports to wpilib.command imports. All of my v1 commands work when called from standard JoystickButton bindings to commands_v1.
However, at the moment I have two problems:
- I can’t send a command to the SmartDashboard with putData. I’d like to still be able to call commands from the shuffleboard. Not sure the reason, if it is a v1 vs v2 thing but I would think both versions would be sendable. Trying a putData with a command that otherwise works on a joystick button causes “Windows fatal exception: access violation” in a way that is not easy for me to trace (on the sim this happens with or without the joystick plugged in, similarly on the rio):
(robo2020) cjh@mingw64robot$ python robot.py sim
11:04:17:588 INFO : wpilib : WPILib version 2020.1.2.3
11:04:17:588 INFO : wpilib : HAL version 2020.1.2.2
11:04:17:589 WARNING : wpilib : Core component versions are not identical! This is not a supported configuration, and you may run into errors!
11:04:17:589 INFO : wpilib : Running with simulated HAL.
11:04:17:590 INFO : halsim_gui : WPILib HAL Simulation 2020.1.2.2
HAL Extensions: Attempting to load: halsim_gui
Simulator GUI Initializing.
Simulator GUI Initialized!
HAL Extensions: Successfully loaded extension
Not loading CameraServerShared
Instantiating navX-Sensor on SPI Port 4.
Joystick Button missing, check if all controllers are plugged in
Default frc::IterativeRobotBase::RobotPeriodic() method… Override me!
Windows fatal exception: access violation
Current thread 0x000074a4 (most recent call first):
File “C:\Users\cjh\AppData\Local\Continuum\miniconda3\envs\robo2020\lib\site-packages\commandbased\commandbasedrobot.py”, line 15 in startCompetition
File “C:\Users\cjh\AppData\Local\Continuum\miniconda3\envs\robo2020\lib\site-packages\wpilib_impl\start.py”, line 94 in start
File “C:\Users\cjh\AppData\Local\Continuum\miniconda3\envs\robo2020\lib\site-packages\wpilib_impl\start.py”, line 31 in _start
File “C:\Users\cjh\AppData\Local\Continuum\miniconda3\envs\robo2020\lib\threading.py”, line 870 in run
File “C:\Users\cjh\AppData\Local\Continuum\miniconda3\envs\robo2020\lib\threading.py”, line 932 in _bootstrap_inner
File “C:\Users\cjh\AppData\Local\Continuum\miniconda3\envs\robo2020\lib\threading.py”, line 890 in _bootstrap
Thread 0x000036f0 (most recent call first):
File “C:\Users\cjh\AppData\Local\Continuum\miniconda3\envs\robo2020\lib\site-packages\wpilib_impl\start.py”, line 37 in run
File “C:\Users\cjh\AppData\Local\Continuum\miniconda3\envs\robo2020\lib\site-packages\halsim_gui\main.py”, line 34 in run
File “C:\Users\cjh\AppData\Local\Continuum\miniconda3\envs\robo2020\lib\site-packages\wpilib_impl\main.py”, line 186 in run
File “robot.py”, line 96 in
Watchdog not fed within 0.020000s
Loop (robo2020) cjh@mingw64robot$
- Trying to bind commands to our custom triggers (fairly standard axis buttons and POV buttons) also kill the sim. I switched to the built-in commands_v1 POVButton and was fine, but still not sure why ours dies, but my only insight is that they both die. I don’t have a ready solution for triggering on the right and left logitech button-axes as a button, so if an alternative is known please let me know. Our axis button code looks like this:
from wpilib.command import Button
class AxisButton(Button):
“”"
A custom button that is used when pretending an axis button is digital.
“”"
def __init__(self, joystick, axis):
self.joystick = joystick
self.axis = axis
self.threshold = 0.03
def get(self):
return self.joystick.getRawAxis(self.axis) > self.threshold
And trying to bind one of these dies in the exact same way as the putData.
It’s pretty fluid right now (forgive the mess, everything is in testing phase at the moment), but the oi code is at GitHub - aesatchien/FRC2429_2020 at robo2020
Any thoughts?
Thanks!