cleanup
This commit is contained in:
parent
aa18b17d29
commit
b9fa9a44ed
|
@ -8,6 +8,11 @@
|
|||
<inspection_tool class="PointlessArithmeticExpression" enabled="false" level="WARNING" enabled_by_default="false">
|
||||
<option name="m_ignoreExpressionsContainingConstants" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="SpellCheckingInspection" enabled="true" level="TYPO" enabled_by_default="true">
|
||||
<option name="processCode" value="false" />
|
||||
<option name="processLiterals" value="true" />
|
||||
<option name="processComments" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="unused" enabled="false" level="WARNING" enabled_by_default="false">
|
||||
<option name="LOCAL_VARIABLE" value="true" />
|
||||
<option name="FIELD" value="true" />
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -18,7 +18,7 @@ public class GamepadRecord extends Gamepad {
|
|||
private JSONObject outputJSON;
|
||||
private boolean prevGuide = false;
|
||||
private int currentIndex = 0;
|
||||
private HashMap<GameMotor, API.Motor> motors = new HashMap();
|
||||
private HashMap<GameMotor, API.Motor> 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()
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package org.firstinspires.ftc.teamcode;
|
||||
|
||||
public class MainOpModeName {
|
||||
public final static String name = "AAAAAAAAA";
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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<GameMotor, API.Motor> motors = new HashMap();
|
||||
private HashMap<GameMotor, API.Motor> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {}
|
||||
|
|
Loading…
Reference in a new issue