Skip to content

Major Refactor#7

Draft
pixelated-pup wants to merge 13 commits intomainfrom
Refactor
Draft

Major Refactor#7
pixelated-pup wants to merge 13 commits intomainfrom
Refactor

Conversation

@pixelated-pup
Copy link
Copy Markdown
Collaborator

Basically a dump of code restructuring changes I want to be in the long-term codebase. Not really intended for much use on this robot, I'll leave this PR as a draft so it can't be actually merged.

List of changes:

  • Combined Superstructure into Robot. Robot was nearly empty, and this has gone from a 220 line file and a 57 line file, to a single 250 line file (including other refactors).
  • Restructured vision at a subsystem level. Limelight is now simply an IO handler class, and a new Vision subsystem contains the array of Limelights and manages them all. Simplifies interaction with limelights by directing it through a single path, and makes changing the number of them easier.
  • Removed unneeded and unused SD keys.
  • Reworked the Key structure. All 3 types (Double, String, Boolean) are now implementations of a generic Key interface, which also extends the Supplier and Consumer interfaces for the given type. Using this and reflection, all Key fields in the SD class now get automatically initialised to smart dashboard.
  • Moved a number of final static fields in the input transmutation classes into Constants.
  • Removed the AlgaeRoller, as it didn't end up being used on the robot.
  • Renamed copilot to operator where it hadn't already been done.
  • Moved the number of MT1 cycles needed to Constants.
  • Used static imports in a number of places.
  • Changed all switches to use the modern syntax (making them expressions in some cases).
  • Changed the PID to pose command to end once at the target position. Also added a new FieldUtils method for checking pose alignment, as part of this.
  • Removed the Pathplanner Vendor Dep and the loadPathplannerPath FieldUtils method, as we're fully not using Pathplanner now.
  • Simplified CoralRoller subsystem. Now using a default command to stop the roller (as in SYF) instead of having the runCommand stop it when it ends. Removed separate setSpeed method, combining it into the body of setSpeedCommand (was never used separately). Removed entire "smartRunCommand" factory method, opting to effectively recreate it at the single place it was used (simply a .until() decoration).
  • Used more concise lamba syntax in a couple places (this::method rather than () -> method()).
  • Tweaked RumbleRequester. Changed the queue to be a HashSet rather than an ArrayList. This better fits the application of unique values and not caring about order, allows for linear-time access for removing values, and simplifies the add method by allowing it to not separately check if the value already exists in the queue. Additionally slightly restructured the command factories (same functionality as far as we are using it).
  • Attractor setup in FieldConstants now uses a static method that takes a BiPredicate to apply the relevant DriveState and TargetPosition to, which is then used as the Suppliers for the Attractors. This method is called on robot initialisation. This improves encapsulation over before, ensuring that any changes in the DriveState and TargetPosition structuring stays in a single file.
  • Removed a number of unused getters and setters from what was Superstructure.
  • General name tweaks, commenting, and organisation.
  • Changed a number of single-use methods that were passed to other methods to be declared anonymously in the other method calls.
  • Changed LL exposure setting to use an in-code state to track the current exposure. This minimises the number of SD calls each cycle.
  • Vision subsystem takes a consumer that the pose estimate results are applied to, rather than directly calling a static method in Superstructure. Improved encapsulation.
  • As above, but a Supplier for getting the heading and RPS.

That should be most of it, but I'm bound to have missed one or two things.

…ed refactor of vision systems. General encapsulation improvements.
…ed stuff, used reflection to auto-init everything in SD, removed unneeded keys, simplified coralroller, removed algaeroller, simplified RumbleRequester, renamed copilot to operator, organised utils a bit, changed switches to new syntax
…imelight, started tidying up vision rotation fetching
…er for Keys, removed unused methods in Robot
@pixelated-pup pixelated-pup marked this pull request as draft August 20, 2025 06:40
Copy link
Copy Markdown
Contributor

@Lego-archer-elf Lego-archer-elf left a comment

Choose a reason for hiding this comment

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

The system will need to be thoroughly tested to ensure everything still works and communicates as intended, but this all looks reasonable.
Only change I'd request is to have the limelight names moved to ID constants.

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