robotpy / robotpy-wpilib

Moved to https://github.com/robotpy/mostrobotpy
https://robotpy.github.io
Other
169 stars 59 forks source link

[BUG]: makeCompressor crashes #706

Closed virtuald closed 10 months ago

virtuald commented 2 years ago

Problem description

See example code

Operating System

Windows, Linux

Installed Python Packages

No response

Reproducible example code

#!/usr/bin/env python3

from commands2 import TimedCommandRobot

from wpilib._impl.main import run

from wpilib import PneumaticHub
class Robot(TimedCommandRobot):
    """Implements a Command Based robot design"""

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

        self.pneumaticsHub = PneumaticHub()

        self.compressor = self.pneumaticsHub.makeCompressor()

    def teleopInit(self):
        pass

    def autonomousInit(self):
        pass

if __name__ == "__main__":
    run(Robot)
virtuald commented 2 years ago

This is a bug in WPILib (https://github.com/wpilibsuite/allwpilib/issues/4067).

As a workaround, you can create a compressor object directly:

self.compressor = wpilib.Compressor(0, wpilib.PneumaticsModuleType.CTREPCM)