FRC / Vision / Controls

Turret Auto Align

A vision-assisted FRC turret alignment system using Java control logic, Limelight values, AprilTag readings, and a Python tuning pipeline.

2024Controls and ML tuningJavaLimelightAprilTagPython

Vision Pipeline

Fused Limelight targeting values with AprilTag readings to estimate angle error and keep the turret centered.

Java Control Loop

Structured the robot loop around sensor updates, PID correction, and safe fallback behavior when targets were lost.

ML-assisted Tuning

Converted robot logs into response features and trained regressors to suggest better PID multipliers.

Project Notes

The details that mattered.

What it did

The turret used target readings to choose a lock, correct angle error, and stay centered while the drivetrain was moving.

How tuning worked

I exported robot logs, extracted rise time, settling time, overshoot, steady-state error, and oscillation features, then trained separate regressors for P, I, and D multipliers.

Videos

Original project media, restored in color.

Turret view and target lock

On-robot field test

Alignment behavior pass

Code

Python training backend

import pandas as pd
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_absolute_error

FEATURE_COLUMNS = [
    "rise_time",
    "settling_time",
    "overshoot_pct",
    "steady_state_error",
    "oscillation_score",
]

LABEL_COLUMNS = ["p_multiplier", "i_multiplier", "d_multiplier"]

df = pd.read_csv("datasets/step_features.csv").dropna(subset=LABEL_COLUMNS)
X = df[FEATURE_COLUMNS].fillna(0.0)

for label in LABEL_COLUMNS:
    X_train, X_test, y_train, y_test = train_test_split(
        X,
        df[label],
        test_size=0.2,
        random_state=42,
    )
    model = RandomForestRegressor(n_estimators=200, max_depth=8)
    model.fit(X_train, y_train)
    print(label, mean_absolute_error(y_test, model.predict(X_test)))