More tinkering
This commit is contained in:
parent
22841bd370
commit
8981527cec
|
|
@ -1,8 +1,12 @@
|
||||||
# from .drivetrain import DriveTrain
|
# from .drivetrain import DriveTrain
|
||||||
|
from .agitator import Agitator
|
||||||
from .controller import XboxController
|
from .controller import XboxController
|
||||||
from .pigeon import Pigeon
|
from .gyro import Pigeon
|
||||||
|
from .intake import Intake
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
"Agitator",
|
||||||
|
"Intake",
|
||||||
"Pigeon",
|
"Pigeon",
|
||||||
"XboxController",
|
"XboxController",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
class Agitator:
|
||||||
|
motor: TalonFX
|
||||||
|
voltage = magicbot.will_reset_to(0.0)
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
self.motor.set_control(VoltageOut(self.voltage))
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
config = TalonFXConfiguration()
|
||||||
|
config.motor_output.neutral_mode = NeutralModeValue.BRAKE
|
||||||
|
self.motor.configurator.apply(config)
|
||||||
|
|
||||||
|
def spin(self):
|
||||||
|
self.voltage = 1.0
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
self.voltage = 0.0
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
import math
|
||||||
|
from phoenix6.hardware.pigeon2 import Pigeon2
|
||||||
|
import navx
|
||||||
|
|
||||||
|
|
||||||
|
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 radians_per_second_ccw(self) -> float:
|
||||||
|
return math.radians(self.degrees_per_second_ccw())
|
||||||
|
|
||||||
|
def set_yaw(self, angle):
|
||||||
|
self.gyro.set_yaw(angle)
|
||||||
|
|
||||||
|
|
||||||
|
class NavX:
|
||||||
|
gyro: navx.AHRS # Either navx.AHRS.create_spi() or navx.AHRS.create_i2c()
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
self.gyro.reset()
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def yaw(self) -> float:
|
||||||
|
return self.gyro.getYaw()
|
||||||
|
|
||||||
|
def roll(self) -> float:
|
||||||
|
return self.gyro.getRoll()
|
||||||
|
|
||||||
|
def pitch(self) -> float:
|
||||||
|
return self.gyro.getPitch()
|
||||||
|
|
||||||
|
def is_calibrating(self) -> bool:
|
||||||
|
return self.gyro.isCalibrating()
|
||||||
|
|
||||||
|
def is_connected(self) -> bool:
|
||||||
|
return self.gyro.isConnected()
|
||||||
|
|
||||||
|
def rotation2d(self):
|
||||||
|
return self.gyro.getRotation2d()
|
||||||
|
|
||||||
|
def rotation3d(self):
|
||||||
|
return self.gyro.getRotation3d()
|
||||||
|
|
||||||
|
def reset(self) -> None:
|
||||||
|
self.gyro.reset()
|
||||||
|
|
||||||
|
def fused_heading(self) -> float:
|
||||||
|
return self.gyro.getFusedHeading()
|
||||||
|
|
||||||
|
def zero_yaw(self) -> None:
|
||||||
|
self.gyro.zeroYaw()
|
||||||
|
|
@ -11,13 +11,18 @@ class Intake:
|
||||||
voltage = magicbot.will_reset_to(0.0)
|
voltage = magicbot.will_reset_to(0.0)
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
motor_control = VoltageOut(self.voltage)
|
self.motor.set_control(VoltageOut(self.voltage))
|
||||||
self.motor.set_control(motor_control)S
|
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
config = TalonFXConfiguration()
|
config = TalonFXConfiguration()
|
||||||
config.motor_output.neutral_mode = NeutralModeValue.BRAKE
|
config.motor_output.neutral_mode = NeutralModeValue.BRAKE
|
||||||
self.motor.configurator.apply(config)
|
self.motor.configurator.apply(config)
|
||||||
|
|
||||||
|
def extend(self):
|
||||||
|
pass # Implement extension logic here
|
||||||
|
|
||||||
|
def retract(self):
|
||||||
|
pass # Implement retraction logic here
|
||||||
|
|
||||||
def set_voltage(self, voltage: units.volts):
|
def set_voltage(self, voltage: units.volts):
|
||||||
self.voltage = voltage
|
self.voltage = voltage
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
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)
|
|
||||||
Loading…
Reference in New Issue