Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
b0ecf06
frome the top!
Ruthie-FRC Nov 3, 2025
f740211
Firingsolutionsolver.java
Ruthie-FRC Nov 4, 2025
3cd45db
a half baked chaotic mess :)
Ruthie-FRC Nov 5, 2025
1451203
dark mode.
Ruthie-FRC Nov 5, 2025
e4cef03
Revert "a half baked chaotic mess :)"
Ruthie-FRC Nov 5, 2025
c9fffa8
let there be light
Ruthie-FRC Nov 5, 2025
8a2d83c
stopped being lazy
Ruthie-FRC Nov 5, 2025
d066e47
used wpilib stuff to make code easier to maintain
Ruthie-FRC Nov 5, 2025
89651d5
no prefixes to my logs
Ruthie-FRC Nov 5, 2025
2830339
logging but the good way
Ruthie-FRC Nov 5, 2025
1fa5b03
poses and translations, oh joy!
Ruthie-FRC Nov 5, 2025
03bd036
fixed stuff lets go also humidity
Ruthie-FRC Nov 5, 2025
a9b7855
i built my code
Ruthie-FRC Nov 5, 2025
b801626
microoptimizations!
Ruthie-FRC Nov 10, 2025
9f7f9f2
fixed the thing bc i fogot to here htis file matches main now
Ruthie-FRC Nov 10, 2025
3f1b8b8
Merge branch 'FRC5892:main' into main
Ruthie-FRC Nov 11, 2025
b277093
Merge branch 'FRC5892:main' into main
Ruthie-FRC Nov 12, 2025
ac76e26
TODO.txt
Ruthie-FRC Nov 13, 2025
30c00a0
Update TODO.txt
Ruthie-FRC Nov 13, 2025
68acbcf
Initial plan
Copilot Nov 15, 2025
431da47
Add complete Bayesian tuner implementation with documentation and tests
Ruthie-FRC Nov 15, 2025
2120bf9
Update .gitignore for Python and remove __pycache__ directories
Ruthie-FRC Nov 15, 2025
f96bd61
Add ultra-simple driver interface with START_TUNER.py and driver docs
Ruthie-FRC Nov 15, 2025
c794ef9
Add zero-interaction auto-start daemon - drivers do literally nothing
Ruthie-FRC Nov 15, 2025
c79a5bf
Add final implementation summary - complete and production ready
Ruthie-FRC Nov 15, 2025
013b1af
Set team number to 5892 and add easy X/Y button bindings for shot log…
Ruthie-FRC Nov 15, 2025
cc6b292
Replace controller buttons with dashboard buttons and remove redundan…
Ruthie-FRC Nov 15, 2025
6309353
Capture complete robot state at shot time, add shooting interlocks, e…
Ruthie-FRC Nov 15, 2025
266dc6f
Add comprehensive dashboard button visual guide and extensive code do…
Ruthie-FRC Nov 15, 2025
aedd19d
Complete system optimization: separate config files, RoboRIO protecti…
Ruthie-FRC Nov 16, 2025
9893bfd
Add comprehensive final review - all 5 passes complete, production ready
Ruthie-FRC Nov 16, 2025
9f4afe0
Final deployment-ready package - all reviews complete, zero redundanc…
Ruthie-FRC Nov 16, 2025
c7b983f
built code
Ruthie-FRC Nov 16, 2025
35c4aca
Initial plan
Copilot Nov 16, 2025
3050537
Merge branch 'bayesopt' into copilot/move-files-to-bayesopt-folder
Copilot Nov 16, 2025
5cc9355
Reorganize bayesopt files into structured folders
Copilot Nov 16, 2025
c281075
Add bayesopt README and complete reorganization
Copilot Nov 16, 2025
aa40086
Remove unrelated Java file changes from merge
Copilot Nov 16, 2025
0a9985b
Addressing PR comments
Copilot Nov 16, 2025
5d7d4eb
Revert unnecessary formatting changes to src/ Java files
Copilot Nov 16, 2025
9ff20c0
Merge pull request #10 from Ruthie-FRC/copilot/move-files-to-bayesopt…
Ruthie-FRC Nov 16, 2025
2b83073
documentaion
Ruthie-FRC Nov 16, 2025
4b4f049
Fix punctuation in MASTERDOC.md
Ruthie-FRC Nov 17, 2025
b466a9b
Fix grammar issues in MASTERDOC.md
Ruthie-FRC Nov 17, 2025
9b63a2c
Fix typo and improve clarity in MASTERDOC.md
Ruthie-FRC Nov 17, 2025
84408da
Update operation guide reference in MASTERDOC
Ruthie-FRC Nov 17, 2025
199db4a
Fix typo in MASTERDOC.md regarding operation guide
Ruthie-FRC Nov 17, 2025
4e72329
START
Ruthie-FRC Nov 17, 2025
77d2694
Update instructions in START.md for tuner setup
Ruthie-FRC Nov 17, 2025
efb867b
TODO
Ruthie-FRC Nov 17, 2025
1dc8e1f
fixed formatting and issues with non ascii characters
Ruthie-FRC Nov 19, 2025
0345875
gave the code my sleep schedule
Ruthie-FRC Nov 22, 2025
c4689a3
Merge pull request #14 from Ruthie-FRC/ascii-fixes
Ruthie-FRC Dec 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,32 @@ ctre_sim/
compile_commands.json

