Skip to content

Added Test and Additional methods to AnglerSubsystem#43

Open
Sahiltheram wants to merge 9 commits intomainfrom
SAT_AnglerEncoderChanges
Open

Added Test and Additional methods to AnglerSubsystem#43
Sahiltheram wants to merge 9 commits intomainfrom
SAT_AnglerEncoderChanges

Conversation

@Sahiltheram
Copy link
Contributor

No description provided.

angler.runToReverseLimit();
if (angler.isAtReverseLimit()) {
angler.resetEncoderToZero();
finished = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably have a timeout of 5 seconds(?) to prevent this from hanging forever if the switch is broken

public static final double ANGLER_LOW_ROTATIONS = -50; //Lowest position of Angler
public static final double ANGLER_HIGH_ROTATIONS = 50; //Highest position of Angler
public static final double ANGLER_FIXED_ROTATIONS = 0.1; //Fixed position of Angler in Fixed ShootState
public static final double ANGLER_HOME_ROTATIONS = 0.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

These comments should not have been removed.

public static final double ANGLER_ENCODER_LOW = 0;
public static final double ANGLER_ENCODER_HIGH = 100;
public static final double ANGLER_ANGLE_LOW = 0;
public static final double ANGLER_ANGLE_HIGH = 45;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have comments about these constants as well


/**
* Gets the desired Angle Position and uses a PID controller to get the motor there
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment about the units the angle is expected to be (@param...)

* Drive toward the forward limit switch and stop once it is pressed.
* Call this repeatedly from a command while homing.
*/
public void runToForwardLimit() {
Copy link
Contributor

Choose a reason for hiding this comment

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

The way this method is written, it is expecting to be called in a loop until the switch is hit - if it only called once, the motor will run forever (well, it will run until the limit switch is hit and the hardware stops the motor).
In this case, I think it is better to just use a "run forward" method, since you rely on the command to repeatedly check the switch and end when it is hit. Sorry if I caused you to do extra work here.
Same for the other method below.

private double calculate(double angle) {
return AnglerSubsystem.calculateRotationsForAngle(
angle,
Constants.ANGLER_ENCODER_HIGH,
Copy link
Contributor

Choose a reason for hiding this comment

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

This would break when the constants change, so you should hardcode test values that will not change with the constants to separate the test code from the real ones.

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.

2 participants