mirror of
https://github.com/TimeCrafters/FTC_2022
synced 2025-12-16 10:02:34 +00:00
Vision in autonomous is added to init
This commit is contained in:
@@ -11,6 +11,7 @@ public class ConeIdentification extends CyberarmState {
|
|||||||
private int time;
|
private int time;
|
||||||
private float minimumConfidence;
|
private float minimumConfidence;
|
||||||
private int ParkPlace;
|
private int ParkPlace;
|
||||||
|
long initTime;
|
||||||
|
|
||||||
public ConeIdentification(PhoenixBot1 robot, String groupName, String actionName) {
|
public ConeIdentification(PhoenixBot1 robot, String groupName, String actionName) {
|
||||||
this.robot = robot;
|
this.robot = robot;
|
||||||
@@ -22,6 +23,7 @@ public class ConeIdentification extends CyberarmState {
|
|||||||
public void init() {
|
public void init() {
|
||||||
engine.blackboard.put("parkPlace", "1");
|
engine.blackboard.put("parkPlace", "1");
|
||||||
robot.tfod.activate();
|
robot.tfod.activate();
|
||||||
|
initTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -47,21 +49,33 @@ public class ConeIdentification extends CyberarmState {
|
|||||||
engine.telemetry.addData("- Position (Row/Col)","%.0f / %.0f", row, col);
|
engine.telemetry.addData("- Position (Row/Col)","%.0f / %.0f", row, col);
|
||||||
engine.telemetry.addData("- Size (Width/Height)","%.0f / %.0f", width, height);
|
engine.telemetry.addData("- Size (Width/Height)","%.0f / %.0f", width, height);
|
||||||
|
|
||||||
if (recognition.getLabel().equals("Red 2")) {
|
if (recognition.getLabel().equals("2 Bulb")) {
|
||||||
engine.telemetry.addData("Red 2", engine.blackboard.put("parkPlace", "2"));
|
engine.telemetry.addData("2 Bulb", engine.blackboard.put("parkPlace", "2"));
|
||||||
} else if (recognition.getLabel().equals("Blue 3")) {
|
} else if (recognition.getLabel().equals("3 Panel")) {
|
||||||
engine.telemetry.addData("Blue 3",engine.blackboard.put("parkPlace", "3"));
|
engine.telemetry.addData("3 Panel",engine.blackboard.put("parkPlace", "3"));
|
||||||
} else {
|
} else {
|
||||||
engine.telemetry.addData("Yellow 1", engine.blackboard.put("parkPlace", "1"));
|
engine.telemetry.addData("1 Bolt", engine.blackboard.put("parkPlace", "1"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
long startTime = System.currentTimeMillis() - initTime;
|
||||||
|
if (startTime < time){
|
||||||
|
time = (int) (time - startTime);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
time = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exec() {
|
public void exec() {
|
||||||
|
|
||||||
|
|
||||||
if (robot.tfod != null) {
|
if (robot.tfod != null) {
|
||||||
// getUpdatedRecognitions() will return null if no new information is available since
|
// getUpdatedRecognitions() will return null if no new information is available since
|
||||||
// the last time that call was made.
|
// the last time that call was made.
|
||||||
@@ -75,9 +89,9 @@ public class ConeIdentification extends CyberarmState {
|
|||||||
if (recognition.getConfidence() >= minimumConfidence && recognition.getConfidence() > bestConfidence) {
|
if (recognition.getConfidence() >= minimumConfidence && recognition.getConfidence() > bestConfidence) {
|
||||||
bestConfidence = recognition.getConfidence();
|
bestConfidence = recognition.getConfidence();
|
||||||
|
|
||||||
if (recognition.getLabel().equals("Red 2")) {
|
if (recognition.getLabel().equals("2 Bulb")) {
|
||||||
engine.blackboard.put("parkPlace", "2");
|
engine.blackboard.put("parkPlace", "2");
|
||||||
} else if (recognition.getLabel().equals("Blue 3")) {
|
} else if (recognition.getLabel().equals("3 Panel")) {
|
||||||
engine.blackboard.put("parkPlace", "3");
|
engine.blackboard.put("parkPlace", "3");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -19,12 +19,15 @@ import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersConfig
|
|||||||
|
|
||||||
public class PhoenixBot1 {
|
public class PhoenixBot1 {
|
||||||
|
|
||||||
private static final String TFOD_MODEL_ASSET = "22-23_PowerPlay_Colors.tflite";
|
// private static final String TFOD_MODEL_ASSET = "22-23_PowerPlay_Colors.tflite";
|
||||||
|
private static final String TFOD_MODEL_ASSET = "PowerPlay.tflite";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static final String[] LABELS = {
|
private static final String[] LABELS = {
|
||||||
"Yellow 1",
|
"1 Bolt",
|
||||||
"Red 2",
|
"2 Bulb",
|
||||||
"Blue 3"
|
"3 Panel"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final String VUFORIA_KEY =
|
private static final String VUFORIA_KEY =
|
||||||
|
|||||||
Reference in New Issue
Block a user