mirror of
https://github.com/Team4388/2019-Hit-or-Miss.git
synced 2026-06-09 00:28:05 -06:00
Finished laser code
laser code and rangefinder subsystem completed and ready to function, but untested
This commit is contained in:
@@ -12,7 +12,14 @@ import org.usfirst.frc4388.robot.Robot;
|
|||||||
import edu.wpi.first.wpilibj.command.Command;
|
import edu.wpi.first.wpilibj.command.Command;
|
||||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||||
|
|
||||||
|
|
||||||
public class LaserToDash extends Command {
|
public class LaserToDash extends Command {
|
||||||
|
String p1 = "";
|
||||||
|
String p2 = "";
|
||||||
|
|
||||||
|
String last1 = "0";
|
||||||
|
String last2 = "0";
|
||||||
|
|
||||||
public LaserToDash() {
|
public LaserToDash() {
|
||||||
// Use requires() here to declare subsystem dependencies
|
// Use requires() here to declare subsystem dependencies
|
||||||
// eg. requires(chassis);
|
// eg. requires(chassis);
|
||||||
@@ -28,19 +35,27 @@ public class LaserToDash extends Command {
|
|||||||
// Called repeatedly when this Command is scheduled to run
|
// Called repeatedly when this Command is scheduled to run
|
||||||
@Override
|
@Override
|
||||||
protected void execute() {
|
protected void execute() {
|
||||||
String p1, p2;
|
|
||||||
try{
|
try{
|
||||||
String toParse = Robot.rangefinder.getDistance();
|
String toParse = Robot.rangefinder.getDistance();
|
||||||
String[] parts = toParse.split("s");
|
String[] parts = toParse.split("s");
|
||||||
p1 = parts[0];
|
p1 = parts[0];
|
||||||
p2 = parts[1];
|
p2 = parts[1];
|
||||||
|
if (!(p1 == "0" || p2 == "0")){
|
||||||
|
SmartDashboard.putNumber("Laser 1 raw out", Double.parseDouble(p1));
|
||||||
|
SmartDashboard.putNumber("Laser 2 raw out", Double.parseDouble(p2));
|
||||||
|
last1 = p1;
|
||||||
|
last2 = p2;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
SmartDashboard.putNumber("Laser 1 raw out", Double.parseDouble(last1));
|
||||||
|
SmartDashboard.putNumber("Laser 2 raw out", Double.parseDouble(last2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(Exception nullException){
|
catch(Exception nullException){
|
||||||
p1 = "0";
|
|
||||||
p2 = "0";
|
|
||||||
}
|
}
|
||||||
SmartDashboard.putNumber("Laser 1 raw out", Double.parseDouble(p1));
|
|
||||||
SmartDashboard.putNumber("Laser 2 raw out", Double.parseDouble(p2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make this return true when this Command no longer needs to run execute()
|
// Make this return true when this Command no longer needs to run execute()
|
||||||
|
|||||||
Reference in New Issue
Block a user