diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 7db07fc..6f2c0b9 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -8,6 +8,11 @@
+
+
+
+
+
diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/API.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/API.java
index 35477b1..7e1ecf6 100644
--- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/API.java
+++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/API.java
@@ -3,7 +3,6 @@ package org.firstinspires.ftc.teamcode;
import com.qualcomm.hardware.bosch.BNO055IMU;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.hardware.DcMotor;
-import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.util.ReadWriteFile;
import org.firstinspires.ftc.robotcore.external.navigation.Quaternion;
@@ -13,12 +12,12 @@ import java.io.File;
import java.util.UUID;
public class API {
- private OpMode opMode;
- public HubIMU imu;
- public boolean useLogFile = false;
+ private final OpMode opMode;
+ public final HubIMU imu;
+ public final Gamepad gamepad1;
+ public final Gamepad gamepad2;
+ public final boolean useLogFile;
public File logFile = null;
- public Gamepad gamepad1;
- public Gamepad gamepad2;
/**
* @param mode the opmode to initialize with
@@ -29,8 +28,6 @@ public class API {
print("Initializing API for class " + opMode.getClass().getName() + "...");
-// for (Motor m : Motor.values()) m.init(mode.hardwareMap);
-// for (Servo s : Servo.values()) s.init(mode.hardwareMap);
imu = new HubIMU("imu");
gamepad1 = new Gamepad(GamepadIndex.GAMEPAD1);
gamepad2 = new Gamepad(GamepadIndex.GAMEPAD2);
@@ -94,15 +91,11 @@ public class API {
}
public class Motor {
-// M0("m0"), M1("m1"), M2("m2"), M3("m3"), M4("m4"), M5("m5"), M6("m6"), M7("m7");
-
- private final String name;
- private DcMotor rawMotor;
+ private final DcMotor rawMotor;
private Direction direction = Direction.FORWARD;
private double power = 0;
Motor(String name) {
- this.name = name;
rawMotor = opMode.hardwareMap.get(DcMotor.class, name);
rawMotor.setPower(0);
}
@@ -256,14 +249,11 @@ public class API {
}
public class Servo {
-// S0("s0"), S1("s1"), S2("s2"), S3("s3"), S4("s4"), S5("s5"), S6("s6"), S7("s7"), S8("s8"), S9("s9"), S10("s10"), S11("s11");
- private final String name;
- private com.qualcomm.robotcore.hardware.Servo servo;
+ private final com.qualcomm.robotcore.hardware.Servo servo;
private Direction direction = Direction.FORWARD;
private double power = 0;
Servo(String name) {
- this.name = name;
servo = opMode.hardwareMap.get(com.qualcomm.robotcore.hardware.Servo.class, name);
}
@@ -410,7 +400,7 @@ public class API {
}
public class Gamepad {
- private com.qualcomm.robotcore.hardware.Gamepad gamepad;
+ private final com.qualcomm.robotcore.hardware.Gamepad gamepad;
Gamepad(GamepadIndex index) {
this.gamepad = index == GamepadIndex.GAMEPAD1 ? opMode.gamepad1 : opMode.gamepad2;
diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/AutonFourB.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/AutonFourB.java
index 45ec9df..b75d04d 100644
--- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/AutonFourB.java
+++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/AutonFourB.java
@@ -1,9 +1,8 @@
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
-import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
-@Autonomous(name="Auton 4.2 Blue", preselectTeleOp = "AAAAAAAAA")
+@Autonomous(name="Auton 4.2 Blue", preselectTeleOp = MainOpModeName.name)
public class AutonFourB extends BaseLinearOpMode {
@Override
public void runOpMode() {
diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/AutonFourR.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/AutonFourR.java
index adc886e..f8536b8 100644
--- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/AutonFourR.java
+++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/AutonFourR.java
@@ -1,9 +1,8 @@
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
-import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
-@Autonomous(name="Auton 4.2 Red", preselectTeleOp = "AAAAAAAAA")
+@Autonomous(name="Auton 4.2 Red", preselectTeleOp = MainOpModeName.name)
public class AutonFourR extends BaseLinearOpMode {
@Override
public void runOpMode() {
diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/ExampleReplayer.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/ExampleReplayer.java
index 5b7122f..ba95fdd 100644
--- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/ExampleReplayer.java
+++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/ExampleReplayer.java
@@ -2,7 +2,7 @@ package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
-@Autonomous(name = "Example Replay", preselectTeleOp = "AAAAAAAAA")
+@Autonomous(name = "Example Replay", preselectTeleOp = MainOpModeName.name)
public class ExampleReplayer extends Replayer {
public ExampleReplayer() {
super("recording1.json");
diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GameMotor.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GameMotor.java
index cebbc0e..3b8314f 100644
--- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GameMotor.java
+++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GameMotor.java
@@ -1,15 +1,5 @@
package org.firstinspires.ftc.teamcode;
-//public enum GameMotor {
-// FL(API.Motor.M0), FR(API.Motor.M1), BL(API.Motor.M2), BR(API.Motor.M3), INTAKE(API.Motor.M4), LIFT(API.Motor.M5), CAROUSEL(API.Motor.M6);
-//
-// public final API.Motor m;
-//
-// GameMotor(API.Motor _m) {
-// m = _m;
-// }
-//}
-
public enum GameMotor {
FL("m0"), FR("m1"), BL("m2"), BR("m3"),
INTAKE("m4"), LIFT("m5"), CAROUSEL("m6");
diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GameMotors.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GameMotors.java
index 8a683a1..4a1c335 100644
--- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GameMotors.java
+++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GameMotors.java
@@ -1,13 +1,10 @@
package org.firstinspires.ftc.teamcode;
public class GameMotors {
- private API api;
- public API.Motor fl, fr, bl, br, intake, lift, carousel;
+ public final API.Motor fl, fr, bl, br, intake, lift, carousel;
public GameMotors(API api) {
- this.api = api;
-
fl = api.new Motor(GameMotor.FL.name);
fr = api.new Motor(GameMotor.FR.name);
bl = api.new Motor(GameMotor.BL.name);
diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Gamepad.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Gamepad.java
index da0d253..ccfe361 100644
--- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Gamepad.java
+++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Gamepad.java
@@ -26,7 +26,7 @@ public abstract class Gamepad extends BaseOpMode {
public void loop() {
MovementAPI.move(-gamepad1.left_stick_y, gamepad1.left_stick_x, gamepad1.right_stick_x, speed, true);
- api.print("Speed", speed + ""); // i dont know how to do this better
+ api.print("Speed", speed + ""); // i don't know how to do this better
if (gamepad1.right_bumper) speed = Math.min(speed + 0.01, 1);
else if (gamepad1.left_bumper) speed = Math.max(speed - 0.01, 0.2);
diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GamepadRecord.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GamepadRecord.java
index 2c36649..c9fa944 100644
--- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GamepadRecord.java
+++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/GamepadRecord.java
@@ -18,7 +18,7 @@ public class GamepadRecord extends Gamepad {
private JSONObject outputJSON;
private boolean prevGuide = false;
private int currentIndex = 0;
- private HashMap motors = new HashMap();
+ private HashMap motors = new HashMap<>();
@Override
public void init() {
@@ -52,7 +52,9 @@ public class GamepadRecord extends Gamepad {
JSONObject motorData = new JSONObject();
for (GameMotor m : GameMotor.values()) {
- motorData.put(m.name().toLowerCase(), motors.get(m).getRawPower());
+ //noinspection ConstantConditions
+ double power = motors.get(m).getRawPower();
+ motorData.put(m.name().toLowerCase(), power);
}
JSONObject currentData = new JSONObject()
diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/MainOpModeName.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/MainOpModeName.java
new file mode 100644
index 0000000..6603e77
--- /dev/null
+++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/MainOpModeName.java
@@ -0,0 +1,5 @@
+package org.firstinspires.ftc.teamcode;
+
+public class MainOpModeName {
+ public final static String name = "AAAAAAAAA";
+}
diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/MovementAPI.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/MovementAPI.java
index 557042a..c3bb05e 100644
--- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/MovementAPI.java
+++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/MovementAPI.java
@@ -24,7 +24,7 @@ public class MovementAPI {
public static void init(API api, API.Motor _fl, API.Motor _fr, API.Motor _bl, API.Motor _br) {
MovementAPI.api = api;
- api.print("Initializing Movementapi...");
+ api.print("Initializing MovementApi...");
fl = _fl;
fr = _fr;
diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Replayer.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Replayer.java
index b0e0c7f..a882a0a 100644
--- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Replayer.java
+++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Replayer.java
@@ -11,10 +11,9 @@ import java.util.HashMap;
public class Replayer extends BaseOpMode {
private final String recordingFileName;
- private File recordingFile;
private JSONObject recordingJSON;
private int nextIndex = 0;
- private HashMap motors = new HashMap();
+ private HashMap motors = new HashMap<>();
public Replayer(String fileName) {
this.recordingFileName = fileName;
@@ -27,7 +26,7 @@ public class Replayer extends BaseOpMode {
api.print("Status", "Initializing, please wait");
api.pause(1);
- recordingFile = AppUtil.getInstance().getSettingsFile(recordingFileName);
+ File recordingFile = AppUtil.getInstance().getSettingsFile(recordingFileName);
try {
recordingJSON = new JSONObject(ReadWriteFile.readFile(recordingFile));
} catch (JSONException e) {
@@ -59,6 +58,7 @@ public class Replayer extends BaseOpMode {
if (this.getRuntime() * 1000 < currentListElement.getDouble("time")) return;
for (GameMotor m : GameMotor.values()) {
+ //noinspection ConstantConditions
motors.get(m).start(currentData.has(m.name().toLowerCase()) ? currentData.getDouble(m.name().toLowerCase()) : 0);
}
diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/TotallyGamepaad.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/TotallyGamepaad.java
index 8c49a19..6a19d02 100644
--- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/TotallyGamepaad.java
+++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/TotallyGamepaad.java
@@ -2,5 +2,5 @@ package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
-@TeleOp(name = "AAAAAAAAA")
+@TeleOp(name = MainOpModeName.name)
public class TotallyGamepaad extends Gamepad {}