Skip to content

Stefan/fix disable 79#81

Merged
spderman3333 merged 7 commits into
mainfrom
stefan/fix-disable-79
Oct 13, 2025
Merged

Stefan/fix disable 79#81
spderman3333 merged 7 commits into
mainfrom
stefan/fix-disable-79

Conversation

@spderman3333
Copy link
Copy Markdown
Member

Only fixes the disabling bug of MotorSubsystem, without any extra code refactoring.

@spderman3333 spderman3333 self-assigned this Oct 13, 2025
vdikov
vdikov previously requested changes Oct 13, 2025
Comment thread .idea/discord.xml Outdated
*/
Current getAppliedCurrent();

/** Stops the motor. */
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.

Do you know: does this only cut power off, or does it also actively apply the break to the motor?

I see that for the TalonFXWrapper you can control this, so you might have to clarify here:

Depending on the motor setting, this can cruise or break... or something along those lines.

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.

This method depends on the individual implementation of the motor controller, it is out of our hands I believe.

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.

If you are correct that the behavior may differ by motor then let's please update the Javadoc to mention that.

CC @cuttestkittensrule in case he has knowledge about how the APIs of the motors we use might differ.

Comment thread lib/src/main/java/com/team2813/lib2813/control/motors/SparkMaxWrapper.java Outdated
Comment thread lib/src/main/java/com/team2813/lib2813/control/motors/TalonFXWrapper.java Outdated
@spderman3333 spderman3333 requested a review from vdikov October 13, 2025 22:30
Copy link
Copy Markdown
Collaborator

@cuttestkittensrule cuttestkittensrule left a comment

Choose a reason for hiding this comment

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

The current changes lgtm.
This wouldn't fully fix #79 though, as MotorSubsystem will always work badly with positional control, even in the other methods. If you want to fully fix #79, you should raise an IllegalArgumentException if the end user passes in a control mode that has positional control (currently just MotionMagic)

Comment on lines +170 to +173
* <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.

Same as prior PR; CTRE may add, remove, or modify the meaning of the neutral mode values, so enumerating them isn't a good 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.

+1

Copy link
Copy Markdown
Collaborator

@cuttestkittensrule cuttestkittensrule left a comment

Choose a reason for hiding this comment

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

After in person discussion, @spderman3333 and I agreed that we can fix the issues with the subsystem in another PR.
I still am not a fan of the documentation, but it is good enough.

@spderman3333 spderman3333 merged commit cabe20e into main Oct 13, 2025
1 of 2 checks passed
@cuttestkittensrule
Copy link
Copy Markdown
Collaborator

@kcooney It looks like we got another JVM crash, here is the CI run if you want to look into it more. I think it might be the same race condition; the crash is in nt::ListenerStorage::ReadListenerQueue(unsigned int)+0x5a


/** Stops the motor. */
void disable();
}
Copy link
Copy Markdown
Contributor

@kcooney kcooney Oct 14, 2025

Choose a reason for hiding this comment

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

@spderman3333 as mentioned in the other PR, disable() is a confusing name since the reader could think this disables the controller (especially if a class implements Motor and Controller) and/or that you need to re-enable it somehow.

Given the description of this method, could you please send a PR renaming this to stopMotor()?

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 refactoring, as the method is introduced as "disable()" in MotorSubsystem, i have decided to name the method accordingly.

Copy link
Copy Markdown
Contributor

@kcooney kcooney Oct 14, 2025

Choose a reason for hiding this comment

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

This PR was submitted. My request is to send another, renaming Motor.disable() to stopMotor()

We could deprecate MotorSubsystem.disable() if you'd like

@spderman3333 spderman3333 deleted the stefan/fix-disable-79 branch October 14, 2025 01:49
@kcooney
Copy link
Copy Markdown
Contributor

kcooney commented Oct 14, 2025

@kcooney It looks like we got another JVM crash, here is the CI run if you want to look into it more. I think it might be the same race condition; the crash is in nt::ListenerStorage::ReadListenerQueue(unsigned int)+0x5a

@cuttestkittensrule Ack

This is indeed the same use-after-free bug I reported to the WPILib maintainers

kcooney added a commit that referenced this pull request Oct 15, 2025
This was broken when #81 was merged to main. We do not use a merge queue, so
this wasn't caught before the merge.
kcooney added a commit that referenced this pull request Oct 15, 2025
This was broken when #81 was merged to main. We do not use a merge
queue, so GitHub did rerun the build before merging.
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.

disable() method of MotorSubsystem will not work for positional control.

4 participants