From 5cbde246e0407001da18b4909aa1f9039e906b10 Mon Sep 17 00:00:00 2001 From: Michael Kennedy <34204085+mlists@users.noreply.github.com> Date: Mon, 11 Mar 2024 11:46:01 +1100 Subject: [PATCH] Appease robotic overlords --- components/chassis.py | 17 +++++++++++++---- physics.py | 4 +++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/components/chassis.py b/components/chassis.py index d6a8c19d..cb00d91a 100644 --- a/components/chassis.py +++ b/components/chassis.py @@ -235,7 +235,7 @@ def __init__(self) -> None: self.on_red_alliance = False - self.modules = [ + self.modules = ( # Front Left SwerveModule( self.WHEEL_BASE / 2, @@ -268,7 +268,7 @@ def __init__(self) -> None: TalonIds.steer_4, CancoderIds.swerve_4, ), - ] + ) self.kinematics = SwerveDrive4Kinematics( self.modules[0].translation, @@ -294,8 +294,17 @@ def __init__(self) -> None: def get_velocity(self) -> ChassisSpeeds: return self.kinematics.toChassisSpeeds(self.get_module_states()) - def get_module_states(self) -> list[SwerveModuleState]: - return [module.get() for module in self.modules] + def get_module_states( + self, + ) -> tuple[ + SwerveModuleState, SwerveModuleState, SwerveModuleState, SwerveModuleState + ]: + return ( + self.modules[0].get(), + self.modules[1].get(), + self.modules[2].get(), + self.modules[3].get(), + ) def setup(self) -> None: initial_pose = TeamPoses.RED_TEST_POSE if is_red() else TeamPoses.BLUE_TEST_POSE diff --git a/physics.py b/physics.py index 0106ba78..581f6d1c 100644 --- a/physics.py +++ b/physics.py @@ -70,7 +70,9 @@ def __init__(self, physics_controller: PhysicsInterface, robot: MyRobot): self.physics_controller = physics_controller self.kinematics: SwerveDrive4Kinematics = robot.chassis.kinematics - self.swerve_modules: list[SwerveModule] = robot.chassis.modules + self.swerve_modules: tuple[ + SwerveModule, SwerveModule, SwerveModule, SwerveModule + ] = robot.chassis.modules # Motors self.wheels = [