mirror of
https://github.com/TimeCrafters/FreightFrenzy.git
synced 2025-12-15 14:02:34 +00:00
Fixed not set checkTime variable, prevent rare crash do to telemetry iterating over a null object
This commit is contained in:
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.timecrafters.FreightFrenzy.Competition.Autonomous.States;
|
package org.timecrafters.FreightFrenzy.Competition.Autonomous.States;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.qualcomm.robotcore.hardware.DcMotor;
|
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||||
|
|
||||||
import org.cyberarm.engine.V2.CyberarmState;
|
import org.cyberarm.engine.V2.CyberarmState;
|
||||||
@@ -13,8 +15,8 @@ public class TensorFlowState extends CyberarmState {
|
|||||||
Robot robot;
|
Robot robot;
|
||||||
private List<Recognition> recognitions;
|
private List<Recognition> recognitions;
|
||||||
private double checkTime;
|
private double checkTime;
|
||||||
private int manualPath;
|
private int manualPath = 0;
|
||||||
private int path = 0;
|
private int path = 3;
|
||||||
private double leftDuck;
|
private double leftDuck;
|
||||||
private double middleDuck;
|
private double middleDuck;
|
||||||
|
|
||||||
@@ -28,6 +30,7 @@ public class TensorFlowState extends CyberarmState {
|
|||||||
this.armExtension = armExtension;
|
this.armExtension = armExtension;
|
||||||
this.leftDuck = robot.configuration.variable(groupName, actionName, "leftDuck").value();
|
this.leftDuck = robot.configuration.variable(groupName, actionName, "leftDuck").value();
|
||||||
this.middleDuck = robot.configuration.variable(groupName, actionName, "middleDuck").value();
|
this.middleDuck = robot.configuration.variable(groupName, actionName, "middleDuck").value();
|
||||||
|
this.checkTime = robot.configuration.variable(groupName, actionName, "time").value();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -41,23 +44,22 @@ public class TensorFlowState extends CyberarmState {
|
|||||||
recognitions = robot.tensorflowDetections();
|
recognitions = robot.tensorflowDetections();
|
||||||
|
|
||||||
if (runTime() < checkTime) {
|
if (runTime() < checkTime) {
|
||||||
if (manualPath != -1) {
|
if (recognitions != null && recognitions.size() != 0) {
|
||||||
|
if (recognitions.size() == 1) {
|
||||||
|
Recognition recognition = recognitions.get(0);
|
||||||
|
|
||||||
if (recognitions != null) {
|
if (recognition.getLeft() < leftDuck) {
|
||||||
if (recognitions.size() == 1) {
|
path = 0;
|
||||||
Recognition recognition = recognitions.get(0);
|
|
||||||
|
|
||||||
if (recognition.getLeft() < leftDuck) {
|
|
||||||
path = 0;
|
|
||||||
} else {
|
|
||||||
path = 1;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
path = 2;
|
path = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
path = 2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Log.i(TAG, "Choosen path: " + path);
|
||||||
|
|
||||||
if (path == 0){
|
if (path == 0){
|
||||||
addState(new TurretArmExtension(robot, armExtension, groupName, "02_0"));
|
addState(new TurretArmExtension(robot, armExtension, groupName, "02_0"));
|
||||||
addState(new TurretArmRiser(robot, armRiser, groupName, "03_0_bottom"));
|
addState(new TurretArmRiser(robot, armRiser, groupName, "03_0_bottom"));
|
||||||
@@ -72,17 +74,27 @@ public class TensorFlowState extends CyberarmState {
|
|||||||
addState(new TurretArmExtension(robot, armExtension, groupName, "04_0_top"));
|
addState(new TurretArmExtension(robot, armExtension, groupName, "04_0_top"));
|
||||||
}
|
}
|
||||||
|
|
||||||
setHasFinished(true);
|
setHasFinished(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void telemetry() {
|
public void telemetry() {
|
||||||
for (Recognition recognition : robot.tensorflowDetections()) {
|
engine.telemetry.addData("Runtime", runTime());
|
||||||
|
engine.telemetry.addData("Check Time", checkTime);
|
||||||
|
engine.telemetry.addData("Path", path);
|
||||||
|
engine.telemetry.addLine();
|
||||||
|
|
||||||
|
if (recognitions == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Recognition recognition : recognitions) {
|
||||||
engine.telemetry.addData("Label", recognition.getLabel());
|
engine.telemetry.addData("Label", recognition.getLabel());
|
||||||
engine.telemetry.addData("Left", recognition.getLeft());
|
engine.telemetry.addData("Left", recognition.getLeft());
|
||||||
engine.telemetry.addData("Top", recognition.getTop());
|
engine.telemetry.addData("Top", recognition.getTop());
|
||||||
engine.telemetry.addData("Confidence", recognition.getConfidence());
|
engine.telemetry.addData("Confidence", recognition.getConfidence());
|
||||||
|
engine.telemetry.addLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user