Add ModuleIOSimTalonFX and refactor TalonFX module IO layer#18
Open
nlaverdure wants to merge 11 commits into
Open
Add ModuleIOSimTalonFX and refactor TalonFX module IO layer#18nlaverdure wants to merge 11 commits into
nlaverdure wants to merge 11 commits into
Conversation
* added Ratio enum * formatting * add gear ratios * use varags, reduce field visibility * remove DRIVE_MOTOR_REDUCTION field * remove unnecessary vendordeps * refine DriveGearRatio couple ratio to support multiple chassis-frame stages Add chassisStages parameter to explicitly separate chassis-frame gear reduction stages (whose product is the couple ratio) from azimuth-frame stages. Add Javadoc to constructor, getDriveMotorReduction, and getCoupleRatio. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: BenGamer3 <benbenw2020@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
* Updating the trigger encoders for glass * Fixing the trigger encoders and made a build of the robot code
- Add ModuleIOSimTalonFX: Phoenix 6 hardware-in-the-loop sim using TalonFXSimState + CANcoderSimState driven by DCMotorSim physics - Expose DRIVE_INITIAL_CONFIGS and TURN_INITIAL_CONFIGS as public in DriveConstants so both TalonFX IO implementations share the same source - Add createDriveSim() / createTurnSim() factory methods to DriveConstants, eliminating duplicated DCMotorSim construction in ModuleIOSimWPI and ModuleIOSimTalonFX - Replace hardcoded 0.02s with Robot.defaultPeriodSecs in both sim classes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add buildDriveConfig(), buildTurnConfig(), and configureCANcoder() to DriveConstants, eliminating ~40 lines of duplicated config mutation from both ModuleIOTalonFX and ModuleIOSimTalonFX constructors. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…IO classes Move shared hardware fields, all 6 control requests, all 9 status signals, device construction, config application, signal initialization, all 5 set* methods, and signal-reading helper into abstract base class. ModuleIOTalonFX and ModuleIOSimTalonFX now only contain what is unique to each: odometry queues/debouncers and physics sim state respectively. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move all non-per-module field mutations (NeutralMode, gains, gear ratios, MotionMagic, FeedbackSensorSource, ContinuousWrap, inversion) from factory methods into DRIVE_INITIAL_CONFIGS and TURN_INITIAL_CONFIGS. Move the remaining per-module mutations (DriveMotorInverted, FeedbackRemoteSensorID, EncoderInverted) directly into the ModuleIOTalonFXBase constructor. Removes buildDriveConfig(), buildTurnConfig(), and configureCANcoder() from DriveConstants entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove private static final intermediates that were only referenced once: closed-loop output types, motor/feedback types, stator current limit, friction voltages, and both initial TalonFXConfiguration objects. All config now lives directly in CONSTANT_CREATOR, keeping only named constants that have a meaningful rationale or are used in more than one place (STEER_GAINS, DRIVE_GAINS, SLIP_CURRENT, STEER_STATOR_CURRENT_LIMIT). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace two remaining DRIVE_MOTOR_REDUCTION usages (createDriveSim and withSensorToMechanismRatio) with SELECTED_RATIO.getDriveMotorReduction() following the DriveGearRatio enum introduced in main. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add configureModule() to bake DriveMotorInverted into DriveMotorInitialConfigs.MotorOutput.Inverted and EncoderId into SteerMotorInitialConfigs.Feedback.FeedbackRemoteSensorID immediately after createModuleConstants(). ModuleIOTalonFXBase can now apply constants.DriveMotorInitialConfigs and constants.SteerMotorInitialConfigs directly without mutation, keeping all configuration logic in DriveConstants. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ModuleIOSimTalonFX: Phoenix 6 hardware-in-the-loop simulation usingTalonFXSimState/CANcoderSimStatedriven byDCMotorSimphysics. Uses the same hardware configuration and control requests asModuleIOTalonFX, so sim behavior closely tracks hardware.ModuleIOTalonFXBase: Abstract base class shared byModuleIOTalonFX(hardware) andModuleIOSimTalonFX(sim), holding all device fields, control requests, status signals, andset*methods. Each subclass only contains what is unique to it (high-frequency odometry queues for hardware; sim state + physics update for sim).DriveConstants: Moved allTalonFXConfigurationandCANcoderConfigurationsetup intoCONSTANT_CREATOR'swithDriveMotorInitialConfigs/withSteerMotorInitialConfigsinline builders. Removed intermediate factory methods (buildDriveConfig,buildTurnConfig,configureCANcoder) and single-use private constants. Remaining named constants are those with meaningful rationale or used in multiple places (STEER_GAINS,DRIVE_GAINS,SLIP_CURRENT,STEER_STATOR_CURRENT_LIMIT).ModuleIOSimWPI: Uses centralizedDriveConstants.createDriveSim()/createTurnSim()andRobot.defaultPeriodSecsin place of localLinearSystemIdcalls and the0.02literal.Test plan
ModuleIOSimTalonFX): launch in simulation, confirm modules steer and drive under joystick input, odometry updates at 50 HzModuleIOSimWPI): confirm no regression in existing WPI sim path🤖 Generated with Claude Code