-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Labels
Description
Problem description
The removeDefaultCommand() function throws an error when you attempt to run it.
01:34:59:693 ERROR : your.robot : Unhandled exception
Traceback (most recent call last):
File "c:\git\2026Robot\.venv\Lib\site-packages\wpilib\_impl\start.py", line 247, in _start
self.robot.startCompetition()
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "C:\git\2026Robot\robot.py", line 10, in robotInit
system.removeDefaultCommand()
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "c:\git\2026Robot\.venv\Lib\site-packages\commands2\subsystem.py", line 78, in removeDefaultCommand
CommandScheduler.getInstance().removeDefaultCommand(self)
^^^^^^^^^^^^^^^^
NameError: name 'CommandScheduler' is not defined
After reviewing the subsystem.py source code, this could be resolved with adding the import for CommandScheduler at approximately line 78.
def removeDefaultCommand(self) -> None:
"""
Removes the default command for the subsystem. This will not cancel the default command if it
is currently running.
"""
from .commandscheduler import CommandScheduler
CommandScheduler.getInstance().removeDefaultCommand(self)
Operating System
RoboRIO, Windows
Installed Python Packages
robotpy
robotpy[commands2]
Reproducible example code
from wpilib import TimedRobot
from commands2 import Subsystem, CommandScheduler
class Robot(TimedRobot):
def robotInit(self):
CommandScheduler.getInstance().run()
system = Subsystem()
system.setDefaultCommand( system.idle().withName("DefaultCommand") )
system.removeDefaultCommand()
Reactions are currently unavailable