Skip to content

Commit 296f924

Browse files
kevinzwangbrettle
authored andcommitted
Climber changes during Sac Day 1 (#105)
* Fix angles for climbing * Use atan for climber angle * use pitch instead of accel calculations * change rails to toggle * changes to controls requested by drive team * lol * change slow climb formula the goal of this new formula is to find a set voltage/joystick value where the robot will be more or less supported statically by the elevator, and use that as the neutral value of the manipulator
1 parent dd37878 commit 296f924

3 files changed

Lines changed: 70 additions & 10 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import frc.robot.commands.IntakeHatch;
1919
import frc.robot.commands.ManualClimb;
2020
import frc.robot.commands.NormalDrive;
21+
import frc.robot.commands.SlowClimb;
2122
import frc.robot.commands.ResetWobble;
2223
import frc.robot.commands.SetArcadeOrTank;
2324
import frc.robot.commands.SlowDrive;
@@ -48,6 +49,7 @@ public class OI {
4849
JoystickButton climberRailBtn;
4950
JoystickButton autoClimbBtn;
5051
JoystickButton manualClimbBtn;
52+
JoystickButton slowClimbBtn;
5153
JoystickButton toggleCameraBtn;
5254
JoystickButton wobbleDriveBtn;
5355
JoystickButton cycleLightBtn;
@@ -92,6 +94,10 @@ public class OI {
9294
manualClimbBtn = new JoystickButton(manipulator, Manip.RT_rTrigger);
9395
manualClimbBtn.toggleWhenPressed(new ManualClimb(climber, manipulator, lights));
9496

97+
98+
slowClimbBtn = new JoystickButton(manipulator, Manip.LB_lShoulder);
99+
slowClimbBtn.whileHeld(new SlowClimb());
100+
95101
toggleCameraBtn = new JoystickButton(leftJoy, 2);
96102
toggleCameraBtn.whenPressed(new ToggleCamera(driveCamera, hatchCamera, cameraServer));
97103

Robot2019/src/main/java/frc/robot/commands/ManualClimb.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public ManualClimb(Climber climber, Joystick manip, Lights lights) {
3939
if (!SmartDashboard.containsKey("Climber Drive Limit")) {
4040
SmartDashboard.putNumber("Climber Drive Limit", 0);
4141
}
42+
if (!SmartDashboard.containsKey("Slow Climb Neutral")) {
43+
SmartDashboard.putNumber("Slow Climb Neutral", -0.5);
44+
}
4245
}
4346

4447
// Called just before this Command runs the first time
@@ -56,16 +59,22 @@ protected void execute() {
5659
if (!SmartDashboard.getBoolean("Outreach Mode", false)) {
5760
double climbSpeed = manip.getRawAxis(climbJoyAxis);
5861

59-
// if (climbSpeed > 0 && climber.getEncDistance() >= climbDist) {
60-
// climbSpeed = 0;
61-
// } else if (climbSpeed < 0 && climber.getEncDistance() <= retractDist) {
62-
// climbSpeed = 0;
63-
// }
64-
65-
// climber soft stop to prevent bindinng
66-
if (climber.getEncDistance() > SmartDashboard.getNumber("Climber Max Height", 25) && (-climbSpeed) > SmartDashboard.getNumber("Climber Drive Limit", 0)) {
67-
climbSpeed = -SmartDashboard.getNumber("Climber Drive Limit", 0);
68-
}
62+
if (SmartDashboard.getBoolean("Slow Climb", false)) {
63+
double neutral = SmartDashboard.getNumber("Slow Climb Neutral", -0.5);
64+
// this part doesn't make any immediate intuitive sense but trust me it is the correct formula
65+
climbSpeed = climbSpeed * (1 + neutral) + neutral;
66+
}
67+
68+
// if (climbSpeed > 0 && climber.getEncDistance() >= climbDist) {
69+
// climbSpeed = 0;
70+
// } else if (climbSpeed < 0 && climber.getEncDistance() <= retractDist) {
71+
// climbSpeed = 0;
72+
// }
73+
74+
// climber soft stop to prevent bindinng
75+
if (climber.getEncDistance() > SmartDashboard.getNumber("Climber Max Height", 25) && (-climbSpeed) > SmartDashboard.getNumber("Climber Drive Limit", 0)) {
76+
climbSpeed = -SmartDashboard.getNumber("Climber Drive Limit", 0);
77+
}
6978

7079
climber.runClimber(climbSpeed);
7180

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package frc.robot.commands;
9+
10+
import edu.wpi.first.wpilibj.command.Command;
11+
12+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
13+
14+
/**
15+
* Add your docs here.
16+
*/
17+
public class SlowClimb extends Command {
18+
/**
19+
* Add your docs here.
20+
*/
21+
public SlowClimb() {
22+
super();
23+
// Use requires() here to declare subsystem dependencies
24+
// eg. requires(chassis);
25+
}
26+
27+
// Called once when the command executes
28+
@Override
29+
protected void initialize() {
30+
SmartDashboard.putBoolean("Slow Climb", true);
31+
}
32+
33+
@Override
34+
protected void end() {
35+
SmartDashboard.putBoolean("Slow Climb", false);
36+
}
37+
38+
@Override
39+
protected void interrupted() {
40+
end();
41+
}
42+
43+
@Override
44+
protected boolean isFinished() { return false; }
45+
}

0 commit comments

Comments
 (0)