Skip to content

Commit 881c17f

Browse files
Merge pull request #62 from Spectrum3847/Vision-Clean-Up
Deleted some duplicate methods in Vision
2 parents 7f6a0fe + 53cee25 commit 881c17f

File tree

1 file changed

+4
-89
lines changed

1 file changed

+4
-89
lines changed

src/main/java/frc/robot/vision/Vision.java

+4-89
Original file line numberDiff line numberDiff line change
@@ -366,66 +366,7 @@ public void setLimelightPipelines(int pipeline) {
366366
limelight.setLimelightPipeline(pipeline);
367367
}
368368
}
369-
370-
// ------------------------------------------------------------------------------
371-
// Config
372-
// ------------------------------------------------------------------------------
373-
374-
/**
375-
* CommandConfig used to create a PIDController and for vision commands using other subsystems
376-
* (i.e. swerve)
377-
*/
378-
public static class CommandConfig {
379-
public double kp;
380-
public double tolerance;
381-
public double maxOutput;
382-
public double error;
383-
public int pipelineIndex;
384-
public Limelight limelight;
385-
/* For Drive-To commands */
386-
public CommandConfig alignCommand;
387-
public double verticalSetpoint; // numbers get small as the cone gets closer
388-
public double verticalMaxView;
389-
390-
public void configKp(double kp) {
391-
this.kp = kp;
392-
}
393-
394-
public void configTolerance(double tolerance) {
395-
this.tolerance = tolerance;
396-
}
397-
398-
public void configMaxOutput(double maxOutput) {
399-
this.maxOutput = maxOutput;
400-
}
401-
402-
public void configError(double error) {
403-
this.error = error;
404-
}
405-
406-
public void configPipelineIndex(int pipelineIndex) {
407-
this.pipelineIndex = pipelineIndex;
408-
}
409-
410-
public void configLimelight(Limelight limelight) {
411-
this.limelight = limelight;
412-
}
413-
414-
public void configVerticalSetpoint(double verticalSetpoint) {
415-
this.verticalSetpoint = verticalSetpoint;
416-
}
417-
418-
public void configVerticalMaxView(double verticalMaxView) {
419-
this.verticalMaxView = verticalMaxView;
420-
}
421-
422-
public void configAlignCommand(CommandConfig alignCommand) {
423-
this.alignCommand = alignCommand;
424-
}
425-
426-
public CommandConfig() {}
427-
}
428-
369+
429370
// ------------------------------------------------------------------------------
430371
// Calculation Functions
431372
// ------------------------------------------------------------------------------
@@ -483,7 +424,7 @@ public double getReefTagAngle() {
483424
}
484425

485426
public double getAdjustedThetaToReefFace() {
486-
int closestReefFace = closestReefFace();
427+
int closestReefFace = (int) frontLL.getClosestTagID();
487428
double[][] reefBlueAngles = {
488429
{17, 60}, {18, 0}, {19, -60}, {20, -120}, {21, 180}, {22, 120}
489430
}; // values in theta
@@ -517,33 +458,7 @@ public double getAdjustedThetaToReefFace() {
517458
return -1; // no reef tag found
518459
}
519460

520-
public int closestReefFace() {
521-
double[] reefdistance = getDistanceToReefFromRobot();
522-
if (reefdistance[0] > -1) {
523-
RawFiducial[] tags = frontLL.getRawFiducial();
524-
if (Field.isRed()) {
525-
int closestReef = tags[0].id;
526-
for (RawFiducial tag : tags) {
527-
if (tag.distToRobot < tags[closestReef].distToRobot) {
528-
closestReef = tag.id;
529-
}
530-
}
531-
Telemetry.print("Closest Reef Face: " + closestReef, PrintPriority.HIGH);
532-
return closestReef; // red reef tag
533-
} else {
534-
int closestReef = tags[0].id;
535-
for (RawFiducial tag : tags) {
536-
if (tag.distToRobot < tags[closestReef].distToRobot) {
537-
closestReef = tag.id;
538-
}
539-
}
540-
Telemetry.print("Closest Reef Face: " + closestReef, PrintPriority.HIGH);
541-
return closestReef; // blue reef tag
542-
}
543-
}
544-
Telemetry.print("No reef tag found", PrintPriority.HIGH);
545-
return -1; // no reef tag found
546-
}
461+
547462

548463
/** Returns the distance from the reef in meters, adjusted for the robot's movement. */
549464
public double[] getDistanceToReefFromRobot() {
@@ -590,7 +505,7 @@ public double[] getDistanceToReefFromRobot() {
590505
*/
591506
public Translation2d getAdjustedReefPos() {
592507

593-
int reefID = closestReefFace(); // must call closestReefFace before this method gets passed
508+
int reefID = (int) frontLL.getClosestTagID(); // must call closestReefFace before this method gets passed
594509
Pose2d[] reefFaces = Field.Reef.getCenterFaces();
595510
double NORM_FUDGE = 0.075;
596511
// double tunableNoteVelocity = 1;

0 commit comments

Comments
 (0)