Skip to content

Repository files navigation

๐Ÿค– FTC DECODE Reference Implementation

โš ๏ธ EDUCATIONAL PURPOSE ONLY

This repository is a reference implementation created for educational purposes. It is NOT production-ready competition code. I am a parent mentor learning FTC programming to better support student teams. This codebase represents my learning journey and is shared openly so others can learn alongside me.

If you're a student team: Use this as a learning resource, but write your own code! The learning process is the most valuable part of FTC.

๐Ÿ“‹ Important: See the FTC Competition Rules & Ethics section below for guidance on using this code in compliance with FTC Rule R102.


๐Ÿ“– What Is This?

This is a reference implementation for an FTC (FIRST Tech Challenge) robot designed for the DECODE season (2025-2026). The game involves shooting 5-inch spherical foam balls called "Artifacts" into goals, with scoring patterns called "Motifs" determined by AprilTag detection.

Why I Made This

As a parent mentor with a software background but no robotics experience, I found it challenging to understand how all the pieces of an FTC robot fit together. The official documentation is excellent but scattered across many sources. I created this reference implementation to:

  1. Learn by doing - Building a complete system helped me understand the concepts
  2. Document patterns - Capture best practices I discovered along the way
  3. Help other mentors - Share what I learned so others don't start from zero
  4. Support student teams - Be a more effective mentor by understanding the code

What This Is NOT

  • โŒ Not competition-ready - This code has never been tested on a real robot
  • โŒ Not optimized - Performance and reliability need real-world tuning
  • โŒ Not official - This is one person's interpretation, not FIRST-endorsed
  • โŒ Not a shortcut - Students should write their own code to truly learn

โš–๏ธ FTC Competition Rules & Ethics

Important for Student Teams:

This code is provided for learning purposes only. According to FTC Rule R102, "Only STUDENTS may be credited for design." This means:

โœ… What You SHOULD Do

  • Study this code to understand concepts and patterns
  • Use ideas and adapt them to your robot's specific needs
  • Write your own code based on what you learn
  • Understand any code you use - be able to explain it in your own words
  • Document your learning process and decisions

โŒ What You SHOULD NOT Do

  • Don't copy code without understanding how it works
  • Don't use code you can't explain to judges
  • Don't treat this as a solution - it's a learning resource
  • Don't skip the learning process - that's the most valuable part!

๐ŸŽฏ During Judging

You must be able to explain your code. Judges will ask questions like:

  • "How does this work?"
  • "Why did you choose this approach?"
  • "What would you do differently?"

If you use concepts from this reference, be ready to explain them in your own words. The best teams can discuss their code confidently because they understand it deeply.

๐Ÿค– About AI-Assisted Coding

The FTC Competition Manual (as of 2025-2026) does not explicitly prohibit AI-assisted coding tools. However, Rule R102 still applies: students must understand and be able to explain their code.

Best practices:

  • Use AI as a learning tool, not a replacement for understanding
  • Explain AI-generated code in your own words
  • Modify and adapt code to fit your robot's needs
  • Document your learning process

Remember: The learning process is more valuable than the final code!


๐ŸŽฎ DECODE Game Overview

The DECODE game (2025-2026 FTC season) features:

Element Description
Artifacts 5-inch spherical foam balls (purple and green)
Motif A pattern of 2 purple + 1 green artifacts in a specific order
Obelisk Triangular structure with AprilTags (21, 22, 23) that reveals the Motif
Goals 3-sided structures with triangular openings for scoring
Ramp & Gate Classifier elements for pattern-based scoring

Match Structure

  • Autonomous: 30 seconds
  • Transition: 8 seconds
  • TeleOp: 2 minutes

Key Rules Referenced

  • LEAVE: Robot must move off LAUNCH LINE by end of AUTO for points
  • Expansion Limits (R105): 20ร—42 inches starting, 20ร—42ร—42 during match
  • PINNING: Cannot pin opponent for more than ~3 seconds

๐Ÿ—๏ธ Robot Design

This reference implementation assumes a robot with:

Component Description
Drivetrain Mecanum wheels with goBILDA Pinpoint odometry
Turret Rotating platform for aiming (motor-controlled)
Hood Adjustable angle for shot trajectory (servo-controlled)
Shooter Flywheel mechanism for launching Artifacts
Gate Servo-controlled ball release mechanism
Intake Wide roller system for collecting Artifacts
Vision Limelight 3A camera mounted on turret

