Want to use RobotPy with an XRP robot but having difficulty setting things up. In particular need to reference the XRPMotor class but that class is apparently not in wpilib. Where is it or is it accessible at all?
I don’t really know how XRP works, but my guess is that it’s like the ROMI. See the documentation at the top of the example here for setting the host/port and for how to enable the websocket client: examples/RomiReference/robot.py at main · robotpy/examples · GitHub
Should make this easier to do, filed an issue at github: Add XRP/ROMI support to pyproject.toml · Issue #71 · robotpy/mostrobotpy · GitHub
Got the package robotpy-xrp installed and that resolved all the missing references. Now trying to run the code using
py -3 -m robotpy sim
Get the following messages:
The procedure entry point could not be located in the dynamic link library C:\Users\tom\AppData\Roaming\Python\Python311\site-packages\xrp\lib\xrpVendordep.dll
Windows fatal exception: code 0xc0000139
Current thread 0x00005aac (most recent call first):
File “C:\Program Files\Python311\Lib\ctypes_init_.py”, line 376 in init
File “C:\Program Files\Python311\Lib\ctypes_init_.py”, line 454 in LoadLibrary
File “C:\Users\tom\AppData\Roaming\Python\Python311\site-packages\xrp_init_xrp.py”, line 19 in
File “”, line 241 in _call_with_frames_removed
File “”, line 940 in exec_module
File “”, line 690 in _load_unlocked
File “”, line 1147 in _find_and_load_unlocked
File “”, line 1176 in _find_and_load
File “”, line 241 in _call_with_frames_removed
File “”, line 1232 in handle_fromlist
File "C:\Users\tom\AppData\Roaming\Python\Python311\site-packages\xrp_init.py", line 1 in
File “”, line 241 in _call_with_frames_removed
File “”, line 940 in exec_module
File “”, line 690 in _load_unlocked
File “”, line 1147 in _find_and_load_unlocked
File “”, line 1176 in _find_and_load
File “C:\Users\tom\Desktop\XRP\FRC2024\subsystems\drivetrain.py”, line 7 in
File “”, line 241 in _call_with_frames_removed
File “”, line 940 in exec_module
File “”, line 690 in _load_unlocked
File “”, line 1147 in _find_and_load_unlocked
File “”, line 1176 in _find_and_load
File “C:\Users\tom\Desktop\XRP\FRC2024\robotcontainer.py”, line 6 in
File “”, line 241 in _call_with_frames_removed
File “”, line 940 in exec_module
File “”, line 690 in _load_unlocked
File “”, line 1147 in _find_and_load_unlocked
File “”, line 1176 in _find_and_load
File “C:\Users\tom\Desktop\XRP\FRC2024\robot.py”, line 8 in
File “”, line 241 in _call_with_frames_removed
File “”, line 940 in exec_module
File “C:\Users\tom\AppData\Roaming\Python\Python311\site-packages\robotpy\main.py”, line 68 in load_robot_class
File “C:\Users\tom\AppData\Roaming\Python\Python311\site-packages\robotpy\main.py”, line 296 in main
File "C:\Users\tom\AppData\Roaming\Python\Python311\site-packages\robotpy_main.py", line 4 in
File “”, line 88 in _run_code
File “”, line 198 in _run_module_as_main
ERROR: importing C:\Users\tom\Desktop\XRP\FRC2024\robot.py failed!
Traceback (most recent call last):
File “C:\Users\tom\AppData\Roaming\Python\Python311\site-packages\robotpy\main.py”, line 68, in _load_robot_class
spec.loader.exec_module(module)
File “”, line 940, in exec_module
File “”, line 241, in call_with_frames_removed
File “C:\Users\tom\Desktop\XRP\FRC2024\robot.py”, line 8, in
from robotcontainer import RobotContainer
File “C:\Users\tom\Desktop\XRP\FRC2024\robotcontainer.py”, line 6, in
from subsystems.drivetrain import Drivetrain
File “C:\Users\tom\Desktop\XRP\FRC2024\subsystems\drivetrain.py”, line 7, in
import xrp
File "C:\Users\tom\AppData\Roaming\Python\Python311\site-packages\xrp_init.py", line 1, in
from . import _init_xrp
File “C:\Users\tom\AppData\Roaming\Python\Python311\site-packages\xrp_init_xrp.py”, line 19, in
_lib = cdll.LoadLibrary(join(root, “lib”, “xrpVendordep.dll”))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\ctypes_init.py", line 454, in LoadLibrary
return self.dlltype(name)
^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\ctypes_init.py", line 376, in init
self._handle = _dlopen(self._name, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 127] The specified procedure could not be found
I’m not able to duplicate that error. I did the following:
py -c "import xrp"
Without an error. What happens when you run that? Same thing?
Have you upgraded to the latest version of RobotPy? What’s the output of py -m pip list
?
If everything is up to date, you might not have the correct version of the Visual Studio runtime installed? See Latest supported Visual C++ Redistributable downloads | Microsoft Learn to download the latest for VS 2022.
Output from py -c “import xrp” command:
C:\Users\tom\Desktop\XRP\FRC2024>py -c “import xrp”
Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\tom\AppData\Roaming\Python\Python311\site-packages\xrp_init_.py”, line 1, in
from . import _init_xrp
File “C:\Users\tom\AppData\Roaming\Python\Python311\site-packages\xrp_init_xrp.py”, line 19, in
_lib = cdll.LoadLibrary(join(root, “lib”, “xrpVendordep.dll”))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\ctypes_init.py", line 454, in LoadLibrary
return self.dlltype(name)
^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\ctypes_init.py", line 376, in init
self._handle = _dlopen(self._name, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 127] The specified procedure could not be found
Output from py -m pip list:
C:\Users\tom\Desktop\XRP\FRC2024>py -m pip list
Package Version
absl-py 2.0.0
astunparse 1.6.3
bcrypt 4.0.1
cachetools 5.3.2
certifi 2023.11.17
cffi 1.15.1
charset-normalizer 3.3.2
click 8.1.7
colorama 0.4.6
contourpy 1.2.0
cryptography 41.0.4
cycler 0.12.1
dm-tree 0.1.8
flatbuffers 23.5.26
fonttools 4.44.1
gast 0.5.4
google-auth 2.23.4
google-auth-oauthlib 1.1.0
google-pasta 0.2.0
grpcio 1.59.3
h5py 3.10.0
idna 3.6
iniconfig 2.0.0
joblib 1.3.2
keras 2.15.0
kiwisolver 1.4.5
libclang 16.0.6
Markdown 3.5.1
markdown-it-py 3.0.0
MarkupSafe 2.1.3
matplotlib 3.8.1
mdurl 0.1.2
ml-dtypes 0.2.0
namex 0.0.7
numpy 1.26.2
oauthlib 3.2.2
opencv-python 4.8.1.78
opt-einsum 3.3.0
packaging 23.1
pandas 2.1.3
paramiko 3.3.1
Pillow 10.1.0
Pint 0.22
pip 23.3.2
pluggy 1.3.0
protobuf 4.23.4
pyasn1 0.5.1
pyasn1-modules 0.3.0
pycparser 2.21
pyfrc 2023.0.1
Pygments 2.17.2
PyNaCl 1.5.0
pynetconsole 2.0.4
pyntcore 2023.4.3.0
pyparsing 3.1.1
pytest 7.4.2
pytest-reraise 2.1.2
python-dateutil 2.8.2
pytz 2023.3.post1
requests 2.31.0
requests-oauthlib 1.3.1
rich 13.7.0
robotpy 2023.4.3.1
robotpy-apriltag 2023.4.3.0
robotpy-cli 2024.0.0
robotpy-commands-v2 2023.4.3.0
robotpy-cscore 2023.4.3.0
robotpy-ctre 2023.1.0
robotpy-hal 2023.4.3.0
robotpy-halsim-ds-socket 2023.4.3.0
robotpy-halsim-gui 2023.4.3.0
robotpy-halsim-ws 2023.4.3.0
robotpy-installer 2023.0.3
robotpy-navx 2023.0.3
robotpy-pathplannerlib 2023.3.4.1
robotpy-photonvision 2023.4.2
robotpy-playingwithfusion 2023.1.0
robotpy-rev 2023.1.3.2
robotpy-wpilib-utilities 2023.1.0
robotpy-wpimath 2023.4.3.0
robotpy-wpinet 2023.4.3.0
robotpy-wpiutil 2023.4.3.0
robotpy-xrp 2024.2.1.2
rsa 4.9
scikit-learn 1.3.2
scipy 1.11.4
setuptools 65.5.0
six 1.16.0
tensorboard 2.15.1
tensorboard-data-server 0.7.2
tensorflow 2.15.0
tensorflow-estimator 2.15.0
tensorflow-intel 2.15.0
tensorflow-io-gcs-filesystem 0.31.0
termcolor 2.3.0
threadpoolctl 3.2.0
typing_extensions 4.8.0
tzdata 2023.3
urllib3 2.1.0
Werkzeug 3.0.1
wheel 0.42.0
wpilib 2023.4.3.0
wrapt 1.14.1
The latest version of Visual Studio 2022 Community Edition is installed. Also WPILib-2024.2.1.
It looks like you have a lot of old robotpy stuff installed – all of the robotpy packages are ‘2023’. Recommend you do a pip install -U robotpy[xrp]
to upgrade and try again.
It appears I have all the version issues resolved. Now I want to actually run the XRP robot which works via the simulation interface. However I have a new problem. Running the command python robot.py sim produces an error message that says run the command py -m robotpy [arguments]. I interpret that to mean run the command py -m robotpy sim. But that command generates the error message No module named robotpy.main; robotpy is a package and cannot be directly executed. Now what?
We updated the installation docs recently because people keep running into this:
If you previously installed a pre-2024 or 2024 beta version of RobotPy, you should first uninstall RobotPy via
py -m pip uninstall robotpy
before upgrading.
There’s an esoteric bug in pip when updating packages that causes the error with __main__
. If you uninstall the robotpy and robotpy-cli package and then install it again, it’ll work.
This solves that problem. The simulator now comes up. However there is no connection to the XRP. Robot.py code contains the following two lines:
os.environ[“HALSIMWS_HOST”] = “192.168.42.1”
os.environ[“HALSIMWS_PORT”] = “5000”
And the XRP does respond to those parameters in the browser. What’s missing now?
Well I was right that I didn’t know how XRP works.
I went looking at the XRP docs and it appears there’s a special simulation extension needed for XRP (so it’s not exactly like the ROMI), which we don’t currently package for RobotPy. I can do it tonight after work.
Once I update the xrp package, you would need to set HALSIMXRP_HOST
and HALSIMXRP_PORT
.
Once robotpy-xrp 2024.2.1.3 is available (build running here), it should have the simulation extension available… maybe 2 hours or so.
You would need to add the environment variables above, and then py -m robotpy sim --xrp
to run it with the extension. I don’t have XRP hardware so I can’t verify that it actually works, but it printed out the following so it likely works?
HAL Extensions: Attempting to load: libhalsim_xrp
HALSim XRP Extension Initializing
HALSimXRP Initialized
HALSim XRP Extension Initialized
HAL Extensions: Successfully loaded extension
I have installed the updates and run the simulation but the XRP is not responding. Here is the output displayed when running the code:
C:\Users\tom\Desktop\XRP\FRC2024>py -3 -m robotpy sim --xrp
21:06:25:201 INFO : halsim_gui : WPILib HAL Simulation 2024.2.1.2
HAL Extensions: Attempting to load: halsim_gui
Simulator GUI Initializing.
Simulator GUI Initialized!
HAL Extensions: Successfully loaded extension
21:06:25:269 INFO : xrp.extension : WPILib XRP client 2024.2.1.3
HAL Extensions: Attempting to load: halsim_xrp
HALSim XRP Extension Initializing
HALSimXRP Initialized
HALSim XRP Extension Initialized
HAL Extensions: Successfully loaded extension
21:06:25:273 WARNING : pyfrc.physics : Cannot enable physics support, C:\Users\tom\Desktop\XRP\FRC2024\physics.py not found
21:06:25:274 INFO : wpilib : RobotPy version 2024.2.1.1
21:06:25:274 INFO : wpilib : WPILib version 2024.2.1.3
21:06:25:274 INFO : wpilib : Running with simulated HAL.
21:06:25:276 INFO : nt : Listening on NT3 port 1735, NT4 port 5810
Not loading CameraServerShared
ArcadeDrive Init
********** Robot program startup complete **********
Default frc::IterativeRobotBase::RobotPeriodic() method... Override me!
Default frc::IterativeRobotBase::SimulationPeriodic() method... Override me!
Additionally, I do know that the XRP works since I have a java XRP program that works fine.
And your code set those environment variables? Apparently the port needs to be 3540.
It all works! Had to change the environment variables from HALSIMWS_HOST and HALSIMWS_PORT to HALSIMXRP_HOST and HALSIMXRP_PORT and port number from 5000 to 3540.
Thanks for all your help.
Awesome. Hopefully we can get an example translated to python and posted in our example repo so the next person doesn’t have to go through this.
Here’s my code. Do with what you will.
FRC2024.zip (24.7 KB)
Does the FRC2024.zip run on XRP hardware?
Yes, it does.