Skip to content

made zeroing for intake and hood - #165

Open
BrodyKarr wants to merge 15 commits into
mainfrom
add-zeroing
Open

made zeroing for intake and hood#165
BrodyKarr wants to merge 15 commits into
mainfrom
add-zeroing

Conversation

@BrodyKarr

Copy link
Copy Markdown
Contributor

No description provided.

@BrodyKarr
BrodyKarr requested a review from a team as a code owner February 16, 2026 19:09
@BrodyKarr BrodyKarr linked an issue Feb 16, 2026 that may be closed by this pull request
@BrodyKarr
BrodyKarr enabled auto-merge (squash) February 16, 2026 19:09
Comment thread src/main/java/frc/robot/Robot.java Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR implements motor zeroing functionality for the intake pivot and hood subsystems in an FRC robot. Zeroing is a critical initialization procedure that establishes a known reference position for mechanisms without absolute encoders by driving them to a hard stop and resetting the sensor position.

Changes:

  • Added support for both automatic and manual zeroing modes with velocity-based stall detection
  • Integrated zeroing commands into robot lifecycle (autonomous, teleop, and disabled modes)
  • Extended Motion subsystem with voltage control, sensor position reset, and software limit management

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
Motion.java Added voltage control methods, velocity getters, sensor position reset, software limit control, and zeroing state flags
ConstMotion.java Defined zeroing constants including voltages, velocity thresholds, timeouts, and zero positions (with TODOs)
ZeroIntake.java New command for automatic intake pivot zeroing using velocity-based stall detection
ZeroHood.java New command for automatic hood zeroing using velocity-based stall detection
ManualZeroIntake.java New command for manual intake pivot zeroing with user-controlled motion and delta velocity detection
ManualZeroHood.java New command for manual hood zeroing with user-controlled motion and delta velocity detection
RobotContainer.java Created composed zeroing commands (zeroSubsystems and manualZeroSubsystems) and added allZeroed() helper
Robot.java Integrated zeroing into robot lifecycle: manual zeroing in disabled mode, automatic zeroing before autonomous/teleop if needed

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/frc/robot/commands/zeroing/ZeroIntake.java
Comment thread src/main/java/frc/robot/constants/ConstMotion.java Outdated
Comment on lines +76 to +80
public void setIntakePivotSoftwareLimits(boolean reverseLimitEnable, boolean forwardLimitEnable) {
ConstMotion.INTAKE_PIVOT_CONFIGURATION.SoftwareLimitSwitch.ReverseSoftLimitEnable = reverseLimitEnable;
ConstMotion.INTAKE_PIVOT_CONFIGURATION.SoftwareLimitSwitch.ForwardSoftLimitEnable = forwardLimitEnable;
intakePivot.getConfigurator().apply(ConstMotion.INTAKE_PIVOT_CONFIGURATION);
}

Copilot AI Feb 16, 2026

Copy link

Choose a reason for hiding this comment

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

Modifying shared configuration objects is not thread-safe and may have unintended side effects. The methods directly mutate ConstMotion.INTAKE_PIVOT_CONFIGURATION which is a shared constant. If multiple instances or threads access this, it could lead to race conditions. Consider creating a copy of the configuration, modifying it, and then applying it to avoid mutating shared state.

Copilot uses AI. Check for mistakes.
Comment thread src/main/java/frc/robot/constants/ConstMotion.java Outdated
Comment thread src/main/java/frc/robot/commands/zeroing/HumanZeroHood.java
Comment on lines +53 to +60
boolean deltaRotorVelocity = RobotContainer.motionInstance.getIntakePivotRotorVelocity()
.minus(lastRotorVelocity)
.lte(ConstMotion.MANUAL_ZEROING_DELTA_VELOCITY);