๐Ÿ“ Project Structure

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/
โ”œโ”€โ”€ common/                    # Shared utilities and base classes
โ”‚   โ”œโ”€โ”€ Robot.java            # Central robot class (subsystem coordinator)
โ”‚   โ”œโ”€โ”€ Subsystem.java        # Abstract base for all subsystems
โ”‚   โ”œโ”€โ”€ Alliance.java         # RED/BLUE enum
โ”‚   โ”œโ”€โ”€ MatchState.java       # AUTO/TELEOP enum
โ”‚   โ””โ”€โ”€ AutoConstants.java    # Autonomous configuration
โ”‚
โ”œโ”€โ”€ subsystems/               # Hardware abstraction layer
โ”‚   โ”œโ”€โ”€ drive/
โ”‚   โ”‚   โ””โ”€โ”€ MecanumDrive.java # Drivetrain with Pedro Pathing integration
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ turret/
โ”‚   โ”‚   โ”œโ”€โ”€ Turret.java       # Turret motor control + auto-aim
โ”‚   โ”‚   โ””โ”€โ”€ TurretConstants.java
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ shooter/
โ”‚   โ”‚   โ”œโ”€โ”€ Shooter.java      # Flywheel control with RPM feedback
โ”‚   โ”‚   โ”œโ”€โ”€ ShooterConstants.java
โ”‚   โ”‚   โ”œโ”€โ”€ Hood.java         # Adjustable hood angle
โ”‚   โ”‚   โ”œโ”€โ”€ HoodConstants.java
โ”‚   โ”‚   โ”œโ”€โ”€ Gate.java         # Ball release timing
โ”‚   โ”‚   โ”œโ”€โ”€ GateConstants.java
โ”‚   โ”‚   โ””โ”€โ”€ ShootOnMoveController.java
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ vision/
โ”‚       โ”œโ”€โ”€ LimelightVision.java    # Limelight 3A interface
โ”‚       โ”œโ”€โ”€ VisionConstants.java    # All vision configuration
โ”‚       โ”œโ”€โ”€ PoseFusion.java         # Odometry + vision fusion
โ”‚       โ”œโ”€โ”€ TurretAimController.java # Vision-based aiming
โ”‚       โ””โ”€โ”€ README.md               # Vision system documentation
โ”‚
โ”œโ”€โ”€ pedroPathing/             # Motion planning
โ”‚   โ”œโ”€โ”€ Constants.java        # Pedro Pathing v2.0 configuration
โ”‚   โ””โ”€โ”€ tuning/
โ”‚       โ””โ”€โ”€ Tuning.java       # Interactive tuning OpMode
โ”‚
โ”œโ”€โ”€ opmodes/                  # Driver-runnable programs
โ”‚   โ”œโ”€โ”€ teleop/
โ”‚   โ”‚   โ””โ”€โ”€ MainTeleOp.java   # Primary driver control
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ auto/
โ”‚   โ”‚   โ”œโ”€โ”€ Auto_Blue_Park_Basic.java  # Simple park (no pathing)
โ”‚   โ”‚   โ”œโ”€โ”€ Auto_Red_Park_Basic.java
โ”‚   โ”‚   โ”œโ”€โ”€ Auto_Blue_MVP.java         # Full auto with shooting
โ”‚   โ”‚   โ”œโ”€โ”€ Auto_Red_MVP.java
โ”‚   โ”‚   โ””โ”€โ”€ MotifAutoExample.java      # Motif detection demo
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ test/
โ”‚       โ””โ”€โ”€ (test opmodes)
โ”‚
โ””โ”€โ”€ utils/
    โ””โ”€โ”€ GamepadEvents.java    # Button edge detection

โœจ Key Features

1. Pedro Pathing v2.0 Integration

Pedro Pathing provides smooth, curved autonomous paths using Bezier curves.

Key files:

  • pedroPathing/Constants.java - All configuration in one place
  • subsystems/drive/MecanumDrive.java - Follower integration

Concepts demonstrated:

  • Follower initialization with FollowerBuilder
  • Path following with PathChains
  • Localization via goBILDA Pinpoint
  • Field-centric teleop driving

2. Limelight 3A Vision System

The Limelight camera enables target tracking, AprilTag detection, and pose estimation.

Key files:

  • subsystems/vision/LimelightVision.java - Camera interface
  • subsystems/vision/VisionConstants.java - All vision tuning
  • subsystems/vision/README.md - Detailed documentation

Capabilities:

  • Target Tracking: Find Obelisk/Goals and calculate aim error
  • Distance Estimation: Trigonometric calculation from target
  • AprilTag Detection: Read Motif pattern, localize on field
  • Pose Fusion: Correct odometry drift after collisions

3. Auto-Aim Shooting System

The shooting system automatically aims and adjusts based on target distance.

Components:

Subsystem Function
Turret Rotates to aim at target
Hood Adjusts angle for distance
Shooter Spins flywheel to calculated RPM
Gate Controls ball release timing

Shot sequence:

  1. Vision acquires target
  2. Turret auto-aims (PID control)
  3. Hood adjusts angle for distance
  4. Flywheel spins to distance-based RPM
  5. All conditions met โ†’ Gate opens โ†’ Ball fires

4. Pose Fusion (Anti-Bump Correction)

When the robot collides with field elements or other robots, odometry can drift. The PoseFusion system uses AprilTags to snap back to the correct position.

