diff --git a/components/intake.py b/components/intake.py new file mode 100644 index 0000000..fffa48c --- /dev/null +++ b/components/intake.py @@ -0,0 +1,23 @@ +import magicbot +from phoenix6.hardware import TalonFX +from phoenix6.configs.talon_fx_configs import TalonFXConfiguration +from phoenix6.signals import NeutralModeValue +from phoenix6.controls import VoltageOut +from wpimath import units + + +class Intake: + motor: TalonFX + voltage = magicbot.will_reset_to(0.0) + + def execute(self): + motor_control = VoltageOut(self.voltage) + self.motor.set_control(motor_control)S + + def setup(self): + config = TalonFXConfiguration() + config.motor_output.neutral_mode = NeutralModeValue.BRAKE + self.motor.configurator.apply(config) + + def set_voltage(self, voltage: units.volts): + self.voltage = voltage \ No newline at end of file diff --git a/components/pigeon.py b/components/pigeon.py new file mode 100644 index 0000000..1a5ee56 --- /dev/null +++ b/components/pigeon.py @@ -0,0 +1,33 @@ +import math +from phoenix6.hardware.pigeon2 import Pigeon2 + +class Pigeon: + + gyro: Pigeon2 + + def setup(self): + self.gyro.reset() + + def execute(self): + pass + + def yaw(self) -> float: + return self.gyro.get_yaw().value + + def roll(self) -> float: + return self.gyro.get_roll().value + + def pitch(self) -> float: + return self.gyro.get_pitch().value + + def rotation2d(self): + return self.gyro.getRotation2d() + + def degrees_per_second_ccw(self) -> float: + return self.gyro.get_angular_velocity_z_world().value + + def getRadiansPerSecCCW(self) -> float: + return math.radians(self.degrees_per_second_ccw()) + + def set_yaw(self, angle): + self.gyro.set_yaw(angle) \ No newline at end of file diff --git a/robot.py b/robot.py index acc3a2d..6089b15 100644 --- a/robot.py +++ b/robot.py @@ -4,18 +4,19 @@ import genie class MyRobot(genie.GenieRobot): - CONTROLLER: components.XboxController + controller: components.XboxController + pigeon: components.Pigeon def createObjects(self): """Create motors and stuff here""" # Controller stuff here - self.CONTROLLER_CORRECT_FOR_DEADBAND = constants.CONTROLLER_CORRECT_FOR_DEADBAND - self.CONTROLLER_DEADBAND = constants.CONTROLLER_DEADBAND - self.CONTROLLER_PORT = constants.CONTROLLER_PORT + self.controller_correct_for_deadband = constants.CONTROLLER_CORRECT_FOR_DEADBAND + self.controller_deadband = constants.CONTROLLER_DEADBAND + self.controller_port = constants.CONTROLLER_PORT def teleopInit(self): """Called when teleop starts; optional""" def teleopPeriodic(self): """Called periodically during teleop""" - self.CONTROLLER.capture_button_presses() + self.controller.capture_button_presses()