Ejemplo n.º 1
0
class HatchLatch(Subsystem, metaclass=singleton.Singleton):
    """The HatchLatch subsystem controls the latch which grabs hatch panels
    and encoders."""

    def __init__(self):
        super().__init__()
        self.servo = Servo(0)

    def setOpen(self):
        """Open the hatch latch."""
        self.servo.setAngle(Constants.HATCH_LATCH_OPENED)

    def setClosed(self):
        """Close the hatch latch."""
        self.servo.setAngle(Constants.HATCH_LATCH_CLOSED)

    def setToggle(self):
        """Toggle the hatch latch between open and closed
           (if it is not in either state, it will be closed)."""
        if self.servo.getAngle() == Constants.HATCH_LATCH_CLOSED:
            self.setOpen()
        elif self.servo.getAngle() == Constants.HATCH_LATCH_OPENED:
            self.setClosed()
        else:
            self.setClosed()

    def outputToSmartDashboard(self):
        Dash.putNumber("Servo Angle", self.servo.getAngle())
Ejemplo n.º 2
0
class Peripherals(Subsystem):
    def __init__(self, robot):
        super().__init__()
        self.intake_spark = Spark(6)
        self.control_panel_spark = Spark(5)
        self.left_dispenser_gate = Servo(7)
        self.right_dispenser_gate = Servo(8)

    def run_intake(self, power=0):
        self.intake_spark.set(power)

    def run_spinner(self, power=0):
        self.control_panel_spark.set(power)

    def close_gate(self):
        self.left_dispenser_gate.setAngle(120)
        self.right_dispenser_gate.setAngle(135)

    def open_gate(self):
        self.left_dispenser_gate.setAngle(0)
        self.right_dispenser_gate.setAngle(0)

    def panel_clockwise(self, power):
        print(power)
        self.control_panel_spark.set(power)



    def log(self):
        pass
Ejemplo n.º 3
0
class HatchLatch(Subsystem, metaclass=singleton.Singleton):
    """The HatchLatch subsystem controls the latch which grabs hatch panels
    and encoders."""
    def __init__(self):
        super().__init__()
        self.servo = Servo(0)

    def setOpen(self):
        """Open the hatch latch."""
        self.servo.setAngle(Constants.HATCH_LATCH_OPENED)

    def setClosed(self):
        """Close the hatch latch."""
        self.servo.setAngle(Constants.HATCH_LATCH_CLOSED)

    def setToggle(self):
        """Toggle the hatch latch between open and closed
           (if it is not in either state, it will be closed)."""
        if self.servo.getAngle() == Constants.HATCH_LATCH_CLOSED:
            self.setOpen()
        elif self.servo.getAngle() == Constants.HATCH_LATCH_OPENED:
            self.setClosed()
        else:
            self.setClosed()

    def outputToDashboard(self):
        Dash.putNumber("Servo Angle", self.servo.getAngle())

    def periodic(self):
        self.outputToDashboard()

    def controlHatch(self):
        """ Checks each trigger and opens and closes depending on the trigger pressed."""
        if oi.OI.operator_buttons[6].whenPressed():
            self.setOpen()
        elif oi.OI.operator_buttons[5].whenPressed():
            self.setClosed()