Skip to content

Commit 8cd54cb

Browse files
Merge branch 'master' of https://github.com/FRC1519/2020-Robot
2 parents 2d86cbe + 24047d6 commit 8cd54cb

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

src/main/java/org/mayheminc/robot2020/commands/AirCompressorDefault.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import edu.wpi.first.wpilibj2.command.CommandBase;
1313

1414
public class AirCompressorDefault extends CommandBase {
15+
boolean value;
16+
1517
/**
1618
* Creates a new AirCompressorDefault.
1719
*/
@@ -20,11 +22,18 @@ public AirCompressorDefault() {
2022
addRequirements(RobotContainer.compressor);
2123
}
2224

25+
public AirCompressorDefault(boolean b) {
26+
// Use addRequirements() here to declare subsystem dependencies.
27+
addRequirements(RobotContainer.compressor);
28+
value = b;
29+
30+
}
31+
2332
// Called when the command is initially scheduled.
2433
@Override
2534
public void initialize() {
2635
// robot.is
27-
RobotContainer.compressor.setCompressor(true);
36+
RobotContainer.compressor.setCompressor(value);
2837
}
2938

3039
// Called every time the scheduler runs while the command is scheduled.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2019 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 org.mayheminc.robot2020.commands;
9+
10+
import org.mayheminc.robot2020.RobotContainer;
11+
12+
import edu.wpi.first.wpilibj2.command.InstantCommand;
13+
14+
public class AirCompressorPause extends InstantCommand {
15+
/**
16+
* Creates a new AirCompressorSet.
17+
*/
18+
public AirCompressorPause() {
19+
// Use addRequirements() here to declare subsystem dependencies.
20+
addRequirements(RobotContainer.compressor);
21+
}
22+
23+
// Called when the command is initially scheduled.
24+
@Override
25+
public void initialize() {
26+
RobotContainer.compressor.setCompressor(false);
27+
}
28+
29+
}

src/main/java/org/mayheminc/robot2020/subsystems/AirCompressor.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
package org.mayheminc.robot2020.subsystems;
99

1010
import edu.wpi.first.wpilibj.Compressor;
11+
import edu.wpi.first.wpilibj.Timer;
1112
import edu.wpi.first.wpilibj2.command.SubsystemBase;
1213

1314
public class AirCompressor extends SubsystemBase {
1415
Compressor compressor = new Compressor();
16+
Timer m_Timer = new Timer();
1517

1618
/**
1719
* Creates a new compressor.
@@ -21,17 +23,25 @@ public AirCompressor() {
2123
setCompressor(true);
2224
}
2325

26+
final double COPRESSOR_PAUSE_TIME = 10.0;
27+
2428
public void setCompressor(boolean b) {
2529
// b = false;
2630
if (b) {
2731
compressor.start();
2832
} else {
2933
compressor.stop();
34+
m_Timer.start();
3035
}
3136
}
3237

3338
@Override
3439
public void periodic() {
3540
// This method will be called once per scheduler run
41+
42+
// if the timer expires, turn on the compressor.
43+
if (m_Timer.hasPeriodPassed(COPRESSOR_PAUSE_TIME)) {
44+
setCompressor(true);
45+
}
3646
}
3747
}

src/main/java/org/mayheminc/robot2020/subsystems/Chimney.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313

1414
import org.mayheminc.robot2020.Constants;
1515
import org.mayheminc.util.MayhemTalonSRX;
16+
import org.mayheminc.util.RangeFinder_GP2D120;
1617

1718
import edu.wpi.first.wpilibj.Victor;
1819
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
1920
import edu.wpi.first.wpilibj2.command.SubsystemBase;
2021

2122
public class Chimney extends SubsystemBase {
2223
private final VictorSPX chimneyTalon = new VictorSPX(Constants.Talon.MAGAZINE_CHIMNEY);
24+
private final RangeFinder_GP2D120 frontIR = new RangeFinder_GP2D120(2, 0);
25+
private final RangeFinder_GP2D120 middleIR = new RangeFinder_GP2D120(3, 0);
2326

2427
/**
2528
* Creates a new Chimney.
@@ -41,11 +44,15 @@ public void periodic() {
4144
// This method will be called once per scheduler run
4245
updateSmartDashboard();
4346
monitorTurntableMovement();
47+
frontIR.periodic();
48+
middleIR.periodic();
4449
}
4550

4651
void updateSmartDashboard() {
4752
SmartDashboard.putNumber("Chimney Speed", chimneyTalon.getMotorOutputPercent());
4853
// SmartDashboard.putNumber("Chimney Current", chimneyTalon.getStatorCurrent());
54+
SmartDashboard.putBoolean("Chimney FrontIR", frontIR.isObjectClose());
55+
SmartDashboard.putBoolean("Chimney MidddleIR", middleIR.isObjectClose());
4956
}
5057

5158
void monitorTurntableMovement() {
@@ -54,4 +61,12 @@ void monitorTurntableMovement() {
5461
public void setChimneySpeed(double speed) {
5562
chimneyTalon.set(ControlMode.PercentOutput, speed);
5663
}
64+
65+
public boolean isBallInFrontOfChimney() {
66+
return frontIR.isObjectClose();
67+
}
68+
69+
public boolean isBallInMiddleOfChimney() {
70+
return middleIR.isObjectClose();
71+
}
5772
}

0 commit comments

Comments
 (0)