Skip to content

addCommands Method Creates Error #3

@benjiboy50fonz

Description

@benjiboy50fonz

Hi devs, @virtuald,

Here is the requested singular file as well as the error. My machine is running Windows 10 and has the most up to date libraries, including commands-v2 version 2021.2.2.0. Here is the traceback of my error:

Traceback (most recent call last):
  File "C:\Users\Ben Bistline\AppData\Local\Programs\Python\Python39\lib\site-packages\wpilib\_impl\start.py", line 106, in start
    self.robot.startCompetition()
  File "C:\Users\Ben Bistline\Code\RobotpyDev\one_file_robot\robot.py", line 23, in robotInit
    self.myCommand = TestCommandGroup()
  File "C:\Users\Ben Bistline\Code\RobotpyDev\one_file_robot\robot.py", line 13, in __init__
    self.addCommands( # Error located at this line.
  File "C:\Users\Ben Bistline\AppData\Local\Programs\Python\Python39\lib\site-packages\wpilib\_impl\start.py", line 106, in start
    self.robot.startCompetition()
  File "C:\Users\Ben Bistline\Code\RobotpyDev\one_file_robot\robot.py", line 23, in robotInit
    self.myCommand = TestCommandGroup()
  File "C:\Users\Ben Bistline\Code\RobotpyDev\one_file_robot\robot.py", line 13, in __init__
    self.addCommands( # Error located at this line.
RuntimeError: Unable to cast Python instance to C++ type (compile in debug mode for details)

The singular file that I used to create this issue can be found here:

#!/usr/bin/env python3

from commands2 import TimedCommandRobot, SequentialCommandGroup, WaitCommand
from wpilib._impl.main import run
from wpilib import RobotBase

import shutil, sys

class TestCommandGroup(SequentialCommandGroup):
    def __init__(self):
        super().__init__()
        
        self.addCommands( # Error located at this line.
            [WaitCommand(1)]
        )

class Robot(TimedCommandRobot):
    """Implements a Command Based robot design"""

    def robotInit(self):
        """Set up everything we need for a working robot."""
        
        self.myCommand = TestCommandGroup()

    def teleopInit(self):
        self.myCommand.schedule()
        
    def autonomousInit(self):
        pass
   
if __name__ == "__main__":
    if len(sys.argv) > 1 and sys.argv[1] == "deploy":
        shutil.rmtree("opkg_cache", ignore_errors=True)
        shutil.rmtree("pip_cache", ignore_errors=True)

    run(Robot)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions