LESSON 02 / 06
Java fundamentals for robotics
Use variables, methods, conditionals, loops, and classes to express robot behavior.
Learning Objectives
- Choose useful types for robot state
- Write small methods with clear inputs
- Use conditionals and loops safely
Explanation
A robot program is easier to tune when each idea has a name. Use variables for state, methods for actions, and conditionals for decisions. Keep loops bounded by the robot lifecycle and avoid hiding hardware behavior inside a large method.
Example
double clippedPower = Math.max(-1.0, Math.min(1.0, requestedPower));
if (gamepad1.a) {
clawOpen = true;
}Try It
Write a method signature for driving a motor at a requested power, then describe how you would clamp the input to the safe range.
