-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
I've been thinking for a while that MotorSubsystem (soon to be named PositionalMotorSubsystem) should not implement Motor or Encoder, for a few reasons:
- It makes the surface area of the API quite large
- It allows code outside of the subsystem to directly interact with the motor (vs having the core robot code use public APIs provided by the subsystem subclass).
Instead, we could add a private static nested class to this class implementing Motor, and Encoder, and put the logic there. MotorSubsystem could have protected methods that allow the subclasses to have direct control. Perhaps:
private final MotorEncoder motorEncoder;
protected final Motor getMotor() {
return motorEncoder;
}
protected final Encoder getEncoder() {
return motorEncoder;
}
private static class MotorEncoder implements Motor, Encoder {
// More code here...
}It would probably still be helpful to have a public method for disabling the motor:
public final Command disableMotorCommand() {
return new InstantCommand(this::disableMotor, this);
}
// Not final, to allow subclasses to do additional things when the subsystem is disabled
protected void disableMotor() {
motorEncoder.disableMotor();
}Metadata
Metadata
Assignees
Labels
No labels