Skip to content

Commit 98c1bba

Browse files
Create AllignAssist Command (INCOMPLETE)
1 parent 37e3dbf commit 98c1bba

4 files changed

Lines changed: 93 additions & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public void robotInit() {
6060
SmartDashboard.putNumber("Max Acceleration", dt.getMaxSpeed() / 1.0);
6161

6262
SmartDashboard.putBoolean("Outreach Mode", false);
63+
SmartDashboard.putBoolean("Using Limelight", false);
6364
timey = new Timer();
6465
}
6566

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2017-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 frc.robot.lib.Limelight;
11+
import frc.robot.subsystems.Drivetrain;
12+
import edu.wpi.first.wpilibj.command.Command;
13+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
14+
15+
public class AllignAssist extends Command {
16+
private Drivetrain dt;
17+
private Limelight.Mode limelightMode;
18+
19+
public AllignAssist(Drivetrain dt, Limelight.Mode mode) {
20+
this.dt = dt;
21+
this.limelightMode = mode;
22+
}
23+
24+
// Called just before this Command runs the first time
25+
@Override
26+
protected void initialize() {
27+
}
28+
29+
// Called repeatedly when this Command is scheduled to run
30+
@Override
31+
protected void execute() {
32+
if (limelightMode == Limelight.Mode.DIST) {
33+
34+
}
35+
else if (limelightMode == Limelight.Mode.STEER) {
36+
37+
} else {
38+
39+
}
40+
}
41+
42+
// Make this return true when this Command no longer needs to run execute()
43+
@Override
44+
protected boolean isFinished() {
45+
if (!SmartDashboard.getBoolean("Use Limelight", false)) {
46+
return true;
47+
} else {
48+
return false;
49+
}
50+
}
51+
52+
// Called once after isFinished returns true
53+
@Override
54+
protected void end() {
55+
}
56+
57+
// Called when another command which requires one or more of the same
58+
// subsystems is scheduled to run
59+
@Override
60+
protected void interrupted() {
61+
end();
62+
}
63+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.InstantCommand;
11+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
12+
13+
public class ToggleLimelight extends InstantCommand {
14+
public ToggleLimelight() {
15+
}
16+
17+
@Override
18+
protected void initialize() {
19+
if (SmartDashboard.getBoolean("Using Limelight", false)) {
20+
SmartDashboard.putBoolean("Using Limelight", true);
21+
} else {
22+
SmartDashboard.putBoolean("Using Limelight", false);
23+
}
24+
}
25+
}

Robot2019/src/main/java/frc/robot/lib/Limelight.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
1313

1414
public class Limelight {
15+
public enum Mode {
16+
DIST, STEER, TARGET
17+
}
18+
1519
private NetworkTableInstance inst;
1620
private NetworkTable table;
1721
private double tv, tx, ty, ta;

0 commit comments

Comments
 (0)