Programming - Main Loop

The main "whileLoop" of our program this year is fairly short containing our functions and temeletry for the flywheel.
What is a Function?
You can think of functions (also known as methods) as a set of pre-written instructions represented by one line of code. When the function is called, the robot knows to run that set of instructions.
As an example, in our program we've created a function called splitStickArcadeDrive. Any time the robot receives an input for that function, in this case from the joysticks, it knows to go through the process of running the drivetrain despite those code lines not being listed individually in the mainLoop.

Our full splitStickArcadeDrive function, and those code steps, can be found elsewhere within our program organized and self-contained with all the relevant pieces together. This code is what's run when the function is called.

In short:
Functions take the place of several lines of code and appear as a single line when called. This can be incredibly useful if there is a section of code we know will be repeated or to break apart our code into chunks for easy editing and viewing.
Below is a breakdown of our functions
splitStickArcadeDrive
Contains the code for driving the robot
setFlywheelVelocity
Contains both the auto and manual control for the flywheel
manualCoreHexAndServoControl
Contains manual control for the feeder Core Hex and servo
Telemetry
The telemetry of the main loop reports the flywheel's velocity and how that equals to power. This can be used as a reference when troubleshooting the flywheel or determining if a new velocity target should be set.

Last updated
Was this helpful?