Key file: subsystems/vision/PoseFusion.java

How it works:

  1. Continuously compare odometry pose to AprilTag-based pose
  2. When drift exceeds threshold and tags are visible
  3. Smoothly correct position (configurable alpha blending)
  4. Cooldown prevents jittery corrections

5. Shoot-on-the-Move

For efficient autonomous cycles, the robot pre-spools the shooter while approaching the shooting position.

Key file: subsystems/shooter/ShootOnMoveController.java

Strategy:

  • At 70% path completion: Start acquiring target
  • At 80% path completion: Start spooling flywheel
  • At 100%: Ready to shoot immediately

๐ŸŽฎ Controls (TeleOp)

Control Action
Left Stick Drive (field-centric)
Right Stick Rotate
Right Trigger Intake
Left Trigger Reverse intake
A Button Toggle auto-aim
B Button Fire shot
X Button Queue shot
Y Button Cancel queued shot
D-Pad Up/Down Manual RPM adjust
Left Bumper Manual turret left
Right Bumper Manual turret right

๐Ÿ”ง Configuration

Hardware Names

These names must match your Robot Configuration on the Control Hub:

Type Name Description
Motor leftFront Front left drive motor
Motor leftRear Rear left drive motor
Motor rightFront Front right drive motor
Motor rightRear Rear right drive motor
Motor turret Turret rotation motor
Motor flywheel Shooter flywheel motor
Motor intakeMotor Intake motor
Servo hood Hood angle servo
Servo gate Ball release servo
Servo indexer Ball indexer servo
I2C pinpoint goBILDA Pinpoint module
Other limelight Limelight 3A camera

FTC Dashboard Tuning

Most constants are annotated with @Config for real-time tuning via FTC Dashboard:

  • Connect to http://192.168.43.1:8080/dash
  • Modify values in the configuration panel
  • Changes apply immediately (no recompile needed)

Key tunable classes:

  • VisionConstants - All vision parameters
  • TurretConstants - Turret PID and limits
  • ShooterConstants - RPM targets and PIDF gains
  • HoodConstants - Angle mapping
  • GateConstants - Shot timing

๐Ÿš€ Getting Started

Prerequisites

  1. Android Studio Ladybug (2024.2) or later
  2. JDK 17 installed and configured
  3. FTC SDK (this repository is based on the official SDK)

Setup

  1. Clone this repository:

    git clone https://github.com/marktsears/ftc-decode-reference.git
  2. Open in Android Studio:

    • File โ†’ Open โ†’ Select the cloned folder
  3. Configure JDK (if needed):

    • Edit gradle.properties
    • Set org.gradle.java.home to your JDK 17 path
  4. Build:

    • Build โ†’ Make Project (or Ctrl+F9)
  5. Deploy to Control Hub:

    • Connect via USB or WiFi
    • Run โ†’ Select your configuration

First Steps

  1. Review the architecture: Start with common/Robot.java to understand how subsystems connect
  2. Study a simple OpMode: Look at Auto_Blue_Park_Basic.java for minimal complexity
  3. Understand vision: Read subsystems/vision/README.md thoroughly
  4. Trace a feature: Follow the auto-aim flow from MainTeleOp through all subsystems

๐Ÿ’ก Learning Tip: As you study this code, ask yourself:

  • "Why was this approach chosen?"
  • "How would I adapt this for my robot?"
  • "Can I explain this to someone else?"

The goal is understanding, not copying. Write your own code based on what you learn!


๐Ÿ“š Learning Resources

Official FTC Resources

Pedro Pathing

Limelight

Community


๐Ÿค Contributing

This is a personal learning project, but I welcome:

  • Bug reports - If you spot errors in the code
  • Suggestions - Better patterns or approaches
  • Questions - Help me improve the documentation

Please open an issue or submit a pull request!


๐Ÿ“œ License & Educational Use

This project is based on the official FTC SDK and follows its licensing terms. The custom code in TeamCode/ is provided as-is for educational purposes.

Educational Use License

Teams may:

  • โœ… Study and learn from the code
  • โœ… Adapt concepts for their own robots
  • โœ… Use code snippets with attribution
  • โœ… Reference patterns and architectures

Teams must:

  • โœ… Understand any code they use
  • โœ… Be able to explain it during judging
  • โœ… Follow FTC Rule R102 (student work requirements)
  • โœ… Write their own code based on what they learn

Attribution: If you use significant portions of this code, consider adding a comment like:

// Adapted from FTC DECODE Reference Implementation
// Original concepts learned from: [repository URL]

This is not required, but demonstrates good practice and transparency.


๐Ÿ™ Acknowledgments

  • FIRST for creating the FTC program
  • Pedro Pathing team for their excellent motion planning library
  • Limelight for making vision accessible
  • The FTC community for countless tutorials and examples
  • Student teams everywhere who inspire mentors to keep learning

Built with โ˜• and curiosity by a parent mentor learning alongside the students

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages