Adding some components
This commit is contained in:
parent
f6a8adee4f
commit
9ff8c70e2c
|
|
@ -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
|
||||||
|
|
@ -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)
|
||||||
11
robot.py
11
robot.py
|
|
@ -4,18 +4,19 @@ import genie
|
||||||
|
|
||||||
|
|
||||||
class MyRobot(genie.GenieRobot):
|
class MyRobot(genie.GenieRobot):
|
||||||
CONTROLLER: components.XboxController
|
controller: components.XboxController
|
||||||
|
pigeon: components.Pigeon
|
||||||
|
|
||||||
def createObjects(self):
|
def createObjects(self):
|
||||||
"""Create motors and stuff here"""
|
"""Create motors and stuff here"""
|
||||||
# Controller stuff here
|
# Controller stuff here
|
||||||
self.CONTROLLER_CORRECT_FOR_DEADBAND = constants.CONTROLLER_CORRECT_FOR_DEADBAND
|
self.controller_correct_for_deadband = constants.CONTROLLER_CORRECT_FOR_DEADBAND
|
||||||
self.CONTROLLER_DEADBAND = constants.CONTROLLER_DEADBAND
|
self.controller_deadband = constants.CONTROLLER_DEADBAND
|
||||||
self.CONTROLLER_PORT = constants.CONTROLLER_PORT
|
self.controller_port = constants.CONTROLLER_PORT
|
||||||
|
|
||||||
def teleopInit(self):
|
def teleopInit(self):
|
||||||
"""Called when teleop starts; optional"""
|
"""Called when teleop starts; optional"""
|
||||||
|
|
||||||
def teleopPeriodic(self):
|
def teleopPeriodic(self):
|
||||||
"""Called periodically during teleop"""
|
"""Called periodically during teleop"""
|
||||||
self.CONTROLLER.capture_button_presses()
|
self.controller.capture_button_presses()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue