Fixed the disable method in MotorSubystem (now called PositionalMotor… - #73
Fixed the disable method in MotorSubystem (now called PositionalMotor…#73spderman3333 wants to merge 6 commits into
Conversation
…Subsyem for clarity).
cuttestkittensrule
left a comment
There was a problem hiding this comment.
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)
|
|
||
| # Exclude local preference files generated by VSCode editors. | ||
| .vscode/ | ||
| .idea/ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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).
| * <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> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
For now, its easier for anyone reading, that does not want to open a whole new tab.
| */ | ||
| @Override | ||
| public void disable() { | ||
| motor.disable(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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().
| /** | ||
| * 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)); | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
The scope of the PR does not cover code refactoring, please make an issue so I can address this later.
There was a problem hiding this comment.
+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.
|
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. |
|
Closed: will split into seperate formatting and functionallity PRs |
|
|
||
| # Exclude local preference files generated by VSCode editors. | ||
| .vscode/ | ||
| .idea/ |
There was a problem hiding this comment.
@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).
There was a problem hiding this comment.
Same here, keep config changes out of this PR.
| /** | ||
| * 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)); | ||
| } |
There was a problem hiding this comment.
+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. |
There was a problem hiding this comment.
"mask" typically means other things in programming (bit masks, pixel masks, etc.) You might call this "alias" here instead.
@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. |
@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. |
…Subsystem for clarity).
Other changes: