A first test of our swerve drive, offering both field orientated and robot orientated driving. Our drive uses Swerve Drive Specialists (SDS) MK4 Swerve Modules with an L2 gear ratio, driven with NEO brushless motors, controlled via SparkMax motor controllers. The software is written in Kotlin, leveraging Java libraries. 2023 will be the first FRC season we use a swerve drive. Needless to say, we are excited!
ABOUT SWERVE DRIVES
Swerve drives are highly maneuverable drives for robots. In it standard field oriented driving, the robot moves on the field in the direction of the gamepad's joystick movement, regardless of which way the robot is facing. For example, moving the joystick to the left moves the robot to the left, regardless of what direction the robot is facing. This allows for more intuitive control, and the ability to turn the robot around as you zip down field. (A second joystick is used to rotate the robot around its center.) For example, you may need the robot facing you to receive a game piece on your end of the field, but facing away from you to deposit the game piece on the far end of the field to score. With field orientated driving, after receiving the game piece, you can start racing down the field and turn around as you go. This saves considerable time by not having to back up, turn around, then move down the field. In robot orientated mode, activated by holding down a gamepad button, the robot movements are orientated based on the front of the robot. Moving the joystick to the left, moves the robot to the robot's left. This is useful when negativing via a camera for close up work. Swerve drives also allows for multi-directional movement. The robot can move left & right, or diagonally just as easily as forward and backwards.
HOW IT WORKS
Swerve drives work by having four serve modules, in each corner of the robot (although any number of modules 3 or greater could be used). There are two motors per wheel. One drives the wheel. The other turns the wheel in a full 360 degrees. An encoder is used to know the direction the wheel is facing. Another encoder is used to measure the speed of the wheel. An on board gyroscope tracks the orientation of the robot on the field. When the driver uses the joystick to control the robot, the software, reading the gyroscope to know its current rotation orientation, does the math -- know as Odometry -- to calculate what direction each wheel needs to turn, and how much speed needs to be applied to each wheel to get the robot to move in the desired direction. The math and motor updates are constantly repeated every 20 milliseconds, as the robot is driven.
![](https://s2.save4k.ru/pic/X2UjzPi35gU/maxresdefault.jpg)