# Version file
src/main/java/frc/robot/generic/BuildConstants.java
src/main/java/frc/robot/generic/BuildConstants.java

# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
env/
venv/
ENV/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Tuner logs
tuner_logs/
201 changes: 201 additions & 0 deletions bayesopt/config/COEFFICIENT_TUNING.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
"""
COEFFICIENT TUNING CONFIGURATION
=================================
This file controls WHAT gets tuned, HOW MUCH it can change, and IN WHAT ORDER.
Edit this file to customize the optimization behavior.

NO CODE CHANGES NEEDED - just modify the values below.
"""

# ============================================================
# TUNING ORDER - What gets optimized and in what sequence
# ============================================================
# The optimizer tunes ONE coefficient at a time in this order.
# Put most impactful coefficients first for fastest improvement.
# Comment out (add # at start) any coefficient you DON'T want to tune.

TUNING_ORDER = [
"kDragCoefficient", # Air resistance (MOST IMPACT - tune this first!)
"kVelocityIterationCount", # Solver accuracy vs CPU load
"kAngleIterationCount", # Solver accuracy vs CPU load
"kVelocityTolerance", # How precise velocity calculation needs to be
"kAngleTolerance", # How precise angle calculation needs to be
"kLaunchHeight", # Physical measurement (tune last - rarely changes)
# "kAirDensity", # Commented out - air density is constant (1.225)
]

# ============================================================
# COEFFICIENT DEFINITIONS
# ============================================================
# For each coefficient, you can control:
# - enabled: True = tune this, False = skip it
# - default_value: Starting value
# - min_value: Lowest allowed value (SAFETY LIMIT)
# - max_value: Highest allowed value (SAFETY LIMIT)
# - initial_step_size: How big the first changes are
# - step_decay_rate: How quickly to reduce step size (0.9 = shrink 10% per iteration)
# - is_integer: True = round to whole numbers, False = allow decimals
# - nt_key: NetworkTables path (don't change unless robot code changes)

# TODO: Update tuning parameters before testing on robot

COEFFICIENTS = {
"kDragCoefficient": {
"enabled": True, # ← CHANGE THIS to enable/disable tuning
"default_value": 0.003, # Starting guess
"min_value": 0.001, # ← SAFETY: Can't go below this
"max_value": 0.006, # ← SAFETY: Can't go above this
"initial_step_size": 0.001, # ← HOW MUCH: Start with big changes
"step_decay_rate": 0.9, # Gradually make smaller changes
"is_integer": False, # Allow decimals like 0.0035
"nt_key": "/Tuning/FiringSolver/DragCoefficient",
"description": "Air resistance coefficient - affects trajectory curvature"
},

"kAirDensity": {
"enabled": False, # ← DISABLED: Air density is constant in FiringSolutionSolver
"default_value": 1.225,
"min_value": 1.10,
"max_value": 1.30,
"initial_step_size": 0.05,
"step_decay_rate": 0.9,
"is_integer": False,
"nt_key": "/Tuning/FiringSolver/AirDensity",
"description": "Air density (kg/m³) - typically constant at 1.225"
},

"kVelocityIterationCount": {
"enabled": True, # ← CHANGE THIS to enable/disable tuning
"default_value": 20,
"min_value": 10,
"max_value": 30, # ← REDUCED from 50 to prevent RoboRIO CPU overload
"initial_step_size": 5, # ← HOW MUCH: Try steps of 5 iterations
"step_decay_rate": 0.85,
"is_integer": True, # Must be whole number (10, 11, 12, not 10.5)
"nt_key": "/Tuning/FiringSolver/VelocityIterations",
"description": "Solver iterations for velocity - more = accurate but slower"
},

"kAngleIterationCount": {
"enabled": True, # ← CHANGE THIS to enable/disable tuning
"default_value": 20,
"min_value": 10,
"max_value": 30, # ← REDUCED from 50 to prevent RoboRIO CPU overload
"initial_step_size": 5, # ← HOW MUCH: Try steps of 5 iterations
"step_decay_rate": 0.85,
"is_integer": True, # Must be whole number
"nt_key": "/Tuning/FiringSolver/AngleIterations",
"description": "Solver iterations for angle - more = accurate but slower"
},

"kVelocityTolerance": {
"enabled": True, # ← CHANGE THIS to enable/disable tuning
"default_value": 0.01,
"min_value": 0.005, # ← SAFETY: Too tight = solver struggles
"max_value": 0.05, # ← SAFETY: Too loose = inaccurate
"initial_step_size": 0.005, # ← HOW MUCH: Start with 0.005 m/s changes
"step_decay_rate": 0.9,
"is_integer": False,
"nt_key": "/Tuning/FiringSolver/VelocityTolerance",
"description": "Velocity convergence tolerance (m/s) - smaller = more precise"
},

"kAngleTolerance": {
"enabled": True, # ← CHANGE THIS to enable/disable tuning
"default_value": 0.0001,
"min_value": 0.00001, # ← SAFETY: Too tight = solver struggles
"max_value": 0.001, # ← SAFETY: Too loose = inaccurate
"initial_step_size": 0.0001, # ← HOW MUCH: Start with 0.0001 rad changes
"step_decay_rate": 0.9,
"is_integer": False,
"nt_key": "/Tuning/FiringSolver/AngleTolerance",
"description": "Angle convergence tolerance (rad) - smaller = more precise"
},

"kLaunchHeight": {
"enabled": True, # ← CHANGE THIS to enable/disable tuning
"default_value": 0.8,
"min_value": 0.75, # ← SAFETY: Physical robot constraint
"max_value": 0.85, # ← SAFETY: Physical robot constraint
"initial_step_size": 0.02, # ← HOW MUCH: Start with 2cm changes
"step_decay_rate": 0.9,
"is_integer": False,
"nt_key": "/Tuning/FiringSolver/LaunchHeight",
"description": "Launch height above ground (m) - physical measurement"
},
}

# ============================================================
# OPTIMIZATION SETTINGS
# ============================================================
# How the Bayesian optimizer behaves

# How many random points to try before starting intelligent optimization
N_INITIAL_POINTS = 5 # More = better exploration, slower convergence

# Maximum iterations per coefficient before moving to next one
N_CALLS_PER_COEFFICIENT = 20 # More = more thorough, takes longer

# ============================================================
# ROBORIO PROTECTION SETTINGS
# ============================================================
# Prevent overloading the robot's onboard computer

# Maximum coefficient updates per second (prevents NT spam)
MAX_WRITE_RATE_HZ = 5.0 # SAFETY: Don't flood the RoboRIO with updates

# Maximum shot data reads per second (prevents NT spam)
MAX_READ_RATE_HZ = 20.0 # SAFETY: Don't overload NT with read requests

# Batch multiple writes together (reduces NT traffic)
BATCH_WRITES = True # True = more efficient, False = immediate writes

# ============================================================
# PHYSICAL ROBOT LIMITS (SAFETY)
# ============================================================
# Hardcoded limits based on robot physical capabilities
# Reject any shot data outside these bounds (likely sensor errors)

PHYSICAL_MAX_VELOCITY_MPS = 30.0 # Maximum physically possible exit velocity
PHYSICAL_MIN_VELOCITY_MPS = 5.0 # Minimum physically possible exit velocity
PHYSICAL_MAX_ANGLE_RAD = 1.57 # ~90 degrees (straight up)
PHYSICAL_MIN_ANGLE_RAD = 0.17 # ~10 degrees (very low angle)
PHYSICAL_MAX_DISTANCE_M = 10.0 # Maximum field distance for shots
PHYSICAL_MIN_DISTANCE_M = 1.0 # Minimum shot distance

# ============================================================
# HOW TO USE THIS FILE
# ============================================================
"""
QUICK MODIFICATIONS:

1. DISABLE A COEFFICIENT:
Set enabled = False in that coefficient's section

2. CHANGE TUNING ORDER:
Rearrange or comment out items in TUNING_ORDER list

3. ADJUST HOW MUCH IT CHANGES:
Modify initial_step_size (bigger = more aggressive)

4. TIGHTEN SAFETY LIMITS:
Reduce the range between min_value and max_value

5. PROTECT ROBORIO:
Lower MAX_WRITE_RATE_HZ or MAX_READ_RATE_HZ

EXAMPLES:

# Only tune drag coefficient:
TUNING_ORDER = ["kDragCoefficient"]

# Make drag tuning more aggressive:
"initial_step_size": 0.002, # Change from 0.001

# Tighten drag safety range:
"min_value": 0.002, # Change from 0.001
"max_value": 0.004, # Change from 0.006

# Reduce RoboRIO load:
MAX_WRITE_RATE_HZ = 2.0 # Change from 5.0
"""
38 changes: 38 additions & 0 deletions bayesopt/config/TUNER_TOGGLES.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ============================================================
# TUNER CONTROL - THREE MAIN TOGGLES
# ============================================================
# This file controls the THREE main tuner settings
# NO DIGGING IN CODE REQUIRED - just edit these values
# ============================================================

[main_controls]
# Toggle 1: Turn the entire tuner on or off
# True = Tuner runs automatically in background
# False = Tuner is completely disabled
tuner_enabled = False

# Toggle 2: Block shooting until shot is logged (hit or miss button pressed)
# True = Robot cannot shoot again until driver logs previous shot result
# False = Robot can shoot freely (may miss logging some shots)
# RECOMMENDED: False for normal play, True for intensive tuning sessions
require_shot_logged = False

# Toggle 3: Block shooting until tuner finishes calculations and updates coefficients
# True = Robot waits for optimizer before allowing next shot
# False = Shooting and optimization happen independently
# RECOMMENDED: False for normal play, True for sequential testing
require_coefficients_updated = False

# ============================================================
# Team Configuration
# ============================================================
[team]
# Your FRC team number (used to calculate robot IP address)
team_number = 5892

# ============================================================
# THAT'S IT!
# ============================================================
# These are the only settings you need to change regularly.
# For coefficient tuning configuration, see COEFFICIENT_TUNING.py
# ============================================================
69 changes: 69 additions & 0 deletions bayesopt/docs/CONTRIBUTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Contributing — SideKick / bayesopt (short)

Thanks for contributing. Be clear, small, and test your changes.

Quick workflow
1. Fork, clone, create a branch (e.g. feat/xxx or fix/yyy).
2. Make focused commits, run tests/linters locally.
3. Push branch and open a PR against main (link issue if present).
4. Address reviews; rebase/squash if requested.

Etiquette (short)
- Be respectful and constructive.
- Ask questions instead of assuming.
- Explain why a change is needed and how you validated it.

Commit message (required)
Format:
<type>(scope): short imperative summary

Body:
- State value change clearly: "from X → Y on Z" and why.
- Add testing/compatibility notes as needed.

Types: feat, fix, docs, style, refactor, perf, test, chore

Example:
- feat(optimizer): change default learning_rate from 0.01 → 0.001
Body: "Changed Adam default LR 0.01 → 0.001 to improve noisy-data stability. Added unit test."

## Examples

Good commit + PR example (clear, concrete)

- Commit title:
feat(optimizer): reduce default Adam learning_rate 0.01 → 0.001

- Commit body:
- What changed value-wise: changed Adam (adaptive motion estimate) default learning_rate in bayesopt/optimizer.py from 0.01 → 0.001.
- Why: reduced overshooting and improved stability on noisy datasets (see issue #42).
- Tests: updated tests/test_optimizer.py::test_default_lr to assert new default.
- Files changed: bayesopt/optimizer.py, tests/test_optimizer.py, docs/usage.md (if applicable).

- PR description (short & required):
- Summary: Reduced Adam default LR 0.01 → 0.001 to improve noisy-data stability.
- Details:
- What changed: Adam.default_lr 0.01 → 0.001 in bayesopt/optimizer.py
- Why: training on noisy datasets showed unstable convergence; lowering LR reduced oscillation.
- How validated: ran unit tests and a small example run below.
- Validation steps (maintainers/reviewers):
1. Run unit test: pytest -k test_default_lr
2. Run a quick example: python examples/adam_demo.py --max-evals 10
3. Confirm no regression in CI and review updated test assertions.
- Related: Closes #42

Bad commit/PR (what to avoid)
- Title: "fix stuff"
- Body: no before/after values, no tests, no explanation.

PR checklist
- Branch uses naming convention.
- Tests added/updated where applicable.
- Linter run.
- Docs updated for public API changes.
- PR description states: what changed, from what → to what, why, and how to validate.

Issues
Provide summary, steps to reproduce, environment, and logs or minimal examples.

That's it — short, clear, and testable contributions are preferred.
Loading