Skip to content

Fixed the disable method in MotorSubystem (now called PositionalMotor… - #73

Closed
spderman3333 wants to merge 6 commits into
mainfrom
stefan/motor_disable_fix
Closed

Fixed the disable method in MotorSubystem (now called PositionalMotor…#73
spderman3333 wants to merge 6 commits into
mainfrom
stefan/motor_disable_fix

Conversation

@spderman3333

Copy link
Copy Markdown
Member

…Subsystem for clarity).

Other changes:

  • Motor (interface) now adds a disable method.
  • TalonFxWrapper now has an implemented disable method (it defaults to coast, however).
  • SparkMaxWrapper has been marked as deprecated and for removal, alongside implementing the disable method (no clue if it works tho).
  • MotorSubsystem has been renamed to PositionalMotorSubsystem for clarity reasons.
  • PositionalMotorSubsystem now properly implements the disable method of the Motor interface.

@spderman3333 spderman3333 self-assigned this Oct 11, 2025
@spderman3333 spderman3333 added the enhancement New feature or request label Oct 11, 2025
@spderman3333
spderman3333 requested a review from kcooney October 11, 2025 04:21

@cuttestkittensrule cuttestkittensrule left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

See my comments for my specific thoughts on individual thoughs
I do have a question though: the title of the PR says you fixed the disable method of MotorSubsystem, but the implementation does the exact thing (minus calling disable instead of set, which should be equivalent iff disable is implemented correctly, which it isn't)

Comment thread .gitignore

# Exclude local preference files generated by VSCode editors.
.vscode/
.idea/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think we actually want to remove the entire .idea directory.
If we want it to be auto imported, we can uncomment these lines.
Even if we do want to do this, it would probably be better to have a separate discussion on this.

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.

@spderman3333 either revert, or address in a separate PR. Generally, you want to avoid bundling unrelated changes in the same PR (this here being some random config change that has nothing to do with the PR Title, which is all about fixing some logical error in the motor drive impl).

Comment on lines +169 to +172
* <ul>
* <li>Coast: The motor stops applying an input, but continues to move with its inertia.
* <li>Brake: The motor stops applying an input, and actively opposes its inertia.
* </ul>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Enumerating the neutral modes is probably a bad idea because they are already present in the Phoenix API docs, and may change in the future

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For now, its easier for anyone reading, that does not want to open a whole new tab.

Comment thread lib/src/main/java/com/team2813/lib2813/control/motors/SparkMaxWrapper.java Outdated
*/
@Override
public void disable() {
motor.disable();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You are probably looking for motor.stopMotor(), or even better, motor.set(new NeutralOut()) to be more explicit with the intention. The documentation from motor.disable() implies that it stops the motor controller instead of the output of the motor.

@kcooney kcooney Oct 11, 2025

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.

@spderman3333 given all the confusion as to the behavior of disable() on the various vendor motor classes, perhaps the new method you are adding to Motor should be named stopMotor(), not disable().

Comment thread lib/src/main/java/com/team2813/lib2813/control/motors/SparkMaxWrapper.java Outdated
Comment on lines +163 to +176
/**
* Clamps the given output value and provides it to the motor.
*
* <p>This was protected and non-final to allow subclasses to clamp the output. Subclasses should
* override {@link #clampOutput(double)}.
*
* @param output The output calculated by the PID algorithm.
* @param setpoint Ignored.
* @deprecated Subclasses should override {@link #clampOutput(double)}.
*/
@Deprecated
protected void useOutput(double output, double setpoint) {
motor.set(controlMode, clampOutput(output));
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We are already making a breaking change by renaming this class, so if we want to remove this deprecated code, now would be an amazing time to do it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The scope of the PR does not cover code refactoring, please make an issue so I can address this later.

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.

+1 to keeping PRs small in scope (generally, we should prefer many and small PRs in a sequence, over few but big ones). This one is already "too" big by including random .gitignore changes. I would have kept the renaming in a separate PR too.

Comment thread lib/src/main/java/com/team2813/lib2813/control/Motor.java
@spderman3333

Copy link
Copy Markdown
Member Author

Note: This PR is here to fix a critical bug which could lead to personal injury or damage to the robot, the ideas for fixes are great, but this PR should be merged ASAP.

@spderman3333

Copy link
Copy Markdown
Member Author

Closed: will split into seperate formatting and functionallity PRs

Comment thread .gitignore

# Exclude local preference files generated by VSCode editors.
.vscode/
.idea/

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.

@spderman3333 either revert, or address in a separate PR. Generally, you want to avoid bundling unrelated changes in the same PR (this here being some random config change that has nothing to do with the PR Title, which is all about fixing some logical error in the motor drive impl).

Comment thread .idea/.gitignore

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.

Same here, keep config changes out of this PR.

Comment on lines +163 to +176
/**
* Clamps the given output value and provides it to the motor.
*
* <p>This was protected and non-final to allow subclasses to clamp the output. Subclasses should
* override {@link #clampOutput(double)}.
*
* @param output The output calculated by the PID algorithm.
* @param setpoint Ignored.
* @deprecated Subclasses should override {@link #clampOutput(double)}.
*/
@Deprecated
protected void useOutput(double output, double setpoint) {
motor.set(controlMode, clampOutput(output));
}

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.

+1 to keeping PRs small in scope (generally, we should prefer many and small PRs in a sequence, over few but big ones). This one is already "too" big by including random .gitignore changes. I would have kept the renaming in a separate PR too.


/**
* Defines PID control over a motor, with values specified by an encoder
* This class is a mask of PositionalMotorSubsystem, kept for backwards compatibility.

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.

"mask" typically means other things in programming (bit masks, pixel masks, etc.) You might call this "alias" here instead.

@cuttestkittensrule

Copy link
Copy Markdown
Collaborator

This PR is here to fix a critical bug which could lead to personal injury or damage to the robot

@spderman3333 what specifically is the bug? Could you create a GitHub issue describing the bug that we can mark as closed after it is fixed? If we know exactly what the issue is, then we can probably add a regression test to ensure it stays fixed.

@kcooney

kcooney commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

Note: This PR is here to fix a critical bug which could lead to personal injury or damage to the robot, the ideas for fixes are great, but this PR should be merged ASAP.

@spderman3333 If you feel that the bug fix is that problematic, I strongly recommend fixing the bug in a separate PR first. Small changes are especially important for critical bugs since people sometimes feel pressure to rush and minimal changes are often safer.

@kcooney
kcooney deleted the stefan/motor_disable_fix branch February 9, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants