General Programming Strategy
- We use various functions to run our programs
(so we can reuse code and change
parameters, as required)
- We have created a selection program
which allows us to quickly and efficiently
choose missions (or even re-run missions
quickly) during matches. Audible sounds
and meaningful EV3 screen messages allow
the user to select programs with ease
- By using gear lash removal before each
movement, the acceleration and deceleration movements when starting
and stopping a movement, our own
error-corrected move block, and Proportional Integral Derivative
line following, we are able to achieve more consistent and repeatable
robot movement
- We regularly use functions, also known as subroutines, which allows us
to reuse code whenever possible and to keep
our program sizes manageable.
- We annotate our work to help us
debug programs and to better understand
the purpose of each line of code
- We make frequent use of our square up
function which allows the robot to position
itself perpendicularly to any line (from
virtually any angle of attack)
- Our functions and parameters are given
descriptive and meaningful names to allow
us to easily understand what our programs
are doing
- Within all of our major movement
functions (such as our error-corrected move block and PID line following block),
we have a function inside that is constantly
checking if a certain exit condition is met.
When that exit condition is met, the program
immediately exits that loop causing the robot to
advance to the next robot maneuver. For example, stop
the robot when one of the light sensors a black
line.
- Our "Check-Abort" function constantly checks
whether the EV3 up arrow button is pressed.
The robot operator can interrupt missions at any time and
still stay within the overall selection program
to avoid the need to exit the program and find
the next program or mission.
- When accelerating from a stationary position,
our robot uses Ctrl-Z-designed acceleration and deceleration feature s
to minimize the likelihood of wheel slip.
This provides for greater repeatability of
the robot’s movements.
- As well, instead of using standard calibrated
values, we use raw light sensor values for more
granularity. Our calibration program collects the
lowest and highest light readings the robot would
see. Then, based on those, we scale any light
readings to a usable range where 0 is black and
100 is white.
Program Hierarchy
In the interest of maximizing programming efficiency, we use subroutines whenever possible.
Subroutines are used for typical robot movements, like line following, squaring to a line,
error-corrected movements, etc., as well as for entire missions.
The use of subroutines allows us to re-use programming code and enjoy the benefits of an
efficient mission selection program. This diagram to the left illustrates the great extent
to which Ctrl-Z re-uses programming code.
Function Examples
Main Selection Program
This selection program allows us to quickly and
efficiently switch programs/missions
during the two-and-a-half minute match.
Our selection program contains functions, each containing one of our missions.
The user of the robot simply starts the selection
program and clicks the centre button to start the first
mission. Then, when the mission finishes, the robot
automatically advances to the next mission and waits for
the user to click the centre button to run the appropriate mission.
In case one needs to go backwards or
forwards through the list of missions, the program
accommodates that by allowing the user to navigate
with the left and right arrow buttons.
Square Up
We have created a function that makes the robot completely perpendicular to the edge of a black line.
Each light sensor corresponds with a motor. The robot drives up to the line and has the light sensor check the
reflected light values. If the light sensor sees a value of less than 50 (black), it will tell the motor to move
towards a value greater than 50 (white). It does this for both motors while for a set amount of time while slowly decreasing in power,
until the robot becomes completely perpendicular to the edge of the line.
Full Programming Documentation (Click to See Full Code!)