Skip to content

Commit

Permalink
Merge branch 'main' of github.com:StuyPulse/BigWang
Browse files Browse the repository at this point in the history
  • Loading branch information
BenG49 committed Feb 2, 2024
2 parents 32923ab + 68cbae6 commit 91e3681
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/main/java/com/stuypulse/robot/constants/Ports.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public interface Climber {
int LEFT_MOTOR = 60;
int RIGHT_MOTOR = 61;

int TOP_RIGHT_LIMIT = 8;
int TOP_LEFT_LIMIT = 7;
int BOTTOM_RIGHT_LIMIT = 6;
int BOTTOM_LEFT_LIMIT = 5;
int TOP_RIGHT_LIMIT = 9;
int TOP_LEFT_LIMIT = 8;
int BOTTOM_RIGHT_LIMIT = 7;
int BOTTOM_LEFT_LIMIT = 6;
}

public interface Amper {
Expand All @@ -29,6 +29,7 @@ public interface Amper {

int ALIGNED_BUMP_SWITCH = 3;
int LIFT_BOTTOM_LIMIT = 4;
int LIFT_TOP_LIMIT = 5;
int AMP_IR = 2;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public final double getTargetHeight() {
public abstract void stopRoller();

public abstract boolean liftAtBottom();
public abstract boolean liftAtTop();
public abstract double getLiftHeight();
public abstract void stopLift();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class AmperImpl extends Amper {

private final DigitalInput alignedSwitch;
private final DigitalInput minSwitch;
private final DigitalInput maxSwitch;
private final DigitalInput ampIRSensor;

private final Controller controller;
Expand All @@ -38,6 +39,7 @@ public AmperImpl() {

alignedSwitch = new DigitalInput(Ports.Amper.ALIGNED_BUMP_SWITCH);
minSwitch = new DigitalInput(Ports.Amper.LIFT_BOTTOM_LIMIT);
maxSwitch = new DigitalInput(Ports.Amper.LIFT_TOP_LIMIT);
ampIRSensor = new DigitalInput(Ports.Amper.AMP_IR);

Motors.Amper.LIFT_MOTOR.configure(liftMotor);
Expand All @@ -61,6 +63,11 @@ public boolean liftAtBottom() {
return !minSwitch.get();
}

@Override
public boolean liftAtTop() {
return !maxSwitch.get();
}

@Override
public double getLiftHeight() {
return liftEncoder.getPosition();
Expand Down Expand Up @@ -97,7 +104,7 @@ public void periodic() {

controller.update(getTargetHeight(), getLiftHeight());

if (liftAtBottom() && controller.getOutput() < 0) {
if (liftAtBottom() && controller.getOutput() < 0 || liftAtTop() && controller.getOutput() > 0) {
stopLift();
} else {
liftMotor.setVoltage(controller.getOutput());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public boolean liftAtBottom() {
return sim.hasHitLowerLimit();
}

@Override
public boolean liftAtTop() {
return sim.hasHitUpperLimit();
}

@Override
public boolean touchingAmp() {
return false;
Expand All @@ -84,7 +89,7 @@ public void periodic() {

controller.update(getTargetHeight(), getLiftHeight());

if (liftAtBottom() && controller.getOutput() < 0) {
if (liftAtBottom() && controller.getOutput() < 0 || liftAtTop() && controller.getOutput() > 0) {
stopLift();
} else {
sim.setInputVoltage(controller.getOutput());
Expand Down

0 comments on commit 91e3681

Please sign in to comment.