SwerveModule
A representation of a swerve module. In a typical swerve drive chassis, there are four swerve modules - the front right, the front left, the back right, and the back left modules. Each of these modules is composed of two motors - the turn motor and the drive motor. In short, the turn motor can control the angle at which the drive motor is facing, and the drive motor can actually drive the robot.
Fields
turn
The Motor responsible for controlling the angle of the swerve module.
drive
The Motor responsible for driving the wheel of the swerve module.
getAngle
A Supplier<Angle> that provides the current angle of the swerve module.
Methods
SwerveModule(Motor turn, Motor drive, Supplier<Angle> getAngle)
Constructs a new SwerveModule.
turn: The motor that controls the angle the drive motor is facing.drive: The motor responsible for applying force to the ground and moving the chassis.getAngle: A supplier to access the module's angle. This angle is relative to the module, not the field. It should typically come from an encoder on the turn motor.
turn()
Returns the Motor instance representing the module's turn motor.
drive()
Returns the Motor instance representing the module's drive motor.
set(RelativeSwerveModuleState state)
Sets the power to both the turn and drive motors based on the provided RelativeSwerveModuleState.
getAngle()
Returns the current angle at which the swerve module is facing, obtained from the getAngle supplier.