diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOmniOpMode_Linear.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOmniOpMode_Linear.java index 1d14dfb7..d4ef9afb 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOmniOpMode_Linear.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOmniOpMode_Linear.java @@ -68,7 +68,7 @@ public class BasicOmniOpMode_Linear extends LinearOpMode { // Declare OpMode members for each of the 4 motors. - private ElapsedTime runtime = new ElapsedTime(); + private final ElapsedTime runtime = new ElapsedTime(); private DcMotor leftFrontDrive = null; private DcMotor leftBackDrive = null; private DcMotor rightFrontDrive = null; diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOpMode_Iterative.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOpMode_Iterative.java index 6504e58a..62b6db6b 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOpMode_Iterative.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOpMode_Iterative.java @@ -55,7 +55,7 @@ public class BasicOpMode_Iterative extends OpMode { // Declare OpMode members. - private ElapsedTime runtime = new ElapsedTime(); + private final ElapsedTime runtime = new ElapsedTime(); private DcMotor leftDrive = null; private DcMotor rightDrive = null; diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOpMode_Linear.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOpMode_Linear.java index ab0bb254..82ef68ca 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOpMode_Linear.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOpMode_Linear.java @@ -55,7 +55,7 @@ public class BasicOpMode_Linear extends LinearOpMode { // Declare OpMode members. - private ElapsedTime runtime = new ElapsedTime(); + private final ElapsedTime runtime = new ElapsedTime(); private DcMotor leftDrive = null; private DcMotor rightDrive = null; diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptAprilTagOptimizeExposure.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptAprilTagOptimizeExposure.java index adee952b..a3d23467 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptAprilTagOptimizeExposure.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptAprilTagOptimizeExposure.java @@ -198,7 +198,7 @@ private boolean setManualExposure(int exposureMS, int gain) { exposureControl.setMode(ExposureControl.Mode.Manual); sleep(50); } - exposureControl.setExposure((long)exposureMS, TimeUnit.MILLISECONDS); + exposureControl.setExposure(exposureMS, TimeUnit.MILLISECONDS); sleep(20); // Set Gain. diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptExternalHardwareClass.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptExternalHardwareClass.java index 7a721fef..8dc6537b 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptExternalHardwareClass.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptExternalHardwareClass.java @@ -103,9 +103,9 @@ public void runOpMode() { // Each time around the loop, the servos will move by a small amount. // Limit the total offset to half of the full travel range if (gamepad1.right_bumper) - handOffset += robot.HAND_SPEED; + handOffset += RobotHardware.HAND_SPEED; else if (gamepad1.left_bumper) - handOffset -= robot.HAND_SPEED; + handOffset -= RobotHardware.HAND_SPEED; handOffset = Range.clip(handOffset, -0.5, 0.5); // Move both servos to new position. Use RobotHardware class @@ -114,9 +114,9 @@ else if (gamepad1.left_bumper) // Use gamepad buttons to move arm up (Y) and down (A) // Use the MOTOR constants defined in RobotHardware class. if (gamepad1.y) - arm = robot.ARM_UP_POWER; + arm = RobotHardware.ARM_UP_POWER; else if (gamepad1.a) - arm = robot.ARM_DOWN_POWER; + arm = RobotHardware.ARM_DOWN_POWER; else arm = 0; diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptNullOp.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptNullOp.java index 4a887bda..846ae224 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptNullOp.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptNullOp.java @@ -41,7 +41,7 @@ @Disabled public class ConceptNullOp extends OpMode { - private ElapsedTime runtime = new ElapsedTime(); + private final ElapsedTime runtime = new ElapsedTime(); /** * This method will be called once, when the INIT button is pressed. diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRevSPARKMini.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRevSPARKMini.java index 798d6893..e2f46773 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRevSPARKMini.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRevSPARKMini.java @@ -53,7 +53,7 @@ public class ConceptRevSPARKMini extends LinearOpMode { // Declare OpMode members. - private ElapsedTime runtime = new ElapsedTime(); + private final ElapsedTime runtime = new ElapsedTime(); private DcMotorSimple leftDrive = null; private DcMotorSimple rightDrive = null; diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptSoundsOnBotJava.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptSoundsOnBotJava.java index fbb7416c..74e446b4 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptSoundsOnBotJava.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptSoundsOnBotJava.java @@ -65,9 +65,9 @@ public class ConceptSoundsOnBotJava extends LinearOpMode { // Point to sound files on the phone's drive - private String soundPath = "/FIRST/blocks/sounds"; - private File goldFile = new File("/sdcard" + soundPath + "/gold.wav"); - private File silverFile = new File("/sdcard" + soundPath + "/silver.wav"); + private final String soundPath = "/FIRST/blocks/sounds"; + private final File goldFile = new File("/sdcard" + soundPath + "/gold.wav"); + private final File silverFile = new File("/sdcard" + soundPath + "/silver.wav"); // Declare OpMode members. private boolean isX = false; // Gamepad button state variables diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptSoundsSKYSTONE.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptSoundsSKYSTONE.java index 983e434f..9492e375 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptSoundsSKYSTONE.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptSoundsSKYSTONE.java @@ -52,7 +52,7 @@ public class ConceptSoundsSKYSTONE extends LinearOpMode { // List of available sound resources - String sounds[] = {"ss_alarm", "ss_bb8_down", "ss_bb8_up", "ss_darth_vader", "ss_fly_by", + String[] sounds = {"ss_alarm", "ss_bb8_down", "ss_bb8_up", "ss_darth_vader", "ss_fly_by", "ss_mf_fail", "ss_laser", "ss_laser_burst", "ss_light_saber", "ss_light_saber_long", "ss_light_saber_short", "ss_light_speed", "ss_mine", "ss_power_up", "ss_r2d2_up", "ss_roger_roger", "ss_siren", "ss_wookie" }; boolean soundPlaying = false; diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveByEncoder_Linear.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveByEncoder_Linear.java index 63293d0c..b8493609 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveByEncoder_Linear.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveByEncoder_Linear.java @@ -69,7 +69,7 @@ public class RobotAutoDriveByEncoder_Linear extends LinearOpMode { private DcMotor leftDrive = null; private DcMotor rightDrive = null; - private ElapsedTime runtime = new ElapsedTime(); + private final ElapsedTime runtime = new ElapsedTime(); // Calculate the COUNTS_PER_INCH for your specific drive train. // Go to your motor vendor website to determine your motor's COUNTS_PER_MOTOR_REV diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveByTime_Linear.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveByTime_Linear.java index a7147481..6ec89fce 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveByTime_Linear.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveByTime_Linear.java @@ -62,7 +62,7 @@ public class RobotAutoDriveByTime_Linear extends LinearOpMode { private DcMotor leftDrive = null; private DcMotor rightDrive = null; - private ElapsedTime runtime = new ElapsedTime(); + private final ElapsedTime runtime = new ElapsedTime(); static final double FORWARD_SPEED = 0.6; diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveToAprilTagOmni.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveToAprilTagOmni.java index 9bac0069..dfcf4cee 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveToAprilTagOmni.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveToAprilTagOmni.java @@ -311,7 +311,7 @@ private void setManualExposure(int exposureMS, int gain) { exposureControl.setMode(ExposureControl.Mode.Manual); sleep(50); } - exposureControl.setExposure((long)exposureMS, TimeUnit.MILLISECONDS); + exposureControl.setExposure(exposureMS, TimeUnit.MILLISECONDS); sleep(20); GainControl gainControl = visionPortal.getCameraControl(GainControl.class); gainControl.setGain(gain); diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveToAprilTagTank.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveToAprilTagTank.java index ba3eb4f9..1de5b9e1 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveToAprilTagTank.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveToAprilTagTank.java @@ -286,7 +286,7 @@ private void setManualExposure(int exposureMS, int gain) { exposureControl.setMode(ExposureControl.Mode.Manual); sleep(50); } - exposureControl.setExposure((long)exposureMS, TimeUnit.MILLISECONDS); + exposureControl.setExposure(exposureMS, TimeUnit.MILLISECONDS); sleep(20); GainControl gainControl = visionPortal.getCameraControl(GainControl.class); gainControl.setGain(gain); diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorKLNavxMicro.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorKLNavxMicro.java index ccc945ff..b5e90cf4 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorKLNavxMicro.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorKLNavxMicro.java @@ -70,7 +70,7 @@ public class SensorKLNavxMicro extends LinearOpMode { // Get a reference to a Modern Robotics GyroSensor object. We use several interfaces // on this object to illustrate which interfaces support which functionality. navxMicro = hardwareMap.get(NavxMicroNavigationSensor.class, "navx"); - gyro = (IntegratingGyroscope)navxMicro; + gyro = navxMicro; // If you're only interested int the IntegratingGyroscope interface, the following will suffice. // gyro = hardwareMap.get(IntegratingGyroscope.class, "navx"); diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRColor.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRColor.java index 32b37e09..e19f0795 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRColor.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRColor.java @@ -61,10 +61,10 @@ public class SensorMRColor extends LinearOpMode { public void runOpMode() { // hsvValues is an array that will hold the hue, saturation, and value information. - float hsvValues[] = {0F,0F,0F}; + float[] hsvValues = {0F,0F,0F}; // values is a reference to the hsvValues array. - final float values[] = hsvValues; + final float[] values = hsvValues; // get a reference to the RelativeLayout so we can change the background // color of the Robot Controller app to match the hue detected by the RGB sensor. diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRGyro.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRGyro.java index 91c0062e..f4d5b283 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRGyro.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRGyro.java @@ -75,7 +75,7 @@ public void runOpMode() { // Get a reference to a Modern Robotics gyro object. We use several interfaces // on this object to illustrate which interfaces support which functionality. modernRoboticsI2cGyro = hardwareMap.get(ModernRoboticsI2cGyro.class, "gyro"); - gyro = (IntegratingGyroscope)modernRoboticsI2cGyro; + gyro = modernRoboticsI2cGyro; // If you're only interested int the IntegratingGyroscope interface, the following will suffice. // gyro = hardwareMap.get(IntegratingGyroscope.class, "gyro"); // A similar approach will work for the Gyroscope interface, if that's all you need. diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/FtcRobotControllerActivity.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/FtcRobotControllerActivity.java index 3f1f77ce..f6eaa2c8 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/FtcRobotControllerActivity.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/FtcRobotControllerActivity.java @@ -318,8 +318,8 @@ protected void onCreate(Bundle savedInstanceState) { preferencesHelper.writeBooleanPrefIfDifferent(getString(R.string.pref_warn_about_incorrect_clocks), true); } - entireScreenLayout = (LinearLayout) findViewById(R.id.entire_screen); - buttonMenu = (ImageButton) findViewById(R.id.menu_buttons); + entireScreenLayout = findViewById(R.id.entire_screen); + buttonMenu = findViewById(R.id.menu_buttons); buttonMenu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -339,7 +339,7 @@ public boolean onMenuItemClick(MenuItem item) { updateMonitorLayout(getResources().getConfiguration()); - BlocksOpMode.setActivityAndWebView(this, (WebView) findViewById(R.id.webViewBlocksRuntime)); + BlocksOpMode.setActivityAndWebView(this, findViewById(R.id.webViewBlocksRuntime)); ExternalLibraries.getInstance().onCreate(); onBotJavaHelper = new OnBotJavaHelperImpl(); @@ -365,13 +365,13 @@ public boolean onMenuItemClick(MenuItem item) { cfgFileMgr.setActiveConfig(false, configFile); } - textDeviceName = (TextView) findViewById(R.id.textDeviceName); - textNetworkConnectionStatus = (TextView) findViewById(R.id.textNetworkConnectionStatus); - textRobotStatus = (TextView) findViewById(R.id.textRobotStatus); - textOpMode = (TextView) findViewById(R.id.textOpMode); - textErrorMessage = (TextView) findViewById(R.id.textErrorMessage); - textGamepad[0] = (TextView) findViewById(R.id.textGamepad1); - textGamepad[1] = (TextView) findViewById(R.id.textGamepad2); + textDeviceName = findViewById(R.id.textDeviceName); + textNetworkConnectionStatus = findViewById(R.id.textNetworkConnectionStatus); + textRobotStatus = findViewById(R.id.textRobotStatus); + textOpMode = findViewById(R.id.textOpMode); + textErrorMessage = findViewById(R.id.textErrorMessage); + textGamepad[0] = findViewById(R.id.textGamepad1); + textGamepad[1] = findViewById(R.id.textGamepad2); immersion = new ImmersiveMode(getWindow().getDecorView()); dimmer = new Dimmer(this); dimmer.longBright(); @@ -501,7 +501,7 @@ protected void unbindFromService() { protected void readNetworkType() { // Control hubs are always running the access point model. Everything else, for the time // being always runs the Wi-Fi Direct model. - if (Device.isRevControlHub() == true) { + if (Device.isRevControlHub()) { networkType = NetworkType.RCWIRELESSAP; } else { networkType = NetworkType.fromString(preferencesHelper.readString(context.getString(R.string.pref_pairing_kind), NetworkType.globalDefaultAsString())); @@ -541,11 +541,7 @@ private boolean isRobotRunning() { RobotState robotState = robot.eventLoopManager.state; - if (robotState != RobotState.RUNNING) { - return false; - } else { - return true; - } + return robotState == RobotState.RUNNING; } @Override @@ -629,7 +625,7 @@ public void onConfigurationChanged(Configuration newConfig) { * based on the given configuration. Makes the children split the space. */ private void updateMonitorLayout(Configuration configuration) { - LinearLayout monitorContainer = (LinearLayout) findViewById(R.id.monitorContainer); + LinearLayout monitorContainer = findViewById(R.id.monitorContainer); if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { // When the phone is landscape, lay out the monitor views horizontally. monitorContainer.setOrientation(LinearLayout.HORIZONTAL); @@ -803,11 +799,7 @@ protected class SharedPreferencesListener implements SharedPreferences.OnSharedP if (key.equals(context.getString(R.string.pref_app_theme))) { ThemedActivity.restartForAppThemeChange(getTag(), getString(R.string.appThemeChangeRestartNotifyRC)); } else if (key.equals(context.getString(R.string.pref_wifi_automute))) { - if (preferencesHelper.readBoolean(context.getString(R.string.pref_wifi_automute), false)) { - initWifiMute(true); - } else { - initWifiMute(false); - } + initWifiMute(preferencesHelper.readBoolean(context.getString(R.string.pref_wifi_automute), false)); } } } diff --git a/MeepMeepTesting/src/main/java/com/example/meepmeeptesting/PurplePixelComponent.java b/MeepMeepTesting/src/main/java/com/example/meepmeeptesting/PurplePixelComponent.java index cc2d8c69..1d9563f2 100644 --- a/MeepMeepTesting/src/main/java/com/example/meepmeeptesting/PurplePixelComponent.java +++ b/MeepMeepTesting/src/main/java/com/example/meepmeeptesting/PurplePixelComponent.java @@ -7,7 +7,7 @@ public class PurplePixelComponent extends Component { - private TensorFlowDetection.PropPosition propPosition; + private final TensorFlowDetection.PropPosition propPosition; public PurplePixelComponent(Robot robot, TensorFlowDetection.PropPosition propPosition) { super(robot); this.propPosition = propPosition; diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/TrackingWheelLocalizer.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/TrackingWheelLocalizer.java index 212bbfb0..488136d1 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/TrackingWheelLocalizer.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/TrackingWheelLocalizer.java @@ -38,7 +38,8 @@ public class TrackingWheelLocalizer extends ThreeTrackingWheelLocalizer { public Encoder leftEncoder, rightEncoder, frontEncoder; public final double X_MULTIPLIER;// = 1.009485424; // Multiplier in the X direction public final double Y_MULTIPLIER;// = 1.017838563; // Multiplier in the Y direction - private List lastEncPositions, lastEncVels; + private final List lastEncPositions; + private final List lastEncVels; public TrackingWheelLocalizer(HardwareMap hardwareMap, List lastTrackingEncPositions, List lastTrackingEncVels, String leftEncoderName, diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/TrajectoryDrive.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/TrajectoryDrive.java index 0a96fd20..247a18c0 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/TrajectoryDrive.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/TrajectoryDrive.java @@ -62,20 +62,20 @@ public class TrajectoryDrive extends MecanumDrive { public static double VY_WEIGHT = 1; public static double OMEGA_WEIGHT = 1; - private TrajectorySequenceRunner trajectorySequenceRunner; + private final TrajectorySequenceRunner trajectorySequenceRunner; - private TrajectoryFollower follower; + private final TrajectoryFollower follower; public DcMotorEx leftFront, leftRear, rightRear, rightFront; - private List motors; + private final List motors; private IMU imu; - private VoltageSensor batteryVoltageSensor; + private final VoltageSensor batteryVoltageSensor; - private List lastEncPositions = new ArrayList<>(); - private List lastEncVels = new ArrayList<>(); + private final List lastEncPositions = new ArrayList<>(); + private final List lastEncVels = new ArrayList<>(); private final TrajectoryAccelerationConstraint accelerationConstraint; private final TrajectoryVelocityConstraint velocityConstraint; diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/tuning/ManualFeedforwardTuner.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/tuning/ManualFeedforwardTuner.java index fffed0d9..84f5872d 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/tuning/ManualFeedforwardTuner.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/tuning/ManualFeedforwardTuner.java @@ -50,7 +50,7 @@ public class ManualFeedforwardTuner extends LinearOpMode { public static double DISTANCE = 72; // in - private FtcDashboard dashboard = FtcDashboard.getInstance(); + private final FtcDashboard dashboard = FtcDashboard.getInstance(); //private PantheraDrive drive; diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/tuning/MaxAngularVeloTuner.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/tuning/MaxAngularVeloTuner.java index 73d0132a..1cbf8ddd 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/tuning/MaxAngularVeloTuner.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/tuning/MaxAngularVeloTuner.java @@ -21,7 +21,7 @@ public class MaxAngularVeloTuner extends LinearOpMode { public static double RUNTIME = 4.0; private ElapsedTime timer; - private double maxAngVelocity = 0.0; + private final double maxAngVelocity = 0.0; @Override public void runOpMode() throws InterruptedException { diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/tuning/MaxVelocityTuner.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/tuning/MaxVelocityTuner.java index e821725a..06b483b8 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/tuning/MaxVelocityTuner.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/tuning/MaxVelocityTuner.java @@ -22,7 +22,7 @@ public class MaxVelocityTuner extends LinearOpMode { public static double RUNTIME = 2.0; private ElapsedTime timer; - private double maxVelocity = 0.0; + private final double maxVelocity = 0.0; private VoltageSensor batteryVoltageSensor; diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/LearningTeleOp.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/LearningTeleOp.java index 1feb6215..fea2c6f4 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/LearningTeleOp.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/LearningTeleOp.java @@ -13,6 +13,9 @@ public class LearningTeleOp extends LinearOpMode { + + + private DcMotor leftFrontMotor; private DcMotor rightFrontMotor; private DcMotor leftBackMotor; diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/LukeSpecifically.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/LukeSpecifically.java new file mode 100644 index 00000000..412bc033 --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/LukeSpecifically.java @@ -0,0 +1,60 @@ +package org.firstinspires.ftc.teamcode.opmode; + +import com.acmerobotics.dashboard.config.Config; +import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; +import com.qualcomm.robotcore.hardware.CRServo; +import com.qualcomm.robotcore.hardware.DcMotor; + +@Config +@TeleOp +public class LukeSpecifically extends LinearOpMode { + + + private DcMotor front_left; + private DcMotor front_right; + private DcMotor back_left; + private DcMotor back_right; + private CRServo servo_dog; + private CRServo grabber_dog; + + + @Override + public void runOpMode() throws InterruptedException { + waitForStart(); + + front_left = hardwareMap.get(DcMotor.class, "left_front_left_dw"); + front_right = hardwareMap.get(DcMotor.class, "right_front"); + back_left = hardwareMap.get(DcMotor.class, "left_back"); + back_right = hardwareMap.get(DcMotor.class, "right_back_right_dw"); + servo_dog = hardwareMap.get(CRServo.class, "servo"); + grabber_dog = hardwareMap.get(CRServo.class, "Grabber"); + while (opModeIsActive()) { + + double y = -gamepad1.left_stick_y; // Remember, Y stick is reversed! + double x = gamepad1.left_stick_x; + double rx = gamepad1.right_stick_x; + + front_left.setPower(-(y + x + rx)); + back_left.setPower(-(y - x + rx)); + front_right.setPower(y - x - rx); + back_right.setPower(y + x - rx); + + if (gamepad1.right_bumper) { + servo_dog.setPower(1); + }//use if else and else statements before i kill you + if (gamepad1.left_bumper) { + servo_dog.setPower(0); + } + if (gamepad1.dpad_left) { + grabber_dog.setPower(-1); + }//make it stop + if (gamepad1.dpad_right) { + grabber_dog.setPower(1); + } + } + + + } + +} diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/PatrickTeleOP.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/PatrickTeleOP.java new file mode 100644 index 00000000..49a10f7a --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/PatrickTeleOP.java @@ -0,0 +1,34 @@ +package org.firstinspires.ftc.teamcode.opmode; + +import com.acmerobotics.dashboard.config.Config; +import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; +import com.qualcomm.robotcore.hardware.DcMotor; + +@Config +@TeleOp +public class PatrickTeleOP extends LinearOpMode { + + private DcMotor front_left; + private DcMotor front_right; + private DcMotor back_left; + private DcMotor back_right; + + @Override + public void runOpMode() throws InterruptedException { + waitForStart(); + front_left = hardwareMap.get(DcMotor.class, "left_front_left_dw"); + front_right = hardwareMap.get(DcMotor.class, "right_front"); + back_left = hardwareMap.get(DcMotor.class, "left_back"); + back_right = hardwareMap.get(DcMotor.class, "right_back_right_dw"); + + while (opModeIsActive()) { + if (gamepad1.left_stick_x > 0) { + } + } + + } + + +} + diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/THEONE.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/THEONE.java new file mode 100644 index 00000000..c1cf981c --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/THEONE.java @@ -0,0 +1,83 @@ +package org.firstinspires.ftc.teamcode.opmode; + +import com.acmerobotics.dashboard.config.Config; +import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; +import com.qualcomm.robotcore.hardware.CRServo; +import com.qualcomm.robotcore.hardware.DcMotor; +import com.qualcomm.robotcore.hardware.DcMotorSimple; + +@Config +@TeleOp +public class THEONE extends LinearOpMode { + + + private DcMotor leftFrontMotor; + private DcMotor rightFrontMotor; + private DcMotor leftBackMotor; + private DcMotor rightBackMotor; + private DcMotor Arm; + + @Override + public void runOpMode() throws InterruptedException { + + leftFrontMotor = hardwareMap.get(DcMotor.class, "front_left"); + rightFrontMotor = hardwareMap.get(DcMotor.class, "front_right"); + leftBackMotor = hardwareMap.get(DcMotor.class, "back_left"); + rightBackMotor = hardwareMap.get(DcMotor.class, "back_right"); + Arm = hardwareMap.get(DcMotor.class, "arm"); + + waitForStart(); + while (opModeIsActive()) { + leftFrontMotor.setDirection(DcMotorSimple.Direction.REVERSE); + leftBackMotor.setDirection(DcMotorSimple.Direction.REVERSE); + double y = -gamepad1.left_stick_y; // Remember, Y stick is reversed! + double x = gamepad1.left_stick_x; + double rx = gamepad1.right_stick_x; + + leftFrontMotor.setPower(y + x + rx); + leftBackMotor.setPower(y - x + rx); + rightFrontMotor.setPower(y - x - rx); + rightBackMotor.setPower(y + x - rx); + if (gamepad1.a) { + leftBackMotor.setPower(2); + rightBackMotor.setPower(2); + leftFrontMotor.setPower(2); + rightFrontMotor.setPower(2); + } + + + if (gamepad1.left_bumper) { + Arm.setPower(.3); + } else if (gamepad1.right_bumper) { + Arm.setPower(-.3); + } else { + /*current_time = get_current_time() + current_error = desire_position-current_position + + p = k_p * current_error + + i += k_i * (current_error * (current_time - previous_time)) + + if i > max_i: + i = max_i + elif i < -max_i: + i = -max_i + + D = k_d * (current_error - previous_error) / (current_time - previous_time) + + output = p + i + d + + previous_error = current_error + previous_time = current_time + Arm.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE); + Arm.setPower(0); + } + //3 hours for 1 bracket... always remember to click code->reformat code + + + } + + } +} + diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TrumanLearnsTeleOP.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TrumanLearnsTeleOP.java index cca9f0e3..02e8e84c 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TrumanLearnsTeleOP.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/TrumanLearnsTeleOP.java @@ -1,15 +1,17 @@ package org.firstinspires.ftc.teamcode.opmode; + import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; import com.qualcomm.robotcore.eventloop.opmode.TeleOp; import com.qualcomm.robotcore.hardware.CRServo; import com.qualcomm.robotcore.hardware.DcMotor; import com.qualcomm.robotcore.hardware.DcMotorSimple; +import org.firstinspires.ftc.teamcode.util.Toggle; @TeleOp - public class TrumanLearnsTeleOP extends LinearOpMode { + private DcMotor topLeftMotor; private DcMotor topRightMotor; private DcMotor bottomLeftMotor; @@ -17,11 +19,13 @@ public class TrumanLearnsTeleOP extends LinearOpMode { private CRServo tail; @Override public void runOpMode() throws InterruptedException { - float ly; - float MaxSpeed= 0.8F; - float lx; - float rx; - float ry; + Toggle myToggleButton = new Toggle(); + double ly; + double lx; + double rx; + double ry; + boolean leftBumper; + boolean rightBumper; //why? just use if statements topLeftMotor = hardwareMap.get(DcMotor.class,"FL"); topRightMotor = hardwareMap.get(DcMotor.class,"FR"); bottomLeftMotor = hardwareMap.get(DcMotor.class,"BL"); @@ -29,30 +33,57 @@ public void runOpMode() throws InterruptedException { topLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE); bottomLeftMotor.setDirection(DcMotorSimple.Direction.REVERSE); //tail = hardwareMap.get(CRServo.class,"servo"); ONLY FOR DOG - int tailAngle = 1; - double motorSpeed = 0.3; + //double tailAngle = 1; + double motorSpeed = 0.3; //^^ waitForStart(); + while (opModeIsActive()){ - lx=gamepad1.left_stick_x; - ly=gamepad1.left_stick_y; - rx=gamepad1.right_stick_x; - ry=gamepad1.right_stick_y; - - lx= (float) (lx*MaxSpeed); - if(gamepad1.left_bumper){ - MaxSpeed= (float) (MaxSpeed+0.1); - - } - if (gamepad1.right_bumper){ - MaxSpeed= (float) (MaxSpeed-0.1); + + myToggleButton.update(gamepad1.a); + + if (myToggleButton.state){ + lx=gamepad1.right_stick_y; + ly=gamepad1.right_stick_y; + rx=gamepad1.left_stick_y; + ry=gamepad1.left_stick_y; + leftBumper=gamepad1.left_bumper; + rightBumper=gamepad1.right_bumper; + if (leftBumper) { + ly=-1; + lx=1; + } + if (rightBumper) { + rx=1; + ry=-1; + + } + topLeftMotor.setPower(ly); + bottomLeftMotor.setPower(lx); + topRightMotor.setPower(rx); + bottomRightMotor.setPower(ry); + telemetry.addData("Ly", ly); + telemetry.addData("Lx", lx); + telemetry.addData("Rx", rx); + telemetry.addData("Ry", ry); + telemetry.update(); } + else{ + double y = -gamepad1.left_stick_y; // Remember, Y stick is reversed! + double x = gamepad1.left_stick_x; + double rx2 = gamepad1.right_stick_x; - topLeftMotor.setPower(lx); - bottomLeftMotor.setPower(lx); - topRightMotor.setPower(lx); - bottomRightMotor.setPower(lx); + topLeftMotor.setPower(y+ x + rx2); + bottomLeftMotor.setPower(y - x + rx2); + topRightMotor.setPower(y - x - rx2); + bottomRightMotor.setPower(y + x - rx2); + } + //while(!check){ + //put the other stuff that isn't t-bar steering here + } } - } } + + + diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/trajectorysequence/TrajectorySequenceRunner.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/trajectorysequence/TrajectorySequenceRunner.java index 9f3cc0cf..dc0eae72 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/trajectorysequence/TrajectorySequenceRunner.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/trajectorysequence/TrajectorySequenceRunner.java @@ -59,9 +59,12 @@ public class TrajectorySequenceRunner { private final FtcDashboard dashboard; private final LinkedList poseHistory = new LinkedList<>(); - private VoltageSensor voltageSensor; + private final VoltageSensor voltageSensor; - private List lastDriveEncPositions, lastDriveEncVels, lastTrackingEncPositions, lastTrackingEncVels; + private final List lastDriveEncPositions; + private final List lastDriveEncVels; + private final List lastTrackingEncPositions; + private final List lastTrackingEncVels; public TrajectorySequenceRunner( TrajectoryFollower follower, PIDCoefficients headingPIDCoefficients, VoltageSensor voltageSensor, diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/trajectorysequence/sequencesegment/TurnSegment.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/trajectorysequence/sequencesegment/TurnSegment.java index 11995dba..c9f21396 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/trajectorysequence/sequencesegment/TurnSegment.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/trajectorysequence/sequencesegment/TurnSegment.java @@ -26,11 +26,11 @@ public TurnSegment(Pose2d startPose, double totalRotation, MotionProfile motionP this.motionProfile = motionProfile; } - public final double getTotalRotation() { + public double getTotalRotation() { return this.totalRotation; } - public final MotionProfile getMotionProfile() { + public MotionProfile getMotionProfile() { return this.motionProfile; } } diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/Blinker.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/Blinker.java index d5599e93..381d5d87 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/Blinker.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/Blinker.java @@ -63,7 +63,7 @@ public void identify() { public static class Pattern { public static final int MAX_STEPS = 16; - private List steps = new ArrayList<>(); + private final List steps = new ArrayList<>(); /** * Add a step to the pattern. You can have a maximum of 16 steps. diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/Encoder.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/Encoder.java index f724c524..9b5cd0dc 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/Encoder.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/Encoder.java @@ -26,7 +26,7 @@ public enum Direction { FORWARD(1), REVERSE(-1); - private int multiplier; + private final int multiplier; Direction(int multiplier) { this.multiplier = multiplier; @@ -37,14 +37,14 @@ public int getMultiplier() { } } - private DcMotorEx motor; - private NanoClock clock; + private final DcMotorEx motor; + private final NanoClock clock; private Direction direction; private int lastPosition; private int velocityEstimateIdx; - private double[] velocityEstimates; + private final double[] velocityEstimates; private double lastUpdateTime; public Encoder(DcMotorEx motor, NanoClock clock) { diff --git a/build.common.gradle b/build.common.gradle index 1f3a725b..4c776cc0 100644 --- a/build.common.gradle +++ b/build.common.gradle @@ -66,7 +66,7 @@ android { * @see Configure Your Build * @see Versioning Your App */ - def manifestFile = project(':FtcRobotController').file('src/main/AndroidManifest.xml'); + def manifestFile = project(':FtcRobotController').file('src/main/AndroidManifest.xml') def manifestText = manifestFile.getText() // def vCodePattern = Pattern.compile("versionCode=\"(\\d+(\\.\\d+)*)\"") @@ -75,7 +75,7 @@ android { def vCode = Integer.parseInt(matcher.group(1)) // def vNamePattern = Pattern.compile("versionName=\"(.*)\"") - matcher = vNamePattern.matcher(manifestText); + matcher = vNamePattern.matcher(manifestText) matcher.find() def vName = matcher.group(1) //