robotpy / robotpy-commands-v2

Python implementation of the WPILib Command Framework (2020+)
Other
2 stars 14 forks source link

[BUG]: Vauge runtime error: Unable to cast Python instance to C++ type #21

Closed KenwoodFox closed 6 months ago

KenwoodFox commented 1 year ago

Problem description

This issue comes from here: https://github.com/FRC-1721/1721-ChargedUp/issues/10 and was discussed on the robotpy gitter.

When trying to execute the example code, the robot will lockup and produce this error. Not really telling you much about where it comes from.

Operating System

Linux

Installed Python Packages

Package                  Version
------------------------ ----------
pip                      22.3.1
pyntcore                 2023.2.1.0
PyYAML                   6.0
robotpy                  2023.2.1
robotpy-commands-v2      2023.2.1.0
robotpy-ctre             2023.0.0
robotpy-hal              2023.2.1.0
robotpy-rev              2023.1.2
robotpy-wpilib-utilities 2023.0.0
robotpy-wpimath          2023.2.1.0
robotpy-wpinet           2023.2.1.0
robotpy-wpiutil          2023.2.1.0
setuptools               65.5.0
wpilib                   2023.2.1.0

Reproducible example code

# Stabilize robot to drive straight with gyro (software diff lock)
        commands2.button.JoystickButton(
            self.driverController, self.driveConsts["DiffLock"]
        ).whileTrue(
            commands2.PIDCommand(
                wpimath.controller.PIDController(
                    self.pidConsts["drive"]["kStabilizationP"],
                    self.pidConsts["drive"]["kStabilizationI"],
                    self.pidConsts["drive"]["kStabilizationD"],
                ),
                # Close the loop on the turn rate
                self.robotDrive.getTurnRate,
                # Setpoint is 0xxx
                0,
                # Pipe the output to the turning controls
                lambda output: self.robotDrive.arcadeDrive(
                    -self.driverController.getLeftY(), output
                ),
                # Require the robot drive
                [self.robotDrive],
            )
        )

Or here: https://github.com/robotpy/examples/blob/ef7372a3ce4bcc73cd6d868922e67dd6e7a99805/commands-v2/gyro-drive-commands/robotcontainer.py#L74-L94

virtuald commented 6 months ago

OBE because of migration to pure python command framework.