Skip to content

Swerve Genereated Code#14

Merged
Orcasphynx merged 1 commit intodevelopmentfrom
Swerve
Feb 6, 2026
Merged

Swerve Genereated Code#14
Orcasphynx merged 1 commit intodevelopmentfrom
Swerve

Conversation

@y0shi
Copy link
Member

@y0shi y0shi commented Feb 5, 2026

No description provided.

@y0shi y0shi requested a review from Orcasphynx February 5, 2026 15:54
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

AI Code Review

This is a fantastic first step in setting up your swerve drive! It looks like you've successfully integrated the generated code from Tuner X, which is a great way to get a robust swerve base quickly. The addition of the Telemetry class is also a very proactive move for debugging and understanding robot behavior.

Positive Highlights

  • Excellent Use of Generated Code: Leveraging Tuner X for your swerve drivetrain configuration (TunerConstants, CommandSwerveDrivetrain) is a smart and efficient approach, ensuring you're building on well-tested components.
  • Comprehensive Telemetry: The new Telemetry class is incredibly thorough, publishing a wide range of swerve drive states to NetworkTables and SignalLogger. This will be invaluable for debugging and analyzing robot performance, especially with deterministic replay.
  • Type-Safe Units: I noticed you're using WPILib's Units system in RobotContainer and TunerConstants (e.g., MetersPerSecond, RotationsPerSecond, Inches). This is an excellent practice that prevents common unit conversion errors.

Suggestions

Code Quality & Readability

  • RobotContainer.java - Javadoc for RobotContainer: The original RobotContainer had a comprehensive Javadoc block. While the generated code focuses on the drivetrain, it might be helpful to update the Javadoc for the RobotContainer class to reflect its current role in orchestrating commands and subsystems, rather than removing it entirely.
    • Why it matters: Good documentation helps new team members understand the purpose and structure of key classes quickly.
  • RobotContainer.java - Naming Conventions for MaxSpeed and MaxAngularRate: Consider renaming MaxSpeed and MaxAngularRate to kMaxSpeed and kMaxAngularRate (or similar) to follow the UPPER_SNAKE_CASE convention for constants, especially since they are final values defining limits.
    • Why it matters: Consistent naming improves readability and immediately indicates that these values are constants.
  • Telemetry.java - Javadoc for Members: While the class and constructor have good Javadoc, it might be helpful to add brief Javadoc comments for the private final members that publish to NetworkTables (e.g., drivePose, driveSpeeds, etc.).
    • Why it matters: This explains the purpose of each publisher, making the telemetry setup easier to understand for someone new to the code.
  • Telemetry.java - Mechanism2d Initialization: The initialization of m_moduleMechanisms, m_moduleSpeeds, and m_moduleDirections is quite repetitive. While perfectly functional, one approach could be to create a helper method or loop to initialize these more compactly, especially if you ever need to change the number of modules or their base properties.
    • Why it matters: Reduces code duplication and makes the code easier to maintain if adjustments are needed.

FRC/WPILib Best Practices

  • RobotContainer.java - Match Logging: The guidelines emphasize explicit match event logging. You've added autonomousInit() and teleopInit() calls with Logger.recordOutput for the Match/ events, which is excellent! This aligns perfectly with the team's custom rules.
    • Why it matters: This ensures critical match timing data is captured for analysis in AdvantageScope.
  • RobotContainer.java - Command Factory Method for Autonomous: Your getAutonomousCommand() method builds a sequence of commands, which is a great example of the Command Composition Pattern. This is very readable and follows best practices for building complex autonomous routines.
  • CommandSwerveDrivetrain.java - Simulation Loop Period: The change from 0.005 to 0.004 seconds for kSimLoopPeriod is a minor but good adjustment. A faster simulation loop can sometimes lead to more accurate PID behavior in simulation, which is a subtle but important detail for tuning.

Java Standards

  • RobotContainer.java - Unused Imports: I noticed frc.robot.Constants.OperatorConstants, frc.robot.commands.Autos, frc.robot.commands.ExampleCommand, frc.robot.subsystems.ExampleSubsystem, and edu.wpi.first.wpilibj2.command.button.Trigger are imported but no longer used after the update.
    • Why it matters: Removing unused imports keeps the code clean and prevents potential confusion. Spotless might handle this, but it's good to be aware.

Performance and Efficiency

  • Telemetry.java - SignalLogger.start(): Calling SignalLogger.start() in the Telemetry constructor means it will be called every time a Telemetry object is instantiated. Since SignalLogger is typically initialized once for the entire robot, consider moving this call to Robot.java or ensuring Telemetry is a singleton or only instantiated once.
    • Why it matters: Redundant calls to SignalLogger.start() might not cause issues, but it's generally best practice to initialize global logging once.

Questions

  • TunerConstants.java - Updated Swerve Parameters: The kSpeedAt12Volts, kCoupleRatio, kDriveGearRatio, kSteerGearRatio, kPigeonId, and module offsets/positions have been updated. Were these values derived from new measurements, a different swerve module, or updated calculations in Tuner X? It's always good to understand the source of these tuning parameters.
  • RobotContainer.java - Telemetry Instance: Is the Telemetry object intended to be a singleton, or will there be multiple instances? If it's a single instance for the robot, placing it as a static final member (or using a singleton pattern) could reinforce that design.

Keep up the excellent work! This PR significantly advances the robot's capabilities by getting a solid swerve drive in place with robust telemetry. Great job!


This review was automatically generated by AI. Please use your judgment and feel free to discuss any suggestions!

@github-actions
Copy link

github-actions bot commented Feb 5, 2026

✓ Build successful and code formatting check passed!

import edu.wpi.first.wpilibj.util.Color;
import edu.wpi.first.wpilibj.util.Color8Bit;

public class Telemetry {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks clean, though Epilogue is easier.

@Orcasphynx Orcasphynx merged commit 65fa507 into development Feb 6, 2026
2 checks passed
@Orcasphynx Orcasphynx deleted the Swerve branch February 6, 2026 00:43
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.

2 participants