Motors and Drivetrains
In this training module, we will explore the various motors and drivetrains commonly used in FRC robots. We will also write our first Java: reading a controller and driving a simulated differential drive robot through MWLib, the team's robot library, so we never program a motor directly.
Presentation
Do this lesson in Scriptum
The exercises below are the Motors and Drivetrains lesson in Scriptum. Open the lesson, start the simulated robot and follow its README. Each step is checked with the Verify button.
New Java in this lesson: calling methods, double variables and the arithmetic operators + - * /.
Exercises
Motors
- Read the controller sticks from your own code
- Declare
doublevariables and store the stick values in them - Remember that pushing a stick forward gives a negative number
- Declare
Drivetrains
- Tank drive: the left stick drives the left side and the right stick drives the right side
- Drive forward, backward, and spin in place
- Arcade drive: the left stick drives forward and backward (up/down) and turns (left/right)
- Use arithmetic:
left = forward + turnandright = forward - turn
- Use arithmetic:
- Bonus: add a speed limit, and try squaring the stick values for finer control
Related Documentation
Hardware
- Motor Controllers: Overview of the motor controllers we use on our robots.
Hardware Interfacing
- Hardware Configurators: Guide on how to configure hardware components in the FRC ecosystem.
Software
- Variables and Data Types: Declaring variables and choosing a type.
- Operators: Arithmetic and comparison operators.
Software Tools
- VSCode: Our primary Integrated Development Environment (IDE) for programming.
- Driver Station: Software used to control and monitor the robot during competitions.