Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void intakeItem(CommandTester commandTester) {

commandTester.runUntilComplete(command);

assertThat(fakeMotor.demand).isWithin(0.01).of(params.intakeDemand());
assertThat(fakeMotor.getDemand()).isWithin(0.01).of(params.intakeDemand());
}
}

Expand Down Expand Up @@ -80,7 +80,7 @@ public void outtakeItem(CommandTester commandTester) {

commandTester.runUntilComplete(command);

assertThat(fakeMotor.demand).isWithin(0.01).of(params.outtakeDemand());
assertThat(fakeMotor.getDemand()).isWithin(0.01).of(params.outtakeDemand());
}
}

Expand All @@ -101,6 +101,6 @@ public void stopAfterOuttakingItem(CommandTester commandTester) {
}

private void assertMotorIsRunning() {
assertThat(fakeMotor.demand).isNotWithin(0.01).of(0.0);
assertThat(fakeMotor.getDemand()).isNotWithin(0.01).of(0.0);
}
}
13 changes: 13 additions & 0 deletions testing/src/main/java/com/team2813/lib2813/testing/FakeMotor.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ public class FakeMotor implements Motor {
public Resistance resistance = Resistance.ofBaseUnits(0.025f, Units.Ohms);
private ControlMode controlMode = ControlMode.VOLTAGE;

/** Gets the most recently applied demand value for this motor. */
public final double getDemand() {
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.

I was wondering the other day, if we want to make the Motor abstraction be a generic that takes the control mode as a template parameter. Then, the getDemand() should return demand in the type that matches the control mode - Position, Velocity, Voltage, etc.

This way, we could potentially prevent improper uses of the demand value (e.g., use a demand value as a voltage, from a motor that has been set up for speed).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@vdikov That's an interesting idea. Perhaps create an issue tracking that?

return demand;
}

/**
* Gets the control mode used for the most recent time the demand value was updated for this
* motor.
*/
public final ControlMode getControlMode() {
return controlMode;
}

/**
* Gets the current voltage being applied to the motor.
*
Expand Down
Loading