Activity 4.4: Explore Your Own Robot Code
🎯 Goal
By the end of this activity you will have:
- Applied the five-question Code Reading Framework to three files you haven’t studied before
- Used the WPILib docs and vendor docs to look up unfamiliar classes and methods
- Documented your findings for each file in a structured format
- Built confidence reading code you’ve never seen before
The Code Reading Framework (Recap)
You learned this framework in Unit 1. For every file, answer these five questions:
- What does this file do? — Summarize its purpose in one or two sentences.
- What subsystem or command does it belong to? — Where does it fit in the robot’s architecture?
- What methods does it expose? — What can other files call on this one?
- What does it depend on? — What imports, libraries, or other files does it use?
- When does this code run? — During init? Every 20ms loop? Only in auto? On a button press?
In Unit 1 you practiced this on Telemetry.java with guidance. Now you’ll do it independently on three new files.
File 1: Telemetry.java — A Deeper Look
You did a quick Code Reading of Telemetry.java in Unit 1. Now let’s go deeper. Open
Step 1: Skim the Imports
Before reading any method, look at the import statements at the top. They tell you what libraries this file depends on. You should see imports from:
com.ctre.phoenix6— CTRE Phoenix 6 library (forSwerveDriveState,SignalLogger)edu.wpi.first.math— WPILib math classes (Pose2d,ChassisSpeeds)edu.wpi.first.networktables— NetworkTables publishersedu.wpi.first.wpilibj— SmartDashboard, Mechanism2d
If you don’t recognize a class, look it up! For CTRE classes, check v6.docs.ctr-electronics.com. For WPILib classes, check docs.wpilib.org.
Step 2: Apply the Code Reading Framework
Telemetry.javaStep 3: Go Deeper — Questions to Investigate
After completing the Code Reading, try to answer these bonus questions using the WPILib docs:
- What is a
StructPublisherand why does Telemetry use it instead ofSmartDashboard.putNumber()? - What is
Mechanism2dand what does it visualize? - What does
SignalLoggerdo that SmartDashboard doesn’t?
-
StructPublisher is a NetworkTables publisher that can send structured data types (like
Pose2dorSwerveModuleState[]) as a single entry, rather than breaking them into individual numbers. It’s more efficient and keeps related data together. Look it up in the WPILib NetworkTables docs. -
Mechanism2d is a WPILib visualization tool that draws a 2D representation of a mechanism on the dashboard. Telemetry uses it to show each swerve module’s current angle and speed as arrows, giving the drive team a visual of what the drivetrain is doing.
-
SignalLogger is CTRE’s high-frequency data logging system. It records data to a file on the roboRIO at up to 250Hz (vs SmartDashboard’s ~50Hz), and the logs can be replayed in AdvantageScope for post-match analysis. SmartDashboard is for live viewing; SignalLogger is for detailed post-match review.
File 2: LimelightHelpers.java
This is a big file — don’t try to read every line. Focus on understanding the structure and purpose. Open
Step 1: Don’t Panic
LimelightHelpers.java is likely the longest file in the project. It’s a utility library provided by Limelight (the vision camera) — your team didn’t write most of it. The key insight: you don’t need to understand every line. Focus on what the file does and which methods your team actually uses.
Step 2: Skim the Structure
Scroll through the file and notice:
- Inner classes at the top (like
LimelightTarget_Fiducial,LimelightResults) — these are data containers for vision results - Static helper methods in the middle — these are the methods your team calls
- NetworkTables access throughout — LimelightHelpers reads data that the Limelight camera publishes to NetworkTables
Step 3: Apply the Code Reading Framework
LimelightHelpers.javaStep 4: Find Where Your Team Uses It
Search your project for LimelightHelpers. (with the dot) to find every place your team calls these methods. You should find calls in the drivetrain or a vision-related file. Note which methods are actually used — that’s the subset you need to understand.
Most teams use LimelightHelpers for two things:
-
AprilTag pose estimation —
getBotPoseEstimate_wpiBlue()returns the robot’s position on the field based on what AprilTags the camera can see. This feeds into the pose estimator for accurate autonomous driving. -
Target detection —
getTV()checks if the camera sees a target, andgetTX()/getTY()give the offset to aim at. This is used for auto-aiming features like your team’s AutoShootCommand.
File 3: TrajectoryCalculations.java
This file contains math. Don’t worry — you don’t need to understand the math to apply the Code Reading Framework. Open
Step 1: Read the Class-Level Comments
If there are comments at the top of the file or above the class declaration, read them first. They often explain the purpose better than the code itself.
Step 2: Identify the Public Methods
Scroll through and list every public method. For each one, note:
- The method name (what it’s called)
- The parameters (what inputs it needs)
- The return type (what it gives back)
Don’t worry about understanding the math inside each method yet. Focus on the interface — what goes in and what comes out.
Step 3: Apply the Code Reading Framework
TrajectoryCalculations.javaReflect: What Did You Learn?
Take a moment to think about what these three files have in common and how they differ.
🗣️ Teach It Back
Pick one of the three files you read and explain it to a teammate (or write it down as if you were explaining to a rookie). Use only plain English — no code jargon. If you can explain what the file does, what it depends on, and when it runs without using technical terms, you truly understand it.
There’s no single right answer here — this is about building self-awareness as a code reader. Some common observations:
-
Telemetry.java is often the easiest because it has a clear, single purpose (publish data) and the method names are descriptive. LimelightHelpers.java can be overwhelming due to its size, but the static methods are straightforward once you focus on the ones your team uses. TrajectoryCalculations.java is often the hardest because the math can be opaque.
-
For a shooting accuracy problem, you’d want to understand TrajectoryCalculations.java (is the math correct?) and LimelightHelpers.java (is the vision data accurate?). The trajectory calculations determine where to aim, and the Limelight data determines where the robot thinks it is.
-
Common lookups:
Pose2d,StructPublisher,Mechanism2d,NetworkTableInstance,SignalLogger. If you didn’t look anything up, challenge yourself to look up at least one unfamiliar class next time!
Bonus Challenge: Find a Fourth File
If you finished the three files above and want more practice, pick any file in the project that you haven’t opened yet. Apply the Code Reading Framework on your own — no guided answers this time.
Some suggestions:
AutoShootCommand.java — the auto-shoot command that coordinates turret, flywheel, and feederClimberSubsystem.java — Handles endgame climbing with elevator and servosTunerConstants.java — the auto-generated swerve configuration (read-only, but interesting to understand)
What’s Next?
You’ve now applied the Code Reading Framework to files across different categories — telemetry, vision utilities, and math helpers. You’re building the skill of picking up any file and quickly understanding its role.
In Lesson 4.5: Java Patterns in FRC Code, you’ll learn to recognize specific Java language patterns (lambdas, method references, enums, inheritance) that appear throughout the robot code. These patterns probably confused you when you first saw them — after Lesson 4.5, they won’t.
In Lesson 4.5: Java Patterns in FRC Code, you’ll learn to recognize specific Java language patterns (lambdas, method references, enums, inheritance) that appear throughout the robot code. These patterns probably confused you when you first saw them — after Lesson 4.5, they won’t.