After deploying our robot code it errors out on startup with the message “commands2 module not found”. Commands-v2 is being copied as part of the deployment process.
Can you share a link to your code? Ideally as a github (or similar) repository
Unless you have a special deploy process, the normal robot code deploy process does not install packages on the roborio (but if you want to change that, Add package synchronization mechanism for local/remote python environment · Issue #70 · robotpy/robotpy-installer · GitHub is about fixing that!). You need to install it separately using robotpy-installer.
You can list the packages on the roborio by executing py -3 -m robotpy_installer list
, if robotpy-commands-v2 isn’t in that list, then you need to install it.
Don’t have a repository. Here’s the code that fails (robot.py)
#!/usr/bin/env python3
import typing
import wpilib
import commands2
from robotcontainer import RobotContainer
class MyRobot(commands2.TimedCommandRobot):
"""
Our default robot class, pass it to wpilib.run
Command v2 robots are encouraged to inherit from TimedCommandRobot, which
has an implementation of robotPeriodic which runs the scheduler for you
"""
autonomousCommand: typing.Optional[commands2.Command] = None
def robotInit(self) -> None:
"""
This function is run when the robot is first started up and should be used for any
initialization code.
"""
# Instantiate our RobotContainer. This will perform all our button bindings, and put our
# autonomous chooser on the dashboard.
self.container = RobotContainer()
def disabledInit(self) -> None:
"""This function is called once each time the robot enters Disabled mode."""
if self.autonomousCommand:
self.autonomousCommand.cancel()
def disabledPeriodic(self) -> None:
"""This function is called periodically when disabled"""
def autonomousInit(self) -> None:
"""This autonomous runs the autonomous command selected by your RobotContainer class."""
self.autonomousCommand = self.container.getAutonomousCommand()
if self.autonomousCommand:
self.autonomousCommand.schedule()
def autonomousPeriodic(self) -> None:
"""This function is called periodically during autonomous"""
def teleopInit(self) -> None:
# This makes sure that the autonomous stops running when
# teleop starts running. If you want the autonomous to
# continue until interrupted by another command, remove
# this line or comment it out.
if self.autonomousCommand:
self.autonomousCommand.cancel()
def teleopPeriodic(self) -> None:
"""This function is called periodically during operator control"""
def testInit(self) -> None:
# Cancels all running commands at the start of test mode
commands2.CommandScheduler.getInstance().cancelAll()
if __name__ == "__main__":
wpilib.run(MyRobot)
The command you listed requires access to the robot which I don’t have at the moment. Here’s what’s listed in the pip_cache:
09/18/2023 11:41 AM 16,401,963 numpy-1.24.2-cp311-cp311-linux_armv7l.whl
09/18/2023 11:41 AM 1,555,470 pyntcore-2023.4.3.0-cp311-cp311-linux_armv7l.whl
09/18/2023 11:41 AM 3,237 robotpy-2023.4.3.1-py3-none-any.whl
11/08/2023 11:38 AM 1,382,448 robotpy_apriltag-2023.4.3.0-cp311-cp311-linux_armv7l.whl
11/08/2023 11:38 AM 1,404,327 robotpy_commands_v2-2023.4.3.0-cp311-cp311-linux_armv7l.whl
09/18/2023 11:41 AM 7,550,627 robotpy_cscore-2023.4.3.0-cp311-cp311-linux_armv7l.whl
11/08/2023 11:38 AM 2,698,172 robotpy_ctre-2023.1.0-cp311-cp311-linux_armv7l.whl
09/18/2023 11:41 AM 1,136,984 robotpy_hal-2023.4.3.0-cp311-cp311-linux_armv7l.whl
09/18/2023 11:41 AM 370,731 robotpy_libgfortran5-12.1.0+r5-py3-none-linux_armv7l.whl
11/08/2023 11:38 AM 206,330 robotpy_navx-2023.0.3-cp311-cp311-linux_armv7l.whl
09/18/2023 11:41 AM 4,386,721 robotpy_openblas-0.3.21+r2-py3-none-linux_armv7l.whl
09/18/2023 11:41 AM 1,472,422 robotpy_opencv-4.6.0+r2-py3-none-linux_armv7l.whl
09/18/2023 11:41 AM 8,892,576 robotpy_opencv_core-4.6.0+r2-py3-none-linux_armv7l.whl
11/08/2023 11:38 AM 288,229 robotpy_pathplannerlib-2023.3.4.1-cp311-cp311-linux_armv7l.whl
11/08/2023 11:38 AM 2,396,482 robotpy_photonvision-2023.4.2-cp311-cp311-linux_armv7l.whl
11/08/2023 11:38 AM 816,667 robotpy_playingwithfusion-2023.1.0-cp311-cp311-linux_armv7l.whl
09/22/2023 05:27 PM 485,086 robotpy_rev-2023.1.3.2-cp311-cp311-linux_armv7l.whl
09/18/2023 11:41 AM 47,666 robotpy_wpilib_utilities-2023.1.0-py3-none-any.whl
09/18/2023 11:41 AM 4,752,799 robotpy_wpimath-2023.4.3.0-cp311-cp311-linux_armv7l.whl
09/18/2023 11:41 AM 650,498 robotpy_wpinet-2023.4.3.0-cp311-cp311-linux_armv7l.whl
09/18/2023 11:41 AM 1,297,553 robotpy_wpiutil-2023.4.3.0-cp311-cp311-linux_armv7l.whl
09/18/2023 11:41 AM 4,382,034 wpilib-2023.4.3.0-cp311-cp311-linux_armv7l.whl
The commands_v2 is definitely listed in the ftp output during the deploy
Ok, assuming all those modules are installed, then the actual error message + stack trace would be the most useful thing to see next.
Here’s the output when deploying the robot code:
C:\Users\tom\Desktop\FRC2024>py -3 robot.py deploy --nc
12:00:03:975 INFO : wpilib : WPILib version 2023.4.3.0
12:00:03:975 INFO : wpilib : HAL version 2023.4.3.0
12:00:03:975 INFO : wpilib : Running with simulated HAL.
12:00:03:975 INFO : wpilib : pyntcore version 2023.4.3.0
12:00:03:976 INFO : wpilib : robotpy-apriltag version 2023.4.3.0
12:00:03:976 INFO : wpilib : robotpy-commands-v2 version 2023.4.3.0
12:00:03:976 INFO : wpilib : robotpy-cscore version 2023.4.3.0
12:00:03:976 INFO : wpilib : robotpy-halsim-ds-socket version 2023.4.3.0
12:00:03:976 INFO : wpilib : robotpy-halsim-gui version 2023.4.3.0
12:00:03:977 INFO : wpilib : robotpy-halsim-ws version 2023.4.3.0
12:00:03:977 INFO : wpilib : robotpy-wpimath version 2023.4.3.0
12:00:03:977 INFO : wpilib : robotpy-wpinet version 2023.4.3.0
12:00:03:977 INFO : wpilib : robotpy-wpiutil version 2023.4.3.0
12:00:03:977 INFO : wpilib : robotpy-photonvision version 2023.4.2
12:00:03:977 INFO : wpilib : robotpy-pathplannerlib version 2023.3.4.1
12:00:03:978 INFO : wpilib : robotpy-rev version 2023.1.3.2
12:00:03:978 INFO : wpilib : robotpy-ctre version 2023.1.0
12:00:03:978 INFO : wpilib : robotpy-playingwithfusion version 2023.1.0
12:00:03:978 INFO : wpilib : robotpy-navx version 2023.0.3
12:00:03:980 INFO : robotpy.installer : -> using existing config at 'C:\Users\tom\Desktop\FRC2024\.deploy_cfg'
12:00:03:980 INFO : robotpy.installer : Finding robot for team 5878
12:00:03:999 INFO : robotpy.installer : -> Robot is at 10.58.78.2
12:00:03:999 INFO : robotpy.installer : Connecting to robot via SSH at 10.58.78.2
12:00:04:264 INFO : paramiko.transport : Connected (version 2.0, client OpenSSH_8.3)
12:00:04:442 INFO : paramiko.transport : Auth banner: b'NI Linux Real-Time (run mode)\n\nLog in with your NI-Auth credentials.\n\n'
12:00:04:443 INFO : paramiko.transport : Authentication (password) successful!
RoboRIO has WPILib version 2023.4.3.0
12:00:05:211 INFO : root : Not including git hash in deploy.json: Not a git repo.
12:00:05:289 INFO : paramiko.transport.sftp: [chan 6] Opened sftp connection (server version 3)
make /home/lvuser/py_new
constants.py -> /home/lvuser/py_new/constants.py
deploy.json -> /home/lvuser/py_new/deploy.json
frc.txt -> /home/lvuser/py_new/frc.txt
networktables.json -> /home/lvuser/py_new/networktables.json
physics.py -> /home/lvuser/py_new/physics.py
pip_cache.txt -> /home/lvuser/py_new/pip_cache.txt
robot.py -> /home/lvuser/py_new/robot.py
robotcontainer.py -> /home/lvuser/py_new/robotcontainer.py
simgui-ds.json -> /home/lvuser/py_new/simgui-ds.json
simgui-window.json -> /home/lvuser/py_new/simgui-window.json
simgui.json -> /home/lvuser/py_new/simgui.json
make /home/lvuser/py_new/commands
commands\DriveDistance.py -> /home/lvuser/py_new/commands/DriveDistance.py
commands\DriveTimed.py -> /home/lvuser/py_new/commands/DriveTimed.py
make /home/lvuser/py_new/subsystems
subsystems\drivetrain.py -> /home/lvuser/py_new/subsystems/drivetrain.py
subsystems\__init__.py -> /home/lvuser/py_new/subsystems/__init__.py
12:00:05:569 INFO : paramiko.transport.sftp: [chan 6] sftp session closed.
Connecting to 10.58.78.2:1741...OK
12:00:05:597 INFO : deploy : Netconsole is listening...
killall: lvrt: no process killed
[472.44] Traceback (most recent call last):
[472.44] File "/home/lvuser/py/robot.py", line 5, in <module>
[472.44] import commands2
[472.44] ModuleNotFoundError: No module named 'commands2'
[478.47] Traceback (most recent call last):
[478.47] File "/home/lvuser/py/robot.py", line 5, in <module>
[478.47] import commands2
[478.47] ModuleNotFoundError: No module named 'commands2'
[484.48] Traceback (most recent call last):
[484.48] File "/home/lvuser/py/robot.py", line 5, in <module>
[484.48] import commands2
[484.49] ModuleNotFoundError: No module named 'commands2'
[484.87] *** Error in `/usr/local/bin/python3': corrupted double-linked list: 0x00edf930 ***
What’s the output of robotpy-installer list
? I find it hard to believe that commands is actually installed on your robot, and there’s nothing complex about the code you’re deploying that would mess with it.
The output at the beginning of the deploy message indicates the packages that are installed on your host (not on your robot) – which, I can see how that would be confusing (and I filed a bug at User reports confusion with initial log messages. · Issue #225 · robotpy/pyfrc · GitHub so we can contemplate how to make that clearer).
Indeed, the problem was that the commands2 module wasn’t copied over. Missed the error message at the end of the copy process that said the disk was full. Perhaps it would be good if error messages could come out in different color than the slew of information messages produced by the install code.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.