@@ -70,12 +70,12 @@ def __init__(self) -> None:
7070 )
7171 self ._brake = swerve .requests .SwerveDriveBrake ()
7272 self ._point = swerve .requests .PointWheelsAt ()
73- self .slowmo = True
73+ self .slowmo = False
7474
7575 self ._logger = Telemetry (self ._max_speed )
7676
7777 self .drivetrain = TunerConstants .create_drivetrain ()
78- self .current_speed = MAX_SPEED_SCALING
78+ self .current_drive_speed = MAX_SPEED_SCALING
7979 self .current_rot_speed = MAX_SPEED_ROT
8080
8181 # Initialize the elevator with motor IDs
@@ -89,7 +89,7 @@ def __init__(self) -> None:
8989
9090 def calculateJoystick (self ) -> tuple [float , float ]:
9191 x0 , y0 = self ._joystick .getLeftX (), self ._joystick .getLeftY ()
92- magnitude = self .applyExponential (math .hypot (x0 , y0 ), self ._deadband , self ._exponent ) * self ._max_speed * self .current_speed
92+ magnitude = self .applyExponential (math .hypot (x0 , y0 ), self ._deadband , self ._exponent ) * self ._max_speed * self .current_drive_speed
9393 theta = math .atan2 (y0 , x0 )
9494
9595 x1 = magnitude * math .cos (theta )
@@ -103,7 +103,7 @@ def defaultDriveRequest(self) -> swerve.requests.SwerveRequest:
103103 return (self ._drive .with_velocity_x (self ._driveMultiplier * new_vy # Drive left with negative X (left)
104104 ) .with_velocity_y (self ._driveMultiplier * new_vx ) # Drive forward with negative Y (forward)
105105 .with_rotational_rate (
106- self ._driveMultiplier * self .applyExponential (self ._joystick .getRightX (), self ._deadband , self ._exponent ) * self ._max_angular_rate * self .current_rot_speed
106+ self ._rotMultiplier * self .applyExponential (self ._joystick .getRightX (), self ._deadband , self ._exponent ) * self ._max_angular_rate * self .current_rot_speed
107107 )) # Drive counterclockwise with negative X (left)
108108
109109 def create_go_to_coordinate_request (self ):
@@ -112,8 +112,6 @@ def create_go_to_coordinate_request(self):
112112 def create_point_at_coordinate_request (self ):
113113 return self .drivetrain .point_at_coordinate (DUMMY_POSE , self .calculateJoystick ())
114114
115-
116-
117115 def configureButtonBindings (self ) -> None :
118116 """
119117 Setup which buttons do what.
@@ -124,6 +122,7 @@ def configureButtonBindings(self) -> None:
124122
125123 # Cache the multiplier
126124 self ._driveMultiplier = - 1.0 if self .isRedAlliance () else 1.0
125+ self ._rotMultiplier = - 1.0
127126
128127 # Note that X is defined as forward according to WPILib convention,
129128 # and Y is defined as to the left according to WPILib convention.
@@ -163,16 +162,14 @@ def configureButtonBindings(self) -> None:
163162 #))
164163
165164 def gear_switch (self ):
166- if self .slowmo :
167- self .current_speed = SLOWMO_SPEED_SCALING
165+ if not self .slowmo :
166+ self .current_drive_speed = SLOWMO_SPEED_SCALING
168167 self .current_rot_speed = SLOWMO_SPEED_ROT
169- self .slowmo = False
168+ self .slowmo = True
170169 else :
171- self .current_speed = MAX_SPEED_SCALING
170+ self .current_drive_speed = MAX_SPEED_SCALING
172171 self .current_rot_speed = MAX_SPEED_ROT
173- self .slowmo = True
174-
175-
172+ self .slowmo = False
176173
177174 def resetHeading (self ) -> None :
178175 self .drivetrain .seed_field_centric ()
@@ -188,18 +185,14 @@ def _registerTelemetry (self) -> None:
188185 lambda state : self ._logger .telemeterize (state )
189186 )
190187
191-
192188 @staticmethod
193189 def compute_heading_to_target (current_pose : Pose2d , target_pose : Pose2d ) -> float :
194190 relative_pose = current_pose .relativeTo (target_pose )
195191 return math .atan2 (relative_pose .Y (), relative_pose .X ())
196192
197-
198193 @staticmethod
199194 def isRedAlliance () -> bool :
200195 return wpilib .DriverStation .getAlliance () == wpilib .DriverStation .Alliance .kRed
201-
202-
203196
204197 @staticmethod
205198 def applyExponential (input : float , deadband : float , exponent : float ) -> float :
0 commit comments