-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
640af34
commit 2c85f08
Showing
17 changed files
with
1,162 additions
and
1,163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,65 @@ | ||
package edu.stuy.robot.commands; | ||
|
||
import java.util.Arrays; | ||
|
||
import edu.stuy.robot.Robot; | ||
import edu.stuy.robot.cv.StuyVision; | ||
import edu.wpi.first.wpilibj.command.Command; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
|
||
/** | ||
* | ||
*/ | ||
public class CVReadAndPrintCommand extends Command { | ||
boolean tryToSaveFile; | ||
public CVReadAndPrintCommand() { | ||
// Use requires() here to declare subsystem dependencies | ||
// eg. requires(chassis); | ||
} | ||
public CVReadAndPrintCommand(boolean save) { | ||
// Use requires() here to declare subsystem dependencies | ||
// eg. requires(chassis); | ||
tryToSaveFile = save; | ||
} | ||
|
||
// Called just before this Command runs the first time | ||
protected void initialize() { | ||
try { | ||
long start = System.currentTimeMillis(); | ||
double[] cvReading = null; | ||
cvReading = Robot.vision.processImage(Robot.isDebugModeOn() && tryToSaveFile); | ||
System.out.println("\n\n\n\n\n\n\n\n\n\nprocessImage took " + (System.currentTimeMillis() - start) + "ms"); | ||
System.out.println(new StuyVision.Report(cvReading)); | ||
boolean canProceed = cvReading != null; | ||
SmartDashboard.putString("cv-reading", Arrays.toString(cvReading)); | ||
if (canProceed) { | ||
double desiredAngle = StuyVision.frameXPxToDegrees(cvReading[0]); | ||
SmartDashboard.putNumber("cv-angle", desiredAngle); | ||
System.out.println("Desired Angle Delta: " + desiredAngle); | ||
} | ||
SmartDashboard.putBoolean("cv-visible", canProceed); | ||
} catch (Exception e) { | ||
System.err.println("\n\n\n\nGeneric exception caught in CVReadAndPrintCommand:"); | ||
e.printStackTrace(); | ||
System.err.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); | ||
} | ||
} | ||
|
||
// Called repeatedly when this Command is scheduled to run | ||
protected void execute() { | ||
} | ||
|
||
// Make this return true when this Command no longer needs to run execute() | ||
protected boolean isFinished() { | ||
return true; | ||
} | ||
|
||
// Called once after isFinished returns true | ||
protected void end() { | ||
} | ||
|
||
// Called when another command which requires one or more of the same | ||
// subsystems is scheduled to run | ||
protected void interrupted() { | ||
} | ||
} | ||
//package edu.stuy.robot.commands; | ||
// | ||
//import java.util.Arrays; | ||
// | ||
//import edu.stuy.robot.Robot; | ||
//import edu.stuy.robot.cv.StuyVision; | ||
//import edu.wpi.first.wpilibj.command.Command; | ||
//import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
// | ||
///** | ||
// * | ||
// */ | ||
//public class CVReadAndPrintCommand extends Command { | ||
// boolean tryToSaveFile; | ||
// public CVReadAndPrintCommand() { | ||
// // Use requires() here to declare subsystem dependencies | ||
// // eg. requires(chassis); | ||
// } | ||
// public CVReadAndPrintCommand(boolean save) { | ||
// // Use requires() here to declare subsystem dependencies | ||
// // eg. requires(chassis); | ||
// tryToSaveFile = save; | ||
// } | ||
// | ||
// // Called just before this Command runs the first time | ||
// protected void initialize() { | ||
// try { | ||
// long start = System.currentTimeMillis(); | ||
// double[] cvReading = null; | ||
// cvReading = Robot.vision.processImage(Robot.isDebugModeOn() && tryToSaveFile); | ||
// System.out.println("\n\n\n\n\n\n\n\n\n\nprocessImage took " + (System.currentTimeMillis() - start) + "ms"); | ||
// System.out.println(new StuyVision.Report(cvReading)); | ||
// boolean canProceed = cvReading != null; | ||
// SmartDashboard.putString("cv-reading", Arrays.toString(cvReading)); | ||
// if (canProceed) { | ||
// double desiredAngle = StuyVision.frameXPxToDegrees(cvReading[0]); | ||
// SmartDashboard.putNumber("cv-angle", desiredAngle); | ||
// System.out.println("Desired Angle Delta: " + desiredAngle); | ||
// } | ||
// SmartDashboard.putBoolean("cv-visible", canProceed); | ||
// } catch (Exception e) { | ||
// System.err.println("\n\n\n\nGeneric exception caught in CVReadAndPrintCommand:"); | ||
// e.printStackTrace(); | ||
// System.err.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); | ||
// } | ||
// } | ||
// | ||
// // Called repeatedly when this Command is scheduled to run | ||
// protected void execute() { | ||
// } | ||
// | ||
// // Make this return true when this Command no longer needs to run execute() | ||
// protected boolean isFinished() { | ||
// return true; | ||
// } | ||
// | ||
// // Called once after isFinished returns true | ||
// protected void end() { | ||
// } | ||
// | ||
// // Called when another command which requires one or more of the same | ||
// // subsystems is scheduled to run | ||
// protected void interrupted() { | ||
// } | ||
//} |
68 changes: 34 additions & 34 deletions
68
src/edu/stuy/robot/commands/DriveToCourtyardRangeCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
package edu.stuy.robot.commands; | ||
|
||
import static edu.stuy.robot.RobotMap.COURTYARD_SHOOTING_DISTANCE; | ||
|
||
import edu.stuy.robot.Robot; | ||
import edu.stuy.robot.cv.StuyVision; | ||
|
||
/** | ||
* | ||
*/ | ||
public class DriveToCourtyardRangeCommand extends EncoderDrivingCommand { | ||
|
||
public DriveToCourtyardRangeCommand() { | ||
super(Robot.stopAutoMovement); | ||
// Use requires() here to declare subsystem dependencies | ||
// eg. requires(chassis); | ||
requires(Robot.drivetrain); | ||
} | ||
|
||
protected void setInchesToMove() { | ||
double[] cvReading = Robot.vision.processImage(); | ||
if (cvReading != null) { | ||
double curDistance = StuyVision.findBotDistanceToGoal(cvReading[1]); | ||
initialInchesToMove = curDistance - COURTYARD_SHOOTING_DISTANCE; | ||
} else { | ||
// CV failed! | ||
cancelCommand = true; | ||
} | ||
System.out.println(new StuyVision.Report(cvReading)); | ||
if (cvReading != null) { | ||
System.out.println(StuyVision.findBotDistanceToGoal(cvReading[1])); | ||
} | ||
} | ||
} | ||
//package edu.stuy.robot.commands; | ||
// | ||
//import static edu.stuy.robot.RobotMap.COURTYARD_SHOOTING_DISTANCE; | ||
// | ||
//import edu.stuy.robot.Robot; | ||
//import edu.stuy.robot.cv.StuyVision; | ||
// | ||
///** | ||
// * | ||
// */ | ||
//public class DriveToCourtyardRangeCommand extends EncoderDrivingCommand { | ||
// | ||
// public DriveToCourtyardRangeCommand() { | ||
// super(Robot.stopAutoMovement); | ||
// // Use requires() here to declare subsystem dependencies | ||
// // eg. requires(chassis); | ||
// requires(Robot.drivetrain); | ||
// } | ||
// | ||
// protected void setInchesToMove() { | ||
// double[] cvReading = Robot.vision.processImage(); | ||
// if (cvReading != null) { | ||
// double curDistance = StuyVision.findBotDistanceToGoal(cvReading[1]); | ||
// initialInchesToMove = curDistance - COURTYARD_SHOOTING_DISTANCE; | ||
// } else { | ||
// // CV failed! | ||
// cancelCommand = true; | ||
// } | ||
// System.out.println(new StuyVision.Report(cvReading)); | ||
// if (cvReading != null) { | ||
// System.out.println(StuyVision.findBotDistanceToGoal(cvReading[1])); | ||
// } | ||
// } | ||
//} |
70 changes: 35 additions & 35 deletions
70
src/edu/stuy/robot/commands/DriveToLayupRangeCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
package edu.stuy.robot.commands; | ||
|
||
import static edu.stuy.robot.RobotMap.LAYUP_SHOOTING_DISTANCE; | ||
|
||
import edu.stuy.robot.Robot; | ||
import edu.stuy.robot.cv.StuyVision; | ||
import edu.stuy.util.BoolBox; | ||
|
||
/** | ||
* | ||
*/ | ||
public class DriveToLayupRangeCommand extends EncoderDrivingCommand { | ||
|
||
public DriveToLayupRangeCommand() { | ||
super(Robot.stopAutoMovement); | ||
// Use requires() here to declare subsystem dependencies | ||
// eg. requires(chassis); | ||
requires(Robot.drivetrain); | ||
} | ||
|
||
protected void setInchesToMove() { | ||
double[] cvReading = Robot.vision.processImage(); | ||
if (cvReading != null) { | ||
double curDistance = StuyVision.findBotDistanceToGoal(cvReading[1]); | ||
initialInchesToMove = curDistance - LAYUP_SHOOTING_DISTANCE; | ||
} else { | ||
// CV failed! | ||
cancelCommand = true; | ||
} | ||
System.out.println(new StuyVision.Report(cvReading)); | ||
if (cvReading != null) { | ||
System.out.println(StuyVision.findBotDistanceToGoal(cvReading[1])); | ||
} | ||
} | ||
} | ||
//package edu.stuy.robot.commands; | ||
// | ||
//import static edu.stuy.robot.RobotMap.LAYUP_SHOOTING_DISTANCE; | ||
// | ||
//import edu.stuy.robot.Robot; | ||
//import edu.stuy.robot.cv.StuyVision; | ||
//import edu.stuy.util.BoolBox; | ||
// | ||
///** | ||
// * | ||
// */ | ||
//public class DriveToLayupRangeCommand extends EncoderDrivingCommand { | ||
// | ||
// public DriveToLayupRangeCommand() { | ||
// super(Robot.stopAutoMovement); | ||
// // Use requires() here to declare subsystem dependencies | ||
// // eg. requires(chassis); | ||
// requires(Robot.drivetrain); | ||
// } | ||
// | ||
// protected void setInchesToMove() { | ||
// double[] cvReading = Robot.vision.processImage(); | ||
// if (cvReading != null) { | ||
// double curDistance = StuyVision.findBotDistanceToGoal(cvReading[1]); | ||
// initialInchesToMove = curDistance - LAYUP_SHOOTING_DISTANCE; | ||
// } else { | ||
// // CV failed! | ||
// cancelCommand = true; | ||
// } | ||
// System.out.println(new StuyVision.Report(cvReading)); | ||
// if (cvReading != null) { | ||
// System.out.println(StuyVision.findBotDistanceToGoal(cvReading[1])); | ||
// } | ||
// } | ||
//} |
Oops, something went wrong.