Skip to content

Commit

Permalink
ItayKauf - fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Atan504 committed Jun 14, 2024
1 parent 3b2b3f9 commit 87ed6ae
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public static Robot getInstance() {
}

//add subsystems...
public Claw CLAW;
public Claw claw;

public void initSubsystems(HardwareMap hardwareMap) {
// init all subsystems...
this.CLAW = new Claw(hardwareMap);
this.claw = new Claw(hardwareMap);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void toggleLeftClaw() {
}

public void switchClaws() {
Finger switchFinger = rightFinger;
Finger switchFinger = new Finger(rightFinger);
rightFinger = leftFinger;
leftFinger = switchFinger;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,50 @@

class Finger {

private final double fingerOpenPosition;
private final double fingerClosePosition;
private final Servo fingerServo;
private final double openPosition;
private final double closePosition;
private final Servo servo;
private boolean isOpen;

protected Finger(Servo fingerServo, double fingerOpenPosition, double fingerClosePosition) {
this.fingerServo = fingerServo;
this.fingerOpenPosition = fingerOpenPosition;
this.fingerClosePosition = fingerClosePosition;
this.servo = fingerServo;
this.openPosition = fingerOpenPosition;
this.closePosition = fingerClosePosition;
}

protected Finger(Finger other) {
this.servo = other.getServo();
this.openPosition = other.getOpenPosition();
this.closePosition = other.getClosePosition();
}

private void setPosition(double position) {
fingerServo.setPosition(position);
servo.setPosition(position);
}

protected Servo getServo() {
return this.servo;
}

protected double getOpenPosition() {
return this.openPosition;
}

protected double getClosePosition() {
return this.closePosition;
}

protected boolean isOpen() {
return isOpen;
}

protected void openClaw() {
setPosition(fingerOpenPosition);
setPosition(openPosition);
isOpen = true;
}

protected void closeClaw() {
setPosition(fingerClosePosition);
setPosition(closePosition);
isOpen = false;
}

Expand All @@ -36,8 +58,4 @@ protected void toggleClaw() {
openClaw();
}
}

protected boolean isOpen() {
return isOpen;
}
}
}

0 comments on commit 87ed6ae

Please sign in to comment.