GalacticSearch working

Paths need to be drawn and tested
This commit is contained in:
ryan123rudder
2021-03-21 17:29:31 -06:00
parent 2de45da486
commit fd37bacd5a
4 changed files with 44 additions and 47 deletions
+4 -5
View File
@@ -218,11 +218,10 @@ public final class Constants {
//Galactic Search
public static final double searchError = 0.5;
public static final double bothCloseVisibleY = -17.69;
public static final double closeLeftVisibleY = -12.78;
public static final double closeRightVisibleY = -11.77;
public static final double farLeftVisibleX = 1.13;
public static final double farRightVisibleX = 4.47;
public static final double bothCloseHiddenErrorCheckY = -5.29;
public static final double closeLeftVisibleY = -12.57;
public static final double closeRightVisibleY = -11.35;
public static final double farLeftVisibleX = 3.58;
public static final double farRightVisibleX = 7.04;
}
public static final class OIConstants {
@@ -282,9 +282,7 @@ public class RobotContainer {
.whenReleased(new InstantCommand(() -> m_robotLime.limeOff()));
new JoystickButton(m_joystick, 1)
.whenPressed(new IdentifyPath(m_robotLime))
.whenReleased(new InstantCommand(() -> m_robotLime.limeOff()));
//.whileHeld(new RunCommand(() -> System.out.println("pog")));
.whenPressed(new IdentifyPath(m_robotLime));
}
public void buildAutos() {
@@ -12,6 +12,7 @@ import javax.lang.model.util.ElementScanner6;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.CommandBase;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import frc4388.robot.Constants.VisionConstants;
import frc4388.robot.subsystems.LimeLight;
@@ -34,10 +35,8 @@ public class IdentifyPath extends CommandBase {
// Called when the command is initially scheduled.
@Override
public void initialize() {
m_limeLight.limeOn();
path = "";
m_limeLight.changePipeline(1); //Dual Targetting Lowest
//closeVisible = false;
closeVisible = false;
}
// Called every time the scheduler runs while the command is scheduled.
@@ -46,18 +45,18 @@ public class IdentifyPath extends CommandBase {
target = m_limeLight.getV();
xAngle = m_limeLight.getX();
yAngle = m_limeLight.getY();
m_limeLight.limeOn();
//Identify which of four paths
m_limeLight.changePipeline(1);//Dual Targetting Lowest
if (withinError(yAngle, VisionConstants.bothCloseVisibleY) && !closeVisible) //BLUE PATHS
{
closeVisible = true;
}
else if (!withinError(yAngle, VisionConstants.bothCloseVisibleY)&& !closeVisible) // RED PATHS
else if (!withinError(yAngle, VisionConstants.bothCloseVisibleY) && !closeVisible) // RED PATHS
{
closeVisible = false;
}
if (closeVisible)
{
m_limeLight.changePipeline(2); //Dual Targetting Highest
@@ -70,9 +69,9 @@ public class IdentifyPath extends CommandBase {
path = "B_BLUE";
}
}
else
{
//m_limeLight.changePipeline(1); //Dual Targetting Lowest
else{
m_limeLight.changePipeline(1); //Dual Targetting Lowest
if(withinError(yAngle, VisionConstants.closeLeftVisibleY)) //A PATH
{
path = "A_RED";
@@ -83,9 +82,9 @@ public class IdentifyPath extends CommandBase {
}
}
System.out.println(path);
SmartDashboard.putString("GalacticSearchPath", path);
SmartDashboard.putBoolean("CloseVisible", closeVisible);
System.out.println("If you see this message a bunch of times in a row, IdentifyPath.java is stuck trying to find the path for GalacticSearch");
System.out.println(path);
}
@@ -112,6 +111,7 @@ public class IdentifyPath extends CommandBase {
{
SmartDashboard.putString("GalacticSearchPath", path);
m_limeLight.galacticSearchPath = path;
m_limeLight.limeOff();
return true;
}
return false;
@@ -21,8 +21,8 @@ public class LimeLight extends SubsystemBase {
}
public void limeOff(){
NetworkTableInstance.getDefault().getTable("limelight").getEntry("camMode").setNumber(1);
NetworkTableInstance.getDefault().getTable("limelight").getEntry("ledMode").setNumber(0);
NetworkTableInstance.getDefault().getTable("limelight").getEntry("camMode").setNumber(0);
NetworkTableInstance.getDefault().getTable("limelight").getEntry("ledMode").setNumber(1);
}
public void limeOn(){