Skip to content

Commit e7fc62f

Browse files
SaltyJokebrettle
authored andcommitted
Fix angles for climbing (#94)
* Fix angles for climbing * Change climber piston ports * Use atan for climber angle * use pitch instead of accel calculations * change rails to toggle
1 parent 8e9737e commit e7fc62f

3 files changed

Lines changed: 13 additions & 15 deletions

File tree

Robot2019/src/main/java/frc/robot/OI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import edu.wpi.cscore.VideoSink;
1212
import edu.wpi.first.wpilibj.Joystick;
1313
import edu.wpi.first.wpilibj.buttons.JoystickButton;
14-
import frc.robot.commands.ActuateClimberRails;
14+
import frc.robot.commands.ToggleClimberRails;
1515
import frc.robot.commands.Climb;
1616
import frc.robot.commands.EjectCargo;
1717
import frc.robot.commands.ToggleHatchEject;
@@ -80,7 +80,7 @@ public class OI {
8080
cargoEjectBtn.whenPressed(new EjectCargo(cargo));
8181

8282
climberRailBtn = new JoystickButton(manipulator, Manip.LB_lShoulder);
83-
climberRailBtn.whenPressed(new ActuateClimberRails(climber));
83+
climberRailBtn.whenPressed(new ToggleClimberRails(climber));
8484

8585
autoClimbBtn = new JoystickButton(manipulator, Manip.RT_rTrigger);
8686
autoClimbBtn.toggleWhenPressed(new Climb(climber, dt, leftJoy));

Robot2019/src/main/java/frc/robot/commands/ActuateClimberRails.java renamed to Robot2019/src/main/java/frc/robot/commands/ToggleClimberRails.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import edu.wpi.first.wpilibj.command.InstantCommand;
44
import frc.robot.subsystems.Climber;
55

6-
public class ActuateClimberRails extends InstantCommand {
6+
public class ToggleClimberRails extends InstantCommand {
77
private Climber climber;
88

9-
public ActuateClimberRails(Climber cl) {
9+
public ToggleClimberRails(Climber cl) {
1010
super();
1111
requires(cl);
1212
climber = cl;
@@ -15,6 +15,6 @@ public ActuateClimberRails(Climber cl) {
1515
// Called once when the command executes
1616
@Override
1717
protected void initialize() {
18-
climber.actuateRails();
18+
climber.toggleRails();
1919
}
2020
}

Robot2019/src/main/java/frc/robot/subsystems/Climber.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import edu.wpi.first.wpilibj.Encoder;
1414
import edu.wpi.first.wpilibj.VictorSP;
1515
import edu.wpi.first.wpilibj.command.Subsystem;
16+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
1617
import frc.robot.commands.KeepClimber;
1718

1819
public class Climber extends Subsystem {
@@ -40,8 +41,12 @@ public Climber(VictorSP motor, Encoder enc, AHRS ahrs, DoubleSolenoid pistons) {
4041
enc.reset();
4142
}
4243

43-
public void actuateRails() {
44-
pistons.set(DoubleSolenoid.Value.kForward);
44+
public void toggleRails() {
45+
if (pistons.get() == DoubleSolenoid.Value.kForward) {
46+
pistons.set(DoubleSolenoid.Value.kReverse);
47+
} else {
48+
pistons.set(DoubleSolenoid.Value.kForward);
49+
}
4550
}
4651

4752
public void runClimber(double speed) {
@@ -53,14 +58,7 @@ public void stopClimber() {
5358
}
5459

5560
public double getAngle() {
56-
double rawAngle = Math.atan2(ahrs.getRawAccelZ(), ahrs.getRawAccelX());
57-
double angle;
58-
if (rawAngle > 0) {
59-
angle = rawAngle - Math.PI;
60-
} else {
61-
angle = rawAngle + Math.PI;
62-
}
63-
return angle * 180 / Math.PI;
61+
return ahrs.getPitch();
6462
}
6563

6664
//We are erring on the side of changing directions too much

0 commit comments

Comments
 (0)