Skip to content

Sim test support to auto - #26

Open
Nonochen0104 wants to merge 86 commits into
NonoAutofrom
jmm-sim-test-support
Open

Nonochen0104 wants to merge 86 commits into
NonoAutofrom
jmm-sim-test-support

Conversation

@Nonochen0104

Copy link
Copy Markdown
Collaborator

No description provided.

- Add SimulationManager class to simulate robot motion and sensor updates.
- Add simulation lifecycle methods (simulationInit, simulationPeriodic) to Robot.
- Add simulation support getters to SwerveSubsystem and SwerveModule.
- Update .gitignore to ignore ctre_sim/ directory.

All simulation code is optional and clearly separated from production code.
Resolved conflicts:
- Constants.java: Use INTAKE_ID=63 and INTAKE_ARM_ID=64 from jmm-sim-support
- SwerveSubsystem.java: Keep both drift test code and simulation support methods
- Store desiredState in SwerveModule for simulation access
- Refactor pointInDirection() to use setDesiredState()
- Support simulation for tests that control individual modules directly
- Improve test commands to work with simulation architecture
- Store desiredState in SwerveModule for simulation access
- Refactor pointInDirection() to use setDesiredState()
- Update SimulationManager to read desired states directly from modules
- Refactor SwerveSubsystem to read desired states from modules instead of storing them
…anization

- Add minHoldTimeSeconds parameter to hold at each position for simulation visibility
- Update state machine to use AT_TARGET and AT_ZERO states for holding
- Reorganize SmartDashboard keys with Test/ prefix for better grouping
- Update SwerveDriftTestManager to support new hold time parameter
- Update CAN IDs and module positions for rebuilt drivebase hardware
- Fix driveBaseRadius calculation (was halving already-halved values)
- Change gear ratios to match MK4i L2 modules (6.75 drive, 21.4 angle)
- Correct swerve kinematics module ordering to WPILib convention (+X fwd, +Y left)
- Change orbit radius from 3.5m to 2.22m in AutoAlign
- Pass isOpenLoop flag through driveFromChassisSpeeds (was hardcoded false)
- Add safety guard to resyncModuleEncoders (disabled-only check)
- Add controller bindings: Y=zero gyro, Back=resync encoders, Start=save offsets
- Add "New Cancoder Offset" SmartDashboard output for calibration
- Improve comments across AutoAlign, TeleopSwerve, Constants, and Main
- Update CAN IDs and module positions for rebuilt drivebase hardware
- Fix driveBaseRadius calculation (was halving already-halved values)
- Change gear ratios to match MK4i L2 modules (6.75 drive, 21.4 angle)
- Correct swerve kinematics module ordering to WPILib convention (+X fwd, +Y left)
- Change orbit radius from 3.5m to 2.22m in AutoAlign
- Pass isOpenLoop flag through driveFromChassisSpeeds (was hardcoded false)
- Add safety guard to resyncModuleEncoders (disabled-only check)
- Add controller bindings: Y=zero gyro, Back=resync encoders, Start=save offsets
- Add "New Cancoder Offset" SmartDashboard output for calibration
- Improve comments across AutoAlign, TeleopSwerve, Constants, and Main
- Exclude ctre_sim directory from merge
- Add CandleSubsystem with Phoenix 6 CANdle API for LED control
- Add color presets, animation types, and LED state management
- Add CANdleConstants with placeholder CAN ID
- Add .vscode/ to .gitignore
- Add CandleSubsystem with Phoenix 6 CANdle API for LED control
- Add color presets, animation types, and LED state management
- Add CANdleConstants with placeholder CAN ID
- Add .vscode/ to .gitignore
- Remove ctre_sim directory and add to .gitignore to prevent re-adding
- Remove unused Phoenix 5 vendor dependency (Phoenix5-frc2026-latest.json)
- Remove unnecessary CTR Electronics Maven repository from build.gradle
- Remove unused imports from RobotContainer (GenericHID, duplicate RunCommand,
  JoystickButton, POVButton)
- Fix duplicate CAN ID conflict (INTAKE_ID and INTAKE_ARM_ID were using same
  IDs as SHOOTER_ID and HOOD_ID) that caused simulator crash
- Rename ChangeColor to changeColor
- Rename ChangeState to changeState
- Rename ClearAnimations to clearAnimations
- Rename LightConfig to lightConfig

All methods now follow camelCase naming convention.
frankeljm and others added 30 commits February 20, 2026 15:48
* Update LimelightHelpers.java

* start to code auto align

* Coded auto align, also commented for most of them. Need correction with orbit tuning constans later.

* Add PID controller for correct radius & feedforward with angular velocity

* Fixed the swervemodules

* rezeroed

* Added SmartDashboard "New Offset"

* rename

* Adjust distance away from hub

* Re-Zero

* Update translation2d.

* fixed some comments

* update ids to the Rebuilt drivebase values.

* Update Constants.java

* Autonomous (#16)

* Test Reject on Compile Error (#7)

* test reject merge to main

* test reject merge with compile error

* fix compile error - pull request test

* Shooter Subsystem

* Shooter Subsystem

* Kinda buggy light subsystem

+ Blinking lights
uhh nothing really else

* Constant motor speed

* Slight organization

* X config + More optimized code

* Lights When Shooting

+ Shooting Lights
+ Light Control

* ID Switch

* Controll Changes and Feeder Addition

* Minor Feeder Bot Changes

* Moving IDS to constant

* !!!(NEEDS TESTING)!!! Robot motor code updated maybe

* Attempted fixes (not tested)

* Configured the Motors

* removed line 21

* made a boolean public

* working shooter and feeder code

shooter is a toggle
feeder works when held

* Remove lightSubsystem.java - moved to light-subsystem branch

---------

Co-authored-by: AlexHuie <ahuie26@moundsparkacademy.org>
Co-authored-by: Zachray <145231265+ZachrayL@users.noreply.github.com>
Co-authored-by: jmmaloney3 <jmmaloney3@gmail.com>

* Auto align (#9)

* Update LimelightHelpers.java

* AutoAlign coded with placeholder distance

* Coded auto align, also commented for most of them. Need correction with orbit tuning constans later.

* Add PID controller for correct radius & feedforward with angular velocity

* Fixed the swervemodules

---------

Co-authored-by: Seqi <gavin2noah@gmail.com>

* Pathplanner lib and basic auto structure (no commands)

* errors but commit so other people can get code

* Intake Toggle Code (#8)

* intake code
does not work yet

* updated intake code

changed control to toggle w/ x button on hems controller

roborio connection problem
can build but can't deploy

* updated pid value for test board

* toggle intake code

* started intake arm code

doesn't work yet

* added intake arm code

needs PID tuning and testing

* arm code with setpoints

moves to the setpoints but oscillates around them

nees tuning

* updated PID values (in progress)

* Changed intake button to two separate ones, A for lowering the intake arm, Y for raising the intake arm on helms controller

* adjust intake

* updated controls

* fixed intake arm (working), the motor is really strong but it's fine

---------

Co-authored-by: Nonochen0104 <xchen26@moundsparkacademy.org>

* shooter subsystem (#10)

* Shooter Subsystem

* Kinda buggy light subsystem

+ Blinking lights
uhh nothing really else

* Constant motor speed

* Slight organization

* X config + More optimized code

* Lights When Shooting

+ Shooting Lights
+ Light Control

* ID Switch

* Controll Changes and Feeder Addition

* Minor Feeder Bot Changes

* Moving IDS to constant

* !!!(NEEDS TESTING)!!! Robot motor code updated maybe

* Attempted fixes (not tested)

* Configured the Motors

* removed line 21

* made a boolean public

* working shooter and feeder code

shooter is a toggle
feeder works when held

* Remove lightSubsystem.java - moved to light-subsystem branch

* Added hood and controllers for all shooter related parts

* Fixed all the shooter parts, everything is working (shooter, feeder, hood)

* Deleted repeated helms controller definition

---------

Co-authored-by: FireheadReal <jwrich28@moundsparkacademy.org>
Co-authored-by: AlexHuie <ahuie26@moundsparkacademy.org>
Co-authored-by: jmmaloney3 <jmmaloney3@gmail.com>
Co-authored-by: Nonochen0104 <xchen26@moundsparkacademy.org>
Co-authored-by: Gavin <gavin2noah@gmail.com>

* Fix compile error in startAutoAt() method

- Complete the incomplete if statement
- Implement proper odometry reset with alliance-aware coordinate flipping
- Add missing Translation2d import
- Method now properly resets robot pose to starting position for autonomous

* fix compile error by completing startAutoAt method

* Theoretically working auto (probably not)

* partial autobuilder configuration code

* finished autoBuilder config

needs testing and review

* changed build.gradle

* Added pathplaner folder with eight lemon path

* added depot auto(s)

* add leave auto

---------

Co-authored-by: jmmaloney3 <jmmaloney3@users.noreply.github.com>
Co-authored-by: FireheadReal <jwrich28@moundsparkacademy.org>
Co-authored-by: AlexHuie <ahuie26@moundsparkacademy.org>
Co-authored-by: Zachray <145231265+ZachrayL@users.noreply.github.com>
Co-authored-by: jmmaloney3 <jmmaloney3@gmail.com>
Co-authored-by: Seqi <gavin2noah@gmail.com>

* fixed mistake in merge conflict

* Revert "fixed mistake in merge conflict"

This reverts commit 24fa677.

* Revert "Autonomous (#16)"

This reverts commit a6b3ecb.

* Add overloaded saveModuleOffsets method

* Pathplanner (autonomous)

added the Pathplannerlib in vendor and the constants&swervesubsystem settings for autonomous, started the 8 fuel auto with a path code in.

* Cleaned up things a little

Got some big blocks of comments deleted for this branch for now (better going over code for coding auto)

* Add DriveTestAuto

Added a drive test autonomous with both driving manually and driving by pathplanner (the pathplanner drive code is currently comment out but can bring back at any time, just switch the manual drive code)

* changed one id so it doesn't interfere

* Fixed the problem with swerve module 1

Put driveInvert and angleInvert specifically for every single module in Constants.

* Leave auto (coded manually) worked out great, still figuring out with the pathplanner auto

---------

Co-authored-by: Seqi <gavin2noah@gmail.com>
Co-authored-by: Nonochen0104 <xchen26@moundsparkacademy.org>
Co-authored-by: Nonochen0104 <157759781+Nonochen0104@users.noreply.github.com>
Co-authored-by: jmmaloney3 <jmmaloney3@users.noreply.github.com>
Co-authored-by: FireheadReal <jwrich28@moundsparkacademy.org>
Co-authored-by: AlexHuie <ahuie26@moundsparkacademy.org>
Co-authored-by: Zachray <145231265+ZachrayL@users.noreply.github.com>
Co-authored-by: jmmaloney3 <jmmaloney3@gmail.com>
Incorporates Nono auto PR (#22) from main:
- PathPlanner autonomous support (AutoConstants, DriveTestAuto, EightLemonAuto)
- Per-module motor inversion (driveInvert/angleInvert in ModuleData)
- CAN ID updates (SHOOTER_ID 60→70)
- FieldConstants updates (BLUE_REEF_CENTER → HUB_CENTER)

Resolved conflicts in Constants.java, SwerveModule.java, Robot.java,
and RobotContainer.java — preserved Javadoc comments and simulation/test
support from this branch.
Incorporates clean-up branch changes:
- CandleSubsystem method naming conventions (camelCase)
- 2024-2026 comparison report document
- CAN ID conflict fix and ctre_sim cleanup (already present, no-op)

Resolved conflicts in Constants.java (kept existing intake CAN IDs 63/64)
and CandleSubsystem.java (trivial whitespace).
Refactor test framework to use enum choosers directly
…leConfig

Problem: In autonomous simulation, the robot teleports to the path starting point (correct) but then sits still.

Root cause: ModuleConfig.maxDriveVelocityMPS was set to 3.0 m/s (the teleop software speed limit) instead of the motor's physical free speed (~5.35 m/s). At 3.0 m/s the NEO Vortex draws 94.6A, exceeding the 40A current limit. PathPlanner's trajectory generator clamped both max-speed and stall current to 40A, producing zero available torque, zero acceleration, and totalTime=0s.

Fix: Derive maxDriveVelocityMPS from DCMotor.getNeoVortex(1).freeSpeedRadPerSec through the gear reduction and wheel radius (~5.35 m/s). The path file maxVelocity constraint still limits planned speed to 3.0 m/s.

Add TrajectoryGenerationTest with programmatic test paths (no dependency on path files) that reproduces the bug with the old config and verifies the fix. Set DEBUG=true for verbose output.

See jmm-auto-mode-debug branch for full analysis (docs/auto-sim-log-analysis.md).
…c (not checked into git) gradle.init setting
Multi-trial simulator diagnostic test that reproduces issue 8.1/8.2:
- Phase 1: Resets pose and observes heading corruption from
  odometry.resetPosition() receiving desired heading as gyro baseline
  instead of actual pigeon reading
- Phase 2: Drives a closed-loop L-shaped path to quantify impact
  of corruption on robot motion
- 10 trials with per-trial statistics and summary table
- Registered in DiagnosticTestRegistry as ODOMETRY_RESET
This reverts commit ff3a1b7.
This reverts commit c09851b, reversing
changes made to e851f45.
Kept (auto-related):
- CenterToDepotAuto.java — new center-to-depot autonomous routine
- TrenchToDepotAuto.java — new trench-to-depot autonomous routine
- AutoMode enum: added None, TrenchToDepotAuto, CenterToDepotAuto
- AutoConstants: refactored static{} to lazy initDashboard() with guard
- AutoAlign: orbit radius tuned to 2.4384m (8 ft)
- RobotContainer: new auto imports, switch cases, initDashboard() call,
  slow-mode multiplier 0.7 → 0.85
- Constants: inner classes changed to static final (FieldConstants,
  ShooterConstants, IntakeConstants, CANdleConstants)

Not merged (sim-related — conflicts with SimulationManager approach):
- RobotSimulation.java (Nono's sim class)
- SwerveSubsystem sim fields/methods (simulationReset, simulationUpdate,
  lastCommandedSpeeds, simYawDegrees, simWheelPositionsMeters)
- SwerveSubsystem.periodic() if(!isSimulation()) guard
- Robot.java sim hooks (RobotSimulation instantiation and delegation)
- ctre_sim/ binary files (gitignored)
- FORCE_BLUE_ALLIANCE constant

Added:
- docs/sim-alternatives.md — comparison of SimulationManager vs
  RobotSimulation approaches with external FRC team research
When the robot transitions to disabled, modules retain their last
commanded velocity. Zero out module speeds on the enabled→disabled
transition to stop SimulationManager from integrating stale values.
Replace if/else fallback with MathUtil.clamp(dt, 0.0, 0.05). Zero dt
now produces zero motion instead of a phantom 20ms step. Upper bound
reduced from 1.0s to 50ms to limit pose jumps during GC pauses or
debugger breakpoints.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants