swerve package¶
Submodules¶
swerve.swerve_drive module¶
Implements a full swerve drive.
-
class
swerve.swerve_drive.
SwerveDrive
(length, width, config_tuples)[source]¶ Bases:
object
-
drive
(forward, strafe, rotate_cw, max_wheel_speed=370)[source]¶ Compute and apply module angles and speeds to achieve a given linear / angular velocity.
All control inputs (arguments) are assumed to be in a robot oriented reference frame. In addition, all values are (for now) assumed to fall within the range [0, 1].
Parameters: - forward (number) – The desired, relative forward motion of the robot.
- strafe (number) – The desired, relative sideways motion of the robot.
- rotate_cw (number) – The desired rotational speed of the robot.
-
swerve.swerve_module module¶
Implements common logic for swerve modules.
-
class
swerve.swerve_module.
SwerveModule
(name, steer_id, drive_id)[source]¶ Bases:
object
-
apply_control_values
(angle_radians, speed, direct=False)[source]¶ Set a steering angle and a drive speed simultaneously.
Parameters: - angle_radians (number) – The desired angle to steer towards.
- percent_speed (number) – The desired percentage speed to drive at.
See also
-
load_config_values
()[source]¶ Load saved configuration values for this module via WPILib’s Preferences interface.
The key names are derived from the name passed to the constructor.
-
save_config_values
()[source]¶ Save configuration values for this module via WPILib’s Preferences interface.
-
set_drive_speed
(speed, direct=False)[source]¶ Drive the swerve module wheels at a given percentage of maximum power or speed.
Parameters: percent_speed (number) – The speed to drive the module at, expressed as a percentage of maximum speed. Negative values drive in reverse.
-
set_steer_angle
(angle_radians)[source]¶ Steer the swerve module to the given angle in radians. angle_radians should be within \([-2\pi, 2\pi]\). This method attempts to find the shortest path to the given steering angle; thus, it may in actuality servo to the position opposite the passed angle and reverse the drive direction. :param angle_radians: The angle to steer towards in radians,
where 0 points in the chassis forward direction.
-