From 64d58fcfd8104a21ae16bf4d01136d80b3e81647 Mon Sep 17 00:00:00 2001 From: Mike Silva Date: Mon, 26 Jan 2026 20:53:07 -0500 Subject: [PATCH] More work --- src/components/gyro.py | 5 +++-- src/components/intake.py | 6 ++++++ src/components/swervemodule.py | 22 ++++++++++++++++++++++ src/components/vision.py | 6 ++++++ src/constants.py | 24 ++++++++++++++++++++++++ src/pyproject.toml | 2 +- src/robot.py | 5 +++-- 7 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 src/components/swervemodule.py create mode 100644 src/components/vision.py diff --git a/src/components/gyro.py b/src/components/gyro.py index ebc66ba..9b31e64 100644 --- a/src/components/gyro.py +++ b/src/components/gyro.py @@ -1,6 +1,6 @@ import math from phoenix6.hardware.pigeon2 import Pigeon2 -import navx +#import navx class Pigeon: @@ -33,7 +33,7 @@ class Pigeon: 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() @@ -72,3 +72,4 @@ class NavX: def zero_yaw(self) -> None: self.gyro.zeroYaw() +''' \ No newline at end of file diff --git a/src/components/intake.py b/src/components/intake.py index b7c82a2..12af728 100644 --- a/src/components/intake.py +++ b/src/components/intake.py @@ -24,5 +24,11 @@ class Intake: def retract(self): pass # Implement retraction logic here + def spin(self): + self.voltage = 1 + + def stop(self): + self.voltage = 0 + def set_voltage(self, voltage: units.volts): self.voltage = voltage diff --git a/src/components/swervemodule.py b/src/components/swervemodule.py new file mode 100644 index 0000000..186d602 --- /dev/null +++ b/src/components/swervemodule.py @@ -0,0 +1,22 @@ +import math + +class SwerveModule: + name: str + drive_id: int + drive_P: float + drive_I: float + drive_D: float + turning_id: int + turning_P: float + turning_I: float + turning_D: float + encoder_id: int + gear_ratio: float + wheel_diameter: float + + def setup(self): + self.max_angular_velocity = math.pi + self.max_angular_acceleration = math.tau + + def execute(self): + pass \ No newline at end of file diff --git a/src/components/vision.py b/src/components/vision.py new file mode 100644 index 0000000..0df1830 --- /dev/null +++ b/src/components/vision.py @@ -0,0 +1,6 @@ + +class Limelight: + def setup(self): + pass + def execute(self): + pass \ No newline at end of file diff --git a/src/constants.py b/src/constants.py index b409627..76bb71f 100644 --- a/src/constants.py +++ b/src/constants.py @@ -1,6 +1,30 @@ +import enum + # Should we apply deadband correction to the controller inputs? CONTROLLER_CORRECT_FOR_DEADBAND = True # The deadband for the controller joysticks CONTROLLER_DEADBAND = 0.3 # The port the controller is connected to CONTROLLER_PORT = 0 + +@enum.unique +class CANID(enum.IntEnum): + # CAN IDs for motors and other devices + FRONT_LEFT_DRIVE = 12 + FRONT_LEFT_STEER = 3 + FRONT_LEFT_STEER_ENCODER = 10 + + FRONT_RIGHT_DRIVE = 5 + FRONT_RIGHT_STEER = 6 + FRONT_RIGHT_STEER_ENCODER = 4 + + REAR_RIGHT_DRIVE = 9 + REAR_RIGHT_STEER = 11 + REAR_RIGHT_STEER_ENCODER = 4 + + REAR_LEFT_DRIVE = 8 + REAR_LEFT_STEER = 2 + REAR_LEFT_STEER_ENCODER = 7 + + # Pigeon2 IMU + PIGEON = 20 \ No newline at end of file diff --git a/src/pyproject.toml b/src/pyproject.toml index 5da83eb..44a4d8d 100644 --- a/src/pyproject.toml +++ b/src/pyproject.toml @@ -22,4 +22,4 @@ components = [ # Other pip packages to install, such as vendor packages (each element # is equivalent to a line in requirements.txt) -requires = ["phoenix6"] +requires = ["phoenix6", "robotpy-pykit"] diff --git a/src/robot.py b/src/robot.py index 6089b15..8b73329 100644 --- a/src/robot.py +++ b/src/robot.py @@ -1,11 +1,12 @@ import components import constants import genie - +from pykit.logger import Logger class MyRobot(genie.GenieRobot): controller: components.XboxController - pigeon: components.Pigeon + #pigeon: components.Pigeon + logger: Logger def createObjects(self): """Create motors and stuff here"""