Skip to content

Commit 899cf34

Browse files
SaltyJokebrettle
authored andcommitted
Hatch experimental (#107)
* more competition changes * hatch move back * disable characterized drive
1 parent d5b7abd commit 899cf34

14 files changed

Lines changed: 210 additions & 21 deletions

File tree

Robot2019/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id "java"
3-
id "edu.wpi.first.GradleRIO" version "2019.3.2"
3+
id "edu.wpi.first.GradleRIO" version "2019.4.1"
44
}
55

66
def ROBOT_MAIN_CLASS = "frc.robot.Main"

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
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.ToggleClimberRails;
1514
import frc.robot.commands.Climb;
1615
import frc.robot.commands.EjectCargo;
1716
import frc.robot.commands.GradualDrive;
18-
import frc.robot.commands.ToggleHatchEject;
1917
import frc.robot.commands.IntakeCargo;
20-
import frc.robot.commands.ToggleHatchIntake;
18+
import frc.robot.commands.IntakeHatch;
2119
import frc.robot.commands.ManualClimb;
2220
import frc.robot.commands.NormalDrive;
2321
import frc.robot.commands.ResetWobble;
2422
import frc.robot.commands.SetArcadeOrTank;
2523
import frc.robot.commands.SlowDrive;
2624
import frc.robot.commands.ToggleCamera;
25+
import frc.robot.commands.ToggleClimberRails;
26+
import frc.robot.commands.ToggleHatchEject;
2727
import frc.robot.commands.ToggleLight;
2828
import frc.robot.commands.WobbleDrive;
2929
import frc.robot.subsystems.Cargo;
@@ -74,7 +74,7 @@ public class OI {
7474
gradDriveBtn.whenPressed(new GradualDrive());
7575

7676
hatchIntakeBtn = new JoystickButton(manipulator, Manip.X);
77-
hatchIntakeBtn.whenPressed(new ToggleHatchIntake(hp));
77+
hatchIntakeBtn.whenPressed(new IntakeHatch(hp, dt));
7878
hatchEjectBtn = new JoystickButton(manipulator, Manip.Y);
7979
hatchEjectBtn.whenPressed(new ToggleHatchEject(hp));
8080

@@ -83,13 +83,13 @@ public class OI {
8383
cargoEjectBtn = new JoystickButton(manipulator, Manip.B); // TODO: set ports to correct values
8484
cargoEjectBtn.whenPressed(new EjectCargo(cargo));
8585

86-
climberRailBtn = new JoystickButton(manipulator, Manip.LB_lShoulder);
86+
climberRailBtn = new JoystickButton(manipulator, Manip.RB_rShoulder);
8787
climberRailBtn.whenPressed(new ToggleClimberRails(climber));
8888

89-
autoClimbBtn = new JoystickButton(manipulator, Manip.RT_rTrigger);
89+
autoClimbBtn = new JoystickButton(manipulator, Manip.LT_lTrigger);
9090
autoClimbBtn.toggleWhenPressed(new Climb(climber, dt, leftJoy, lights));
9191

92-
manualClimbBtn = new JoystickButton(manipulator, Manip.LT_lTrigger);
92+
manualClimbBtn = new JoystickButton(manipulator, Manip.RT_rTrigger);
9393
manualClimbBtn.toggleWhenPressed(new ManualClimb(climber, manipulator, lights));
9494

9595
toggleCameraBtn = new JoystickButton(leftJoy, 2);

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import frc.robot.subsystems.Drivetrain;
2020
import frc.robot.subsystems.HatchPanel;
2121
import frc.robot.subsystems.Lights;
22+
import edu.wpi.first.wpilibj.Timer;
2223

2324
public class Robot extends TimedRobot {
2425
private static Drivetrain dt;
@@ -28,6 +29,7 @@ public class Robot extends TimedRobot {
2829
private static Climber climber;
2930
private static Lights lights;
3031
private static String fname1, fname2, fname3, fname4;
32+
private static Timer timey;
3133

3234
@Override
3335
public void robotInit() {
@@ -56,6 +58,8 @@ public void robotInit() {
5658

5759
dt.setDefaultCommand(new TeleopDrive(dt, oi.leftJoy, oi.rightJoy));
5860
SmartDashboard.putNumber("Max Acceleration", dt.getMaxSpeed() / 1.0);
61+
62+
timey = new Timer();
5963
}
6064

6165
/**
@@ -83,15 +87,22 @@ public void disabledPeriodic() {
8387

8488
@Override
8589
public void autonomousInit() {
90+
timey.reset();
91+
timey.start();
92+
hp.grab();
8693
}
8794

8895
@Override
8996
public void autonomousPeriodic() {
9097
Scheduler.getInstance().run();
98+
99+
SmartDashboard.putNumber("Time left", (int) (15 - timey.get() + 1));
91100
}
92101

93102
@Override
94103
public void teleopInit() {
104+
timey.reset();
105+
timey.start();
95106
// This makes sure that the autonomous stops running when
96107
// teleop starts running. If you want the autonomous to
97108
// continue until interrupted by another command, remove
@@ -101,6 +112,8 @@ public void teleopInit() {
101112
@Override
102113
public void teleopPeriodic() {
103114
Scheduler.getInstance().run();
115+
116+
SmartDashboard.putNumber("Time left", (int) (135 - timey.get() + 1));
104117
}
105118

106119
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private static WPI_TalonSRX createConfiguredTalon(int port) {
121121
catchError(tsrx.configPeakCurrentLimit(0, 0));
122122
catchError(tsrx.configPeakCurrentDuration(0, 0));
123123
// 40 Amps is the amp limit of a CIM. lThe PDP has 40 amp circuit breakers,
124-
catchError(tsrx.configContinuousCurrentLimit(40, 0));
124+
catchError(tsrx.configContinuousCurrentLimit(30, 0));
125125
tsrx.enableCurrentLimit(true);
126126
catchError(tsrx.configNeutralDeadband(0.001, 10));
127127
tsrx.setNeutralMode(NeutralMode.Brake);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public GradualDrive() {
2626
// Called once when the command executes
2727
@Override
2828
protected void initialize() {
29-
SmartDashboard.putBoolean("Gradual Drive", !SmartDashboard.getBoolean("Gradual Drive", false));
29+
SmartDashboard.putBoolean("Gradual Drive", !SmartDashboard.getBoolean("Gradual Drive", true));
3030
}
3131

3232
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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.CommandGroup;
11+
import frc.robot.subsystems.Drivetrain;
12+
import frc.robot.subsystems.HatchPanel;
13+
14+
public class IntakeHatch extends CommandGroup {
15+
/**
16+
* Add your docs here.
17+
*/
18+
public IntakeHatch(HatchPanel hp, Drivetrain dt) {
19+
// Add Commands here:
20+
// e.g. addSequential(new Command1());
21+
// addSequential(new Command2());
22+
// these will run in order.
23+
24+
// To run multiple commands at the same time,
25+
// use addParallel()
26+
// e.g. addParallel(new Command1());
27+
// addSequential(new Command2());
28+
// Command1 and Command2 will run in parallel.
29+
30+
// A command group will require all of the subsystems that each member
31+
// would require.
32+
// e.g. if Command1 requires chassis, and Command2 requires arm,
33+
// a CommandGroup containing them would require both the chassis and the
34+
// arm.
35+
addSequential(new ToggleHatchIntake(hp));
36+
addSequential(new WaitTime(dt, 0.25));
37+
addSequential(new MoveBack(dt, 0.25));
38+
}
39+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public class KeepClimber extends Command {
1414
private Climber climber;
1515

16-
private final double retractSpeed = -1;
16+
private final double retractSpeed = 0.25;
1717

1818
public KeepClimber(Climber climber) {
1919
// Use requires() here to declare subsystem dependencies

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class ManualClimb extends Command {
2121
final private double retractDist = 0;
2222
final private double climbDist = 24.46; // In inches
2323

24-
final private int climbJoyAxis = 1;
24+
final private int climbJoyAxis = 3;
2525

2626
public ManualClimb(Climber climber, Joystick manip, Lights lights) {
2727
// Use requires() here to declare subsystem dependencies
@@ -32,6 +32,13 @@ public ManualClimb(Climber climber, Joystick manip, Lights lights) {
3232
this.climber = climber;
3333
this.lights = lights;
3434
this.manip = manip;
35+
36+
if (!SmartDashboard.containsKey("Climber Max Height")) {
37+
SmartDashboard.putNumber("Climber Max Height", 25);
38+
}
39+
if (!SmartDashboard.containsKey("Climber Drive Limit")) {
40+
SmartDashboard.putNumber("Climber Drive Limit", 0);
41+
}
3542
}
3643

3744
// Called just before this Command runs the first time
@@ -53,6 +60,12 @@ protected void execute() {
5360
// } else if (climbSpeed < 0 && climber.getEncDistance() <= retractDist) {
5461
// climbSpeed = 0;
5562
// }
63+
64+
// climber soft stop to prevent bindinng
65+
if (climber.getEncDistance() > SmartDashboard.getNumber("Climber Max Height", 25) && (-climbSpeed) > SmartDashboard.getNumber("Climber Drive Limit", 0)) {
66+
climbSpeed = -SmartDashboard.getNumber("Climber Drive Limit", 0);
67+
}
68+
5669
climber.runClimber(climbSpeed);
5770

5871
double angle = climber.getAngle();
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.Timer;
11+
import edu.wpi.first.wpilibj.command.Command;
12+
import frc.robot.subsystems.Drivetrain;
13+
14+
public class MoveBack extends Command {
15+
Timer tim;
16+
Drivetrain dt;
17+
double time;
18+
public MoveBack(Drivetrain dt, double time) {
19+
// Use requires() here to declare subsystem dependencies
20+
// eg. requires(chassis);
21+
requires(dt);
22+
this.dt = dt;
23+
this.time = time;
24+
}
25+
26+
// Called just before this Command runs the first time
27+
@Override
28+
protected void initialize() {
29+
tim = new Timer();
30+
tim.reset();
31+
tim.start();
32+
}
33+
34+
// Called repeatedly when this Command is scheduled to run
35+
@Override
36+
protected void execute() {
37+
dt.drive(-1, -1);
38+
}
39+
40+
// Make this return true when this Command no longer needs to run execute()
41+
@Override
42+
protected boolean isFinished() {
43+
return tim.get() >= time;
44+
}
45+
46+
// Called once after isFinished returns true
47+
@Override
48+
protected void end() {
49+
}
50+
51+
// Called when another command which requires one or more of the same
52+
// subsystems is scheduled to run
53+
@Override
54+
protected void interrupted() {
55+
}
56+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public NormalDrive() {
2626
// Called once when the command executes
2727
@Override
2828
protected void initialize() {
29-
SmartDashboard.putBoolean("Characterized Drive", !SmartDashboard.getBoolean("Characterized Drive", false));
29+
SmartDashboard.putBoolean("Characterized Drive", false); // !SmartDashboard.getBoolean("Characterized Drive", false));
3030
}
3131

3232
}

0 commit comments

Comments
 (0)