if (deltaRotorVelocity && lastRotorVelocity.lte(Units.RotationsPerSecond.of(0))) {
zeroingSuccess = true;
} else {
lastRotorVelocity = RobotContainer.motionInstance.getIntakePivotRotorVelocity();

Copilot AI Feb 16, 2026

Copy link

Choose a reason for hiding this comment

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

The logic for detecting zeroing completion appears incorrect. The condition checks if the velocity delta is less than or equal to MANUAL_ZEROING_DELTA_VELOCITY and if lastRotorVelocity is less than or equal to 0. However, the delta calculation on line 53-55 computes (current - last), which will be negative if velocity is decreasing. This means deltaRotorVelocity will be true when velocity decreases by more than 5 RPS, not when it's stable. Consider using the absolute value of the delta or reversing the logic to properly detect when the mechanism has stalled against a hard stop.

Suggested change
boolean deltaRotorVelocity = RobotContainer.motionInstance.getIntakePivotRotorVelocity()
.minus(lastRotorVelocity)
.lte(ConstMotion.MANUAL_ZEROING_DELTA_VELOCITY);
if (deltaRotorVelocity && lastRotorVelocity.lte(Units.RotationsPerSecond.of(0))) {
zeroingSuccess = true;
} else {
lastRotorVelocity = RobotContainer.motionInstance.getIntakePivotRotorVelocity();
AngularVelocity currentRotorVelocity = RobotContainer.motionInstance.getIntakePivotRotorVelocity();
boolean deltaRotorVelocity = lastRotorVelocity
.minus(currentRotorVelocity)
.lte(ConstMotion.MANUAL_ZEROING_DELTA_VELOCITY);
if (deltaRotorVelocity && lastRotorVelocity.lte(Units.RotationsPerSecond.of(0))) {
zeroingSuccess = true;
} else {
lastRotorVelocity = currentRotorVelocity;

Copilot uses AI. Check for mistakes.
Comment thread src/main/java/frc/robot/commands/zeroing/ZeroIntake.java Outdated
Comment thread src/main/java/frc/robot/commands/zeroing/HumanZeroHood.java
Comment on lines +53 to +60
boolean deltaRotorVelocity = RobotContainer.motionInstance.getHoodRotorVelocity()
.minus(lastRotorVelocity)
.lte(ConstMotion.MANUAL_ZEROING_DELTA_VELOCITY);

if (deltaRotorVelocity && lastRotorVelocity.lte(Units.RotationsPerSecond.of(0))) {
zeroingSuccess = true;
} else {
lastRotorVelocity = RobotContainer.motionInstance.getHoodRotorVelocity();

Copilot AI Feb 16, 2026

Copy link

Choose a reason for hiding this comment

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

The logic for detecting zeroing completion appears incorrect. The condition checks if the velocity delta is less than or equal to MANUAL_ZEROING_DELTA_VELOCITY and if lastRotorVelocity is less than or equal to 0. However, the delta calculation on line 53-55 computes (current - last), which will be negative if velocity is decreasing. This means deltaRotorVelocity will be true when velocity decreases by more than 5 RPS, not when it's stable. Consider using the absolute value of the delta or reversing the logic to properly detect when the mechanism has stalled against a hard stop.

Suggested change
boolean deltaRotorVelocity = RobotContainer.motionInstance.getHoodRotorVelocity()
.minus(lastRotorVelocity)
.lte(ConstMotion.MANUAL_ZEROING_DELTA_VELOCITY);
if (deltaRotorVelocity && lastRotorVelocity.lte(Units.RotationsPerSecond.of(0))) {
zeroingSuccess = true;
} else {
lastRotorVelocity = RobotContainer.motionInstance.getHoodRotorVelocity();
AngularVelocity currentRotorVelocity = RobotContainer.motionInstance.getHoodRotorVelocity();
AngularVelocity deltaRotorVelocityMeasure = lastRotorVelocity.minus(currentRotorVelocity);
boolean deltaRotorVelocity = deltaRotorVelocityMeasure
.lte(ConstMotion.MANUAL_ZEROING_DELTA_VELOCITY);
if (deltaRotorVelocity && lastRotorVelocity.lte(Units.RotationsPerSecond.of(0))) {
zeroingSuccess = true;
} else {
lastRotorVelocity = currentRotorVelocity;

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@TaylerUva not sure about this

() -> stateMachineInstance.tryState(RobotState.NONE));

Command zeroSubsystems = new ParallelCommandGroup(
new ZeroHood().withTimeout(ConstMotion.ZEROING_TIMEOUT.in(Units.Seconds)),

Copilot AI Feb 16, 2026

Copy link

Choose a reason for hiding this comment

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

Missing condition for intake pivot zeroing. Unlike ZeroHood, ZeroIntake includes an onlyIf check to skip zeroing if already zeroed (line 100). However, ZeroHood at line 99 has no such check and will always attempt to zero even if hasHoodZeroed is true. This creates an inconsistency and unnecessary wear on the hood mechanism. Consider adding .onlyIf(() -> !RobotContainer.motionInstance.hasHoodZeroed) to the ZeroHood command for consistency.

Suggested change
new ZeroHood().withTimeout(ConstMotion.ZEROING_TIMEOUT.in(Units.Seconds)),
new ZeroHood().onlyIf(() -> !RobotContainer.motionInstance.hasHoodZeroed)
.withTimeout(ConstMotion.ZEROING_TIMEOUT.in(Units.Seconds)),

Copilot uses AI. Check for mistakes.
@FRCTeam3255 FRCTeam3255 deleted a comment from BrodyKarr Feb 22, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@FRCTeam3255 FRCTeam3255 deleted a comment from Copilot AI Feb 27, 2026
Comment thread src/main/java/frc/robot/commands/zeroing/ManualZeroHood.java Outdated
Comment thread src/main/java/frc/robot/commands/zeroing/ManualZeroIntake.java Outdated
Comment thread src/main/java/frc/robot/commands/zeroing/ManualZeroIntake.java Outdated
Comment thread src/main/java/frc/robot/commands/zeroing/ManualZeroHood.java Outdated
Comment thread src/main/java/frc/robot/commands/zeroing/ManualZeroIntake.java Outdated
Comment thread src/main/java/frc/robot/subsystems/Motion.java Outdated
Comment thread src/main/java/frc/robot/commands/zeroing/ZeroIntake.java Outdated
Comment thread src/main/java/frc/robot/commands/zeroing/ZeroHood.java Outdated
Comment thread src/main/java/frc/robot/commands/zeroing/ZeroIntake.java
Comment thread src/main/java/frc/robot/RobotContainer.java Outdated
@TaylerUva
TaylerUva marked this pull request as draft February 28, 2026 00:14
auto-merge was automatically disabled February 28, 2026 00:14

Pull request was converted to draft

@BrodyKarr
BrodyKarr marked this pull request as ready for review March 21, 2026 17:53
@BrodyKarr
BrodyKarr enabled auto-merge (squash) March 21, 2026 17:53
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.

Add zeroing for intake and hood

5 participants