Closed picode98 closed 4 years ago
I'll take a look in a bit.
I don't have it set up to run on this laptop, but my guess is that you need to implement all of the virtual functions for every command. Prior versions of RobotPy didn't make you do this, so we can fix it at some point, but this would get you going for now.
Anything on this that says 'virtual' and =0... looks like only isFinished needs to be implemented. https://first.wpi.edu/FRC/roborio/release/docs/cpp/classfrc_1_1Command.html
I tried adding the following definitions to all command classes (drive_immediate.py
, drive_reserve.py
):
def _isFinished(self):
return False
def IsFinished(self):
return False
def isCompleted(self):
return False
The crash still occurs with all of these definitions present in both classes. Is there some other function that should be implemented?
There are two issues.
One, you need to override the _isFinished
function. We need to provide either a better error message or a default implementation like we did previously. I'm open to suggestions?
The other is that when we pass in commands to the scheduler, it doesn't retain a reference to them. Store them somewhere first, then pass it to the scheduler. We will fix this, but maybe not until later today.
robotpy-commands-v1 2020.1.2.1 fixes the reference issue, and gives a mildly better error message when you forget to override something.
I can confirm that this release fixes the issue; I appreciate the help. However, I also had to rename execute
to _execute
in both commands in order for these functions to be executed. This leads me to wonder which set of naming conventions are in use, as help(wpilib.command.Command)
does not list either _isFinished
or _execute
as members.
>>> import pprint
>>> pprint.pprint(dir(wpilib.command.Command))
['__Cancel',
'__End',
'__Execute',
'__Initialize',
'__Interrupted',
'__class__',
'__delattr__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__le__',
'__lt__',
'__module__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'_assertUnlocked',
'_clearRequirements',
'_end',
'_execute',
'_initialize',
'_interrupted',
'_isFinished',
'_isParented',
'_isTimedOut',
'_m_error',
'_setParent',
'_setTimeout',
'cancel',
'clearError',
'clearGlobalErrors',
'cloneError',
'doesRequire',
'getError',
'getGlobalError',
'getGlobalErrors',
'getGroup',
'getID',
'getName',
'getRequirements',
'getSubsystem',
'initSendable',
'isCanceled',
'isCompleted',
'isInitialized',
'isInterruptible',
'isRunning',
'requires',
'run',
'setErrnoError',
'setError',
'setErrorRange',
'setGlobalError',
'setGlobalWPIError',
'setImaqError',
'setInterruptible',
'setName',
'setRunWhenDisabled',
'setSubsystem',
'setWPIError',
'start',
'statusIsFatal',
'timeSinceInitialized',
'willRunWhenDisabled']
.. basically, anything that is 'protected' in C++ automatically gets an underscore before it, and anything with an underscore is automatically excluded from help. We should probably figure out the right way to deal with that.
I tried running some existing pre-season code, and found that it crashes when I attempt to enter Teleop mode. Full output is as follows:
Packages installed (
pip list
):