diff --git a/FtcRobotController/src/main/AndroidManifest.xml b/FtcRobotController/src/main/AndroidManifest.xml index d97707d4a59..05c35b4c863 100644 --- a/FtcRobotController/src/main/AndroidManifest.xml +++ b/FtcRobotController/src/main/AndroidManifest.xml @@ -2,11 +2,12 @@ + android:versionCode="13" + android:versionName="2.3"> diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptCompassCalibration.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptCompassCalibration.java index 5b300c62cdc..ff3ef8eb63a 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptCompassCalibration.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptCompassCalibration.java @@ -71,7 +71,7 @@ public class ConceptCompassCalibration extends LinearOpMode { static final double CAL_TIME_SEC = 20; @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { /* Initialize the drive system variables. * The init() method of the hardware class does all the work here @@ -104,8 +104,7 @@ public void runOpMode() throws InterruptedException { // run until time expires OR the driver presses STOP; runtime.reset(); while (opModeIsActive() && (runtime.time() < CAL_TIME_SEC)) { - - idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop + idle(); } // Stop all motors and turn off claibration @@ -123,6 +122,5 @@ public void runOpMode() throws InterruptedException { else telemetry.addData("Compass", "Calibrate Passed."); telemetry.update(); - } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptDIMAsIndicator.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptDIMAsIndicator.java index b5cb32c5bd5..82d08d3fe31 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptDIMAsIndicator.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptDIMAsIndicator.java @@ -37,7 +37,7 @@ public class ConceptDIMAsIndicator extends LinearOpMode { DeviceInterfaceModule dim; @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { // Connect to motor (Assume standard left wheel) // Change the text in quotes to match any motor name on your robot. diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptI2cAddressChange.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptI2cAddressChange.java index 2d7c8b706f1..27d38e681c0 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptI2cAddressChange.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptI2cAddressChange.java @@ -99,7 +99,7 @@ public class ConceptI2cAddressChange extends LinearOpMode { DeviceInterfaceModule dim; @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { // set up the hardware devices we are going to use dim = hardwareMap.deviceInterfaceModule.get("dim"); diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRampMotorSpeed.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRampMotorSpeed.java index ca80a8d3ca4..017ce0ccef4 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRampMotorSpeed.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRampMotorSpeed.java @@ -9,7 +9,7 @@ * This OpMode ramps a single motor speed up and down repeatedly until Stop is pressed. * The code is structured as a LinearOpMode * - * This code assumes a DC motor configured with the name "left motor" as is found on a pushbot. + * This code assumes a DC motor configured with the name "left_drive" as is found on a pushbot. * * INCREMENT sets how much to increase/decrease the power each cycle * CYCLE_MS sets the update period. @@ -33,11 +33,11 @@ public class ConceptRampMotorSpeed extends LinearOpMode { @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { // Connect to motor (Assume standard left wheel) // Change the text in quotes to match any motor name on your robot. - motor = hardwareMap.dcMotor.get("left motor"); + motor = hardwareMap.dcMotor.get("left_drive"); // Wait for the start button telemetry.addData(">", "Press Start to run Motors." ); diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRegisterOpModes.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRegisterOpModes.java index 8db41be79e2..4563ddb4d7a 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRegisterOpModes.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRegisterOpModes.java @@ -86,7 +86,10 @@ public static void registerMyOpModes(OpModeManager manager) { // manager.register("K9 Telop", K9botTeleopTank_Linear.class); // Sensor Samples + // manager.register("AdaFruit IMU", SensorAdafruitIMU.class); + // manager.register("AdaFruit IMU Cal", SensorAdafruitIMUCalibration.class); // manager.register("AdaFruit Color", SensorAdafruitRGB.class); + // manager.register("DIM DIO", SensorDIO.class); // manager.register("HT Color", SensorHTColor.class); // manager.register("LEGO Light", SensorLEGOLight.class); // manager.register("LEGO Touch", SensorLEGOTouch.class); diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptScanServo.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptScanServo.java index 013641358cd..cedcf533180 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptScanServo.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptScanServo.java @@ -36,11 +36,11 @@ public class ConceptScanServo extends LinearOpMode { @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { - // Connect to servo (Assume PushBot Left Claw) + // Connect to servo (Assume PushBot Left Hand) // Change the text in quotes to match any servo name on your robot. - servo = hardwareMap.servo.get("left claw"); + servo = hardwareMap.servo.get("left_hand"); // Wait for the start button telemetry.addData(">", "Press Start to scan Servo." ); diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptTelemetry.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptTelemetry.java index 5d74231a25b..15baf012247 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptTelemetry.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptTelemetry.java @@ -52,8 +52,7 @@ are permitted (subject to the limitations in the disclaimer below) provided that */ @Autonomous(name = "Concept: Telemetry", group = "Concept") @Disabled -public class ConceptTelemetry extends LinearOpMode - { +public class ConceptTelemetry extends LinearOpMode { /** keeps track of the line of the poem which is to be emitted next */ int poemLine = 0; @@ -83,9 +82,9 @@ public class ConceptTelemetry extends LinearOpMode "The teacher did reply.", "", "" - }; + }; - @Override public void runOpMode() throws InterruptedException { + @Override public void runOpMode() { /* we keep track of how long it's been since the OpMode was started, just * to have some interesting data to show */ @@ -107,7 +106,7 @@ public class ConceptTelemetry extends LinearOpMode telemetry.addData("time", "%.1f seconds", opmodeRunTime.seconds()); telemetry.update(); idle(); - } + } // Ok, we've been given the ok to go @@ -123,7 +122,7 @@ public class ConceptTelemetry extends LinearOpMode telemetry.addData("voltage", "%.1f volts", new Func() { @Override public Double value() { return getBatteryVoltage(); - } + } }); // Reset to keep some timing stats for the post-'start' part of the opmode @@ -136,7 +135,7 @@ public class ConceptTelemetry extends LinearOpMode // Emit poetry if it's been a while if (poemElapsed.seconds() > sPoemInterval) { emitPoemLine(); - } + } // As an illustration, show some loop timing information telemetry.addData("loop count", loopCount); @@ -158,16 +157,15 @@ public class ConceptTelemetry extends LinearOpMode /** Update loop info and play nice with the rest of the {@link Thread}s in the system */ loopCount++; - idle(); - } } + } // emits a line of poetry to the telemetry log void emitPoemLine() { telemetry.log().add(poem[poemLine]); poemLine = (poemLine+1) % poem.length; poemElapsed.reset(); - } + } // Computes the current battery voltage double getBatteryVoltage() { @@ -176,8 +174,8 @@ void emitPoemLine() { double voltage = sensor.getVoltage(); if (voltage > 0) { result = Math.min(result, voltage); - } } - return result; } + return result; } +} diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptVuforiaNavigation.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptVuforiaNavigation.java index d2cb50556f3..12c48e528d4 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptVuforiaNavigation.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptVuforiaNavigation.java @@ -98,7 +98,7 @@ public class ConceptVuforiaNavigation extends LinearOpMode { */ VuforiaLocalizer vuforia; - @Override public void runOpMode() throws InterruptedException { + @Override public void runOpMode() { /** * Start up Vuforia, telling it the id of the view that we wish to use as the parent for * the camera monitor feedback; if no camera monitor feedback is desired, use the parameterless @@ -319,7 +319,6 @@ public class ConceptVuforiaNavigation extends LinearOpMode { telemetry.addData("Pos", "Unknown"); } telemetry.update(); - idle(); } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/HardwareK9bot.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/HardwareK9bot.java index 2fc021d33e4..f4b2846fc36 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/HardwareK9bot.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/HardwareK9bot.java @@ -14,8 +14,8 @@ * This hardware class assumes the following device names have been configured on the robot: * Note: All names are lower case and some have single spaces between words. * - * Motor channel: Left drive motor: "left motor" - * Motor channel: Right drive motor: "right motor" + * Motor channel: Left drive motor: "left_drive" + * Motor channel: Right drive motor: "right_drive" * Servo channel: Servo to raise/lower arm: "arm" * Servo channel: Servo to open/close claw: "claw" * @@ -52,8 +52,8 @@ public void init(HardwareMap ahwMap) { hwMap = ahwMap; // Define and Initialize Motors - leftMotor = hwMap.dcMotor.get("left motor"); - rightMotor = hwMap.dcMotor.get("right motor"); + leftMotor = hwMap.dcMotor.get("left_drive"); + rightMotor = hwMap.dcMotor.get("right_drive"); leftMotor.setDirection(DcMotor.Direction.REVERSE); // Set all motors to zero power @@ -79,15 +79,19 @@ public void init(HardwareMap ahwMap) { * The function looks at the elapsed cycle time, and sleeps for the remaining time interval. * * @param periodMs Length of wait cycle in mSec. - * @throws InterruptedException */ - public void waitForTick(long periodMs) throws InterruptedException { + public void waitForTick(long periodMs) { long remaining = periodMs - (long)period.milliseconds(); // sleep for the remaining portion of the regular cycle period. - if (remaining > 0) - Thread.sleep(remaining); + if (remaining > 0) { + try { + Thread.sleep(remaining); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } // Reset the cycle clock for the next pass. period.reset(); diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/HardwarePushbot.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/HardwarePushbot.java index e4697f896be..f463da9ef4b 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/HardwarePushbot.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/HardwarePushbot.java @@ -80,15 +80,19 @@ public void init(HardwareMap ahwMap) { * The function looks at the elapsed cycle time, and sleeps for the remaining time interval. * * @param periodMs Length of wait cycle in mSec. - * @throws InterruptedException */ - public void waitForTick(long periodMs) throws InterruptedException { + public void waitForTick(long periodMs) { long remaining = periodMs - (long)period.milliseconds(); // sleep for the remaining portion of the regular cycle period. - if (remaining > 0) - Thread.sleep(remaining); + if (remaining > 0) { + try { + Thread.sleep(remaining); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } // Reset the cycle clock for the next pass. period.reset(); diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/HardwarePushbotMatrix.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/HardwarePushbotMatrix.java index d6cd69c9ce4..f051f7ed949 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/HardwarePushbotMatrix.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/HardwarePushbotMatrix.java @@ -20,11 +20,11 @@ * * Matrix Controller has been assigned the name: "matrix controller" * - * Motor channel: Left drive motor: "left motor" - * Motor channel: Right drive motor: "right motor" - * Motor channel: Manipulator drive motor: "arm motor" - * Servo channel: Servo to open left claw: "left claw" - * Servo channel: Servo to open right claw: "right claw" + * Motor channel: Left drive motor: "left_drive" + * Motor channel: Right drive motor: "right_drive" + * Motor channel: Manipulator drive motor: "left_arm" + * Servo channel: Servo to open left claw: "left_hand" + * Servo channel: Servo to open right claw: "right_hand" * * In addition, the Matrix Controller has been assigned the name: "matrix controller" */ diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/K9botTeleopTank_Linear.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/K9botTeleopTank_Linear.java index e2bef1ebff4..29a44181456 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/K9botTeleopTank_Linear.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/K9botTeleopTank_Linear.java @@ -66,7 +66,7 @@ public class K9botTeleopTank_Linear extends LinearOpMode { final double ARM_SPEED = 0.01 ; // sets rate to move servo @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { double left; double right; @@ -118,7 +118,6 @@ else if (gamepad1.b) // Pause for metronome tick. 40 mS each cycle = update 25 times a second. robot.waitForTick(40); - idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop } } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveByEncoder_Linear.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveByEncoder_Linear.java index b32275a3590..2e114d5a338 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveByEncoder_Linear.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveByEncoder_Linear.java @@ -82,7 +82,7 @@ public class PushbotAutoDriveByEncoder_Linear extends LinearOpMode { static final double TURN_SPEED = 0.5; @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { /* * Initialize the drive system variables. @@ -134,7 +134,7 @@ public void runOpMode() throws InterruptedException { */ public void encoderDrive(double speed, double leftInches, double rightInches, - double timeoutS) throws InterruptedException { + double timeoutS) { int newLeftTarget; int newRightTarget; @@ -167,9 +167,6 @@ public void encoderDrive(double speed, robot.leftMotor.getCurrentPosition(), robot.rightMotor.getCurrentPosition()); telemetry.update(); - - // Allow time for other processes to run. - idle(); } // Stop all motion; diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveByGyro_Linear.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveByGyro_Linear.java index b003ec77242..0b9de606607 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveByGyro_Linear.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveByGyro_Linear.java @@ -96,7 +96,7 @@ public class PushbotAutoDriveByGyro_Linear extends LinearOpMode { @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { /* * Initialize the standard drive system variables. @@ -116,8 +116,8 @@ public void runOpMode() throws InterruptedException { gyro.calibrate(); // make sure the gyro is calibrated before continuing - while (gyro.isCalibrating()) { - Thread.sleep(50); + while (!isStopRequested() && gyro.isCalibrating()) { + sleep(50); idle(); } @@ -167,7 +167,7 @@ public void runOpMode() throws InterruptedException { */ public void gyroDrive ( double speed, double distance, - double angle) throws InterruptedException { + double angle) { int newLeftTarget; int newRightTarget; @@ -231,9 +231,6 @@ public void gyroDrive ( double speed, robot.rightMotor.getCurrentPosition()); telemetry.addData("Speed", "%5.2f:%5.2f", leftSpeed, rightSpeed); telemetry.update(); - - // Allow time for other processes to run. - idle(); } // Stop all motion; @@ -256,16 +253,13 @@ public void gyroDrive ( double speed, * @param angle Absolute Angle (in Degrees) relative to last gyro reset. * 0 = fwd. +ve is CCW from fwd. -ve is CW from forward. * If a relative angle is required, add/subtract from current heading. - * @throws InterruptedException */ - public void gyroTurn ( double speed, double angle) - throws InterruptedException { + public void gyroTurn ( double speed, double angle) { // keep looping while we are still active, and not on heading. while (opModeIsActive() && !onHeading(speed, angle, P_TURN_COEFF)) { // Update telemetry & Allow time for other processes to run. telemetry.update(); - idle(); } } @@ -278,10 +272,8 @@ public void gyroTurn ( double speed, double angle) * 0 = fwd. +ve is CCW from fwd. -ve is CW from forward. * If a relative angle is required, add/subtract from current heading. * @param holdTime Length of time (in seconds) to hold the specified heading. - * @throws InterruptedException */ - public void gyroHold( double speed, double angle, double holdTime) - throws InterruptedException { + public void gyroHold( double speed, double angle, double holdTime) { ElapsedTime holdTimer = new ElapsedTime(); @@ -291,7 +283,6 @@ public void gyroHold( double speed, double angle, double holdTime) // Update telemetry & Allow time for other processes to run. onHeading(speed, angle, P_TURN_COEFF); telemetry.update(); - idle(); } // Stop all motion; diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveByTime_Linear.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveByTime_Linear.java index d8fac2f2812..a33302000a8 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveByTime_Linear.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveByTime_Linear.java @@ -72,7 +72,7 @@ public class PushbotAutoDriveByTime_Linear extends LinearOpMode { static final double TURN_SPEED = 0.5; @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { /* * Initialize the drive system variables. @@ -96,7 +96,6 @@ public void runOpMode() throws InterruptedException { while (opModeIsActive() && (runtime.seconds() < 3.0)) { telemetry.addData("Path", "Leg 1: %2.5f S Elapsed", runtime.seconds()); telemetry.update(); - idle(); } // Step 2: Spin right for 1.3 seconds @@ -106,7 +105,6 @@ public void runOpMode() throws InterruptedException { while (opModeIsActive() && (runtime.seconds() < 1.3)) { telemetry.addData("Path", "Leg 2: %2.5f S Elapsed", runtime.seconds()); telemetry.update(); - idle(); } // Step 3: Drive Backwards for 1 Second @@ -116,7 +114,6 @@ public void runOpMode() throws InterruptedException { while (opModeIsActive() && (runtime.seconds() < 1.0)) { telemetry.addData("Path", "Leg 3: %2.5f S Elapsed", runtime.seconds()); telemetry.update(); - idle(); } // Step 4: Stop and close the claw. @@ -128,6 +125,5 @@ public void runOpMode() throws InterruptedException { telemetry.addData("Path", "Complete"); telemetry.update(); sleep(1000); - idle(); } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveToLine_Linear.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveToLine_Linear.java index 505d138af11..c463ff1e939 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveToLine_Linear.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveToLine_Linear.java @@ -43,7 +43,7 @@ are permitted (subject to the limitations in the disclaimer below) provided that * The code is structured as a LinearOpMode * * The code shows using two different light sensors: - * The Primary sensor shown in this code is a legacy NXT Light sensor (called "light sensor") + * The Primary sensor shown in this code is a legacy NXT Light sensor (called "sensor_light") * Alternative "commented out" code uses a MR Optical Distance Sensor (called "sensor_ods") * instead of the LEGO sensor. Chose to use one sensor or the other. * @@ -71,7 +71,7 @@ public class PushbotAutoDriveToLine_Linear extends LinearOpMode { static final double APPROACH_SPEED = 0.5; @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { /* Initialize the drive system variables. * The init() method of the hardware class does all the work here @@ -83,7 +83,7 @@ public void runOpMode() throws InterruptedException { // robot.rightMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER); // get a reference to our Light Sensor object. - lightSensor = hardwareMap.lightSensor.get("light sensor"); // Primary LEGO Light Sensor + lightSensor = hardwareMap.lightSensor.get("sensor_light"); // Primary LEGO Light Sensor // lightSensor = hardwareMap.opticalDistanceSensor.get("sensor_ods"); // Alternative MR ODS sensor. // turn on LED of light sensor. @@ -94,7 +94,8 @@ public void runOpMode() throws InterruptedException { telemetry.update(); // Wait for the game to start (driver presses PLAY) - while (!isStarted()) { + // Abort this loop is started or stopped. + while (!(isStarted() || isStopRequested())) { // Display the light level while we are waiting to start telemetry.addData("Light Level", lightSensor.getLightDetected()); @@ -112,7 +113,6 @@ public void runOpMode() throws InterruptedException { // Display the light level while we are looking for the line telemetry.addData("Light Level", lightSensor.getLightDetected()); telemetry.update(); - idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop } // Stop all motors diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotTeleopPOV_Linear.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotTeleopPOV_Linear.java index ab64eb42b15..b5ca4d80307 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotTeleopPOV_Linear.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotTeleopPOV_Linear.java @@ -66,7 +66,7 @@ public class PushbotTeleopPOV_Linear extends LinearOpMode { final double CLAW_SPEED = 0.02 ; // sets rate to move servo @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { double left; double right; double max; diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotTeleopTank_Iterative.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotTeleopTank_Iterative.java index 2a34087fefe..53401db81a3 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotTeleopTank_Iterative.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotTeleopTank_Iterative.java @@ -78,7 +78,6 @@ public void init() { // Send telemetry message to signify robot waiting; telemetry.addData("Say", "Hello Driver"); // - updateTelemetry(telemetry); } /* @@ -132,7 +131,6 @@ else if (gamepad1.a) telemetry.addData("claw", "Offset = %.2f", clawOffset); telemetry.addData("left", "%.2f", left); telemetry.addData("right", "%.2f", right); - updateTelemetry(telemetry); } /* diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorAdafruitIMU.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorAdafruitIMU.java index 261fbaa0a8f..115ac5366d7 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorAdafruitIMU.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorAdafruitIMU.java @@ -76,7 +76,7 @@ public class SensorAdafruitIMU extends LinearOpMode // Main logic //---------------------------------------------------------------------------------------------- - @Override public void runOpMode() throws InterruptedException { + @Override public void runOpMode() { // Set up the parameters with which we will use our IMU. Note that integration // algorithm here just reports accelerations to the logcat log; it doesn't actually @@ -107,7 +107,6 @@ public class SensorAdafruitIMU extends LinearOpMode // Loop and update the dashboard while (opModeIsActive()) { telemetry.update(); - idle(); } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorAdafruitIMUCalibration.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorAdafruitIMUCalibration.java index 56f38d5a572..98cdfd1f923 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorAdafruitIMUCalibration.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorAdafruitIMUCalibration.java @@ -123,7 +123,7 @@ public class SensorAdafruitIMUCalibration extends LinearOpMode // Main logic //---------------------------------------------------------------------------------------------- - @Override public void runOpMode() throws InterruptedException { + @Override public void runOpMode() { telemetry.log().setCapacity(12); telemetry.log().add(""); @@ -179,7 +179,6 @@ public class SensorAdafruitIMUCalibration extends LinearOpMode } telemetry.update(); - idle(); } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorAdafruitRGB.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorAdafruitRGB.java index c418cdc34ae..bae1c6d238e 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorAdafruitRGB.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorAdafruitRGB.java @@ -60,7 +60,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * * The op mode assumes that the Core Device Interface Module * is configured with a name of "dim" and that the Adafruit color sensor - * is configured as an I2C device with a name of "color". + * is configured as an I2C device with a name of "sensor_color". * * It also assumes that the LED pin of the RGB sensor * is connected to the signal pin of digital port #5 (zero indexed) @@ -83,7 +83,7 @@ public class SensorAdafruitRGB extends LinearOpMode { static final int LED_CHANNEL = 5; @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { // hsvValues is an array that will hold the hue, saturation, and value information. float hsvValues[] = {0F,0F,0F}; @@ -111,7 +111,7 @@ public void runOpMode() throws InterruptedException { cdim.setDigitalChannelMode(LED_CHANNEL, DigitalChannelController.Mode.OUTPUT); // get a reference to our ColorSensor object. - sensorRGB = hardwareMap.colorSensor.get("color"); + sensorRGB = hardwareMap.colorSensor.get("sensor_color"); // turn the LED on in the beginning, just so user will know that the sensor is active. cdim.setDigitalChannelState(LED_CHANNEL, bLedOn); @@ -158,7 +158,6 @@ public void run() { }); telemetry.update(); - idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop } } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorDIO.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorDIO.java new file mode 100644 index 00000000000..6e1fb6e2150 --- /dev/null +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorDIO.java @@ -0,0 +1,112 @@ +/* Copyright (c) 2016 PSM + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted (subject to the limitations in the disclaimer below) provided that +the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +Neither the name of Qualcomm Technologies Inc nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS +LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +package org.firstinspires.ftc.robotcontroller.external.samples; + +import com.qualcomm.hardware.modernrobotics.ModernRoboticsI2cGyro; +import com.qualcomm.hardware.modernrobotics.ModernRoboticsUsbDeviceInterfaceModule; +import com.qualcomm.robotcore.eventloop.opmode.Disabled; +import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; +import com.qualcomm.robotcore.hardware.DeviceInterfaceModule; +import com.qualcomm.robotcore.hardware.DigitalChannel; +import com.qualcomm.robotcore.hardware.DigitalChannelController; + +/* + * This is an example LinearOpMode that shows how to use the digital inputs and outputs on the + * the Modern Robotics Device Interface Module. In addition, it shows how to use the Red and Blue LED + * + * This op mode assumes that there is a Device Interface Module attached, named 'dim'. + * On this DIM there is a digital input named 'digin' and an output named 'digout' + * + * To fully exercise this sample, connect pin 3 of the digin connector to pin 3 of the digout. + * Note: Pin 1 is indicated by the black stripe, so pin 3 is at the opposite end. + * + * The X button on the gamepad will be used to activate the digital output pin. + * The Red/Blue LED will be used to indicate the state of the digital input pin. + * Blue = false (0V), Red = true (5V) + * If the two pins are linked, the gamepad will change the LED color. + * + * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name. + * Remove or comment out the @Disabled line to add this opmode to the Driver Station OpMode list +*/ +@TeleOp(name = "Sensor: DIM DIO", group = "Sensor") +@Disabled +public class SensorDIO extends LinearOpMode { + +final int BLUE_LED_CHANNEL = 0; +final int RED_LED_CHANNEL = 1; + + @Override + public void runOpMode() { + + boolean inputPin; // Input State + boolean outputPin; // Output State + DeviceInterfaceModule dim; // Device Object + DigitalChannel digIn; // Device Object + DigitalChannel digOut; // Device Object + + // get a reference to a Modern Robotics DIM, and IO channels. + dim = hardwareMap.get(DeviceInterfaceModule.class, "dim"); // Use generic form of device mapping + digIn = hardwareMap.get(DigitalChannel.class, "digin"); // Use generic form of device mapping + digOut = hardwareMap.get(DigitalChannel.class, "digout"); // Use generic form of device mapping + + digIn.setMode(DigitalChannelController.Mode.INPUT); // Set the direction of each channel + digOut.setMode(DigitalChannelController.Mode.OUTPUT); + + // wait for the start button to be pressed. + telemetry.addData(">", "Press play, and then user X button to set DigOut"); + telemetry.update(); + waitForStart(); + + while (opModeIsActive()) { + + outputPin = gamepad1.x ; // Set the output pin based on x button + digOut.setState(outputPin); + inputPin = digIn.getState(); // Read the input pin + + // Display input pin state on LEDs + if (inputPin) { + dim.setLED(RED_LED_CHANNEL, true); + dim.setLED(BLUE_LED_CHANNEL, false); + } + else { + dim.setLED(RED_LED_CHANNEL, false); + dim.setLED(BLUE_LED_CHANNEL, true); + } + + telemetry.addData("Output", outputPin ); + telemetry.addData("Input", inputPin ); + telemetry.addData("LED", inputPin ? "Red" : "Blue" ); + telemetry.update(); + } + } +} diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorHTColor.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorHTColor.java index 094b27e7148..28a64e90dec 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorHTColor.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorHTColor.java @@ -45,7 +45,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * * This is an example LinearOpMode that shows how to use * a legacy (NXT-compatible) Hitechnic Color Sensor v2. - * It assumes that the color sensor is configured with a name of "color sensor". + * It assumes that the color sensor is configured with a name of "sensor_color". * * You can use the X button on gamepad1 to toggle the LED on and off. * @@ -60,7 +60,7 @@ public class SensorHTColor extends LinearOpMode { @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { // hsvValues is an array that will hold the hue, saturation, and value information. float hsvValues[] = {0F,0F,0F}; @@ -80,7 +80,7 @@ public void runOpMode() throws InterruptedException { boolean bLedOn = true; // get a reference to our ColorSensor object. - colorSensor = hardwareMap.colorSensor.get("color sensor"); + colorSensor = hardwareMap.colorSensor.get("sensor_color"); // turn the LED on in the beginning, just so user will know that the sensor is active. colorSensor.enableLed(bLedOn); @@ -128,7 +128,6 @@ public void run() { }); telemetry.update(); - idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop } } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorLEGOLight.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorLEGOLight.java index 5c808adefac..eb6c19e44fc 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorLEGOLight.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorLEGOLight.java @@ -47,7 +47,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * * This is an example LinearOpMode that shows how to use * a legacy (NXT-compatible) Light Sensor. - * It assumes that the light sensor is configured with a name of "light sensor". + * It assumes that the light sensor is configured with a name of "sensor_light". * * You can use the X button on gamepad1 to turn Toggle the LED on and off. * @@ -61,7 +61,7 @@ public class SensorLEGOLight extends LinearOpMode { LightSensor lightSensor; // Hardware Device Object @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { // bPrevState and bCurrState represent the previous and current state of the button. boolean bPrevState = false; @@ -71,7 +71,7 @@ public void runOpMode() throws InterruptedException { boolean bLedOn = true; // get a reference to our Light Sensor object. - lightSensor = hardwareMap.lightSensor.get("light sensor"); + lightSensor = hardwareMap.lightSensor.get("sensor_light"); // Set the LED state in the beginning. lightSensor.enableLed(bLedOn); @@ -103,7 +103,6 @@ public void runOpMode() throws InterruptedException { telemetry.addData("Normal", lightSensor.getLightDetected()); telemetry.update(); - idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop } } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorLEGOTouch.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorLEGOTouch.java index 9a64934825d..fbfd47f1664 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorLEGOTouch.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorLEGOTouch.java @@ -40,7 +40,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE /* * This is an example LinearOpMode that shows how to use * a legacy (NXT-compatible) Touch Sensor. - * It assumes that the touch sensor is configured with a name of "touch sensor". + * It assumes that the touch sensor is configured with a name of "sensor_touch". * * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name. * Remove or comment out the @Disabled line to add this opmode to the Driver Station OpMode list @@ -52,10 +52,10 @@ public class SensorLEGOTouch extends LinearOpMode { TouchSensor touchSensor; // Hardware Device Object @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { // get a reference to our Light Sensor object. - touchSensor = hardwareMap.touchSensor.get("touch sensor"); + touchSensor = hardwareMap.touchSensor.get("sensor_touch"); int counter = 0; // wait for the start button to be pressed. @@ -63,7 +63,7 @@ public void runOpMode() throws InterruptedException { // while the op mode is active, loop and read the light levels. // Note we use opModeIsActive() as our loop condition because it is an interruptible method. - while (true) { + while (opModeIsActive()) { // send the info back to driver station using telemetry function. if (touchSensor.isPressed()) @@ -72,7 +72,6 @@ public void runOpMode() throws InterruptedException { telemetry.addData("Touch", "Is Not Pressed"); telemetry.update(); - idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop } } } 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 e38086f6461..7a2dbda90e0 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 @@ -47,7 +47,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * a Modern Robotics Color Sensor. * * The op mode assumes that the color sensor - * is configured with a name of "color sensor". + * is configured with a name of "sensor_color". * * You can use the X button on gamepad1 to toggle the LED on and off. * @@ -62,7 +62,7 @@ public class SensorMRColor extends LinearOpMode { @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { // hsvValues is an array that will hold the hue, saturation, and value information. float hsvValues[] = {0F,0F,0F}; @@ -82,7 +82,7 @@ public void runOpMode() throws InterruptedException { boolean bLedOn = true; // get a reference to our ColorSensor object. - colorSensor = hardwareMap.colorSensor.get("color sensor"); + colorSensor = hardwareMap.colorSensor.get("sensor_color"); // Set the LED in the beginning colorSensor.enableLed(bLedOn); @@ -129,7 +129,6 @@ public void run() { }); telemetry.update(); - idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop } } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRCompass.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRCompass.java index f030e1bb3f9..f1045d8f67f 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRCompass.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRCompass.java @@ -59,7 +59,7 @@ public class SensorMRCompass extends LinearOpMode { ModernRoboticsI2cCompassSensor compass; ElapsedTime timer = new ElapsedTime(); - @Override public void runOpMode() throws InterruptedException { + @Override public void runOpMode() { // get a reference to our compass compass = hardwareMap.get(ModernRoboticsI2cCompassSensor.class, "compass"); @@ -116,7 +116,6 @@ public class SensorMRCompass extends LinearOpMode { } doTelemetry(); - idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop } } 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 4226b200584..95c98dc9a53 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 @@ -53,7 +53,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE public class SensorMRGyro extends LinearOpMode { @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { ModernRoboticsI2cGyro gyro; // Hardware Device Object int xVal, yVal, zVal = 0; // Gyro rate Values @@ -71,8 +71,8 @@ public void runOpMode() throws InterruptedException { gyro.calibrate(); // make sure the gyro is calibrated. - while (gyro.isCalibrating()) { - Thread.sleep(50); + while (!isStopRequested() && gyro.isCalibrating()) { + sleep(50); idle(); } @@ -109,7 +109,6 @@ public void runOpMode() throws InterruptedException { telemetry.addData("3", "Y av. %03d", yVal); telemetry.addData("4", "Z av. %03d", zVal); telemetry.update(); - idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop } } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRIrSeeker.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRIrSeeker.java index 7336c04015c..cfeae7bff11 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRIrSeeker.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRIrSeeker.java @@ -43,7 +43,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * the Modern Robotics ITR Seeker * * The op mode assumes that the IR Seeker - * is configured with a name of "ir seeker". + * is configured with a name of "sensor_ir". * * Set the switch on the Modern Robotics IR beacon to 1200 at 180.
* Turn on the IR beacon. @@ -57,12 +57,12 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE public class SensorMRIrSeeker extends LinearOpMode { @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { IrSeekerSensor irSeeker; // Hardware Device Object // get a reference to our GyroSensor object. - irSeeker = hardwareMap.irSeekerSensor.get("seeker"); + irSeeker = hardwareMap.irSeekerSensor.get("sensor_ir"); // wait for the start button to be pressed. waitForStart(); @@ -83,7 +83,6 @@ public void runOpMode() throws InterruptedException { } telemetry.update(); - idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop } } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMROpticalDistance.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMROpticalDistance.java index f75f6046cd8..2f33ab2b132 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMROpticalDistance.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMROpticalDistance.java @@ -39,7 +39,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE /* * This is an example LinearOpMode that shows how to use * a Modern Robotics Optical Distance Sensor - * It assumes that the ODS sensor is configured with a name of "ods sensor". + * It assumes that the ODS sensor is configured with a name of "sensor_ods". * * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name. * Remove or comment out the @Disabled line to add this opmode to the Driver Station OpMode list @@ -51,10 +51,10 @@ public class SensorMROpticalDistance extends LinearOpMode { OpticalDistanceSensor odsSensor; // Hardware Device Object @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { // get a reference to our Light Sensor object. - odsSensor = hardwareMap.opticalDistanceSensor.get("ods"); + odsSensor = hardwareMap.opticalDistanceSensor.get("sensor_ods"); // wait for the start button to be pressed. waitForStart(); @@ -68,7 +68,6 @@ public void runOpMode() throws InterruptedException { telemetry.addData("Normal", odsSensor.getLightDetected()); telemetry.update(); - idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop } } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRRangeSensor.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRRangeSensor.java index a606d88376a..e98ba139fc0 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRRangeSensor.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRRangeSensor.java @@ -43,7 +43,7 @@ are permitted (subject to the limitations in the disclaimer below) provided that * {@link SensorMRRangeSensor} illustrates how to use the Modern Robotics * Range Sensor. * - * The op mode assumes that the range sensor is configured with a name of "range sensor". + * The op mode assumes that the range sensor is configured with a name of "sensor_range". * * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name. * Remove or comment out the @Disabled line to add this opmode to the Driver Station OpMode list @@ -56,10 +56,10 @@ public class SensorMRRangeSensor extends LinearOpMode { ModernRoboticsI2cRangeSensor rangeSensor; - @Override public void runOpMode() throws InterruptedException { + @Override public void runOpMode() { // get a reference to our compass - rangeSensor = hardwareMap.get(ModernRoboticsI2cRangeSensor.class, "range sensor"); + rangeSensor = hardwareMap.get(ModernRoboticsI2cRangeSensor.class, "sensor_range"); // wait for the start button to be pressed waitForStart(); @@ -70,7 +70,6 @@ public class SensorMRRangeSensor extends LinearOpMode { telemetry.addData("cm optical", "%.2f cm", rangeSensor.cmOptical()); telemetry.addData("cm", "%.2f cm", rangeSensor.getDistance(DistanceUnit.CM)); telemetry.update(); - idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop } } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/TemplateOpMode_Iterative.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/TemplateOpMode_Iterative.java index 662a3ecc08a..d1186ad310e 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/TemplateOpMode_Iterative.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/TemplateOpMode_Iterative.java @@ -78,8 +78,8 @@ public void init() { * to 'get' must correspond to the names assigned during the robot configuration * step (using the FTC Robot Controller app on the phone). */ - // leftMotor = hardwareMap.dcMotor.get("left motor"); - // rightMotor = hardwareMap.dcMotor.get("right motor"); + // leftMotor = hardwareMap.dcMotor.get("left_drive"); + // rightMotor = hardwareMap.dcMotor.get("right_drive"); // eg: Set the drive motor directions: // Reverse the motor that runs backwards when connected directly to the battery diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/TemplateOpMode_Linear.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/TemplateOpMode_Linear.java index 2556832a5b7..86eb3d57b7e 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/TemplateOpMode_Linear.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/TemplateOpMode_Linear.java @@ -62,7 +62,7 @@ public class TemplateOpMode_Linear extends LinearOpMode { // DcMotor rightMotor = null; @Override - public void runOpMode() throws InterruptedException { + public void runOpMode() { telemetry.addData("Status", "Initialized"); telemetry.update(); @@ -70,8 +70,8 @@ public void runOpMode() throws InterruptedException { * to 'get' must correspond to the names assigned during the robot configuration * step (using the FTC Robot Controller app on the phone). */ - // leftMotor = hardwareMap.dcMotor.get("left motor"); - // rightMotor = hardwareMap.dcMotor.get("right motor"); + // leftMotor = hardwareMap.dcMotor.get("left_drive"); + // rightMotor = hardwareMap.dcMotor.get("right_drive"); // eg: Set the drive motor directions: // "Reverse" the motor that runs backwards when connected directly to the battery @@ -90,8 +90,6 @@ public void runOpMode() throws InterruptedException { // eg: Run wheels in tank mode (note: The joystick goes negative when pushed forwards) // leftMotor.setPower(-gamepad1.left_stick_y); // rightMotor.setPower(-gamepad1.right_stick_y); - - idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop } } } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/sample_conventions.md b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/sample_conventions.md index 1a1c3b4578c..9366862b49c 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/sample_conventions.md +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/sample_conventions.md @@ -65,15 +65,31 @@ becomes obsolete. ### Device Configuration Names -The textual device names (assigned to a device during the robot configuration process) should -be unambiguous, and be constructed to allow easy entry on the phone keypad. - -This dictates that ONLY lower case letters, and the space character should be used. -The names should be functional descriptions which can be used to trace wiring (eg: left motor). -Avoid assigning numeric designations which don’t help with troubleshooting. - -* Examples of good names are: “tool”, “left motor”, “right claw servo”, “rear light sensor” -* Examples of bad names would be: “Left_Motor”, “motor_1”, “Servo#2”. +The following device names are used in the external samples + +** Motors +left_drive +right_drive +left_arm + +** Servos +left_hand +right_hand +arm +claw + +** Sensors +sensor_color +sensor_ir +sensor_light +sensor_ods +sensor_range +sensor_touch + +** Localization +compass +gyro +imu ### Device Object Names 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 831daf208ae..39439399531 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 @@ -194,6 +194,7 @@ protected void passReceivedUsbAttachmentsToEventLoop() { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + RobotLog.writeLogcatToDisk(); RobotLog.vv(TAG, "onCreate()"); receivedUsbAttachmentNotifications = new ConcurrentLinkedQueue(); @@ -252,8 +253,6 @@ public void onClick(View v) { if (USE_DEVICE_EMULATION) { HardwareFactory.enableDeviceEmulation(); } - // save 4MB of logcat to the SD card - RobotLog.writeLogcatToDisk(this, 4 * 1024); wifiLock.acquire(); callback.networkConnectionUpdate(WifiDirectAssistant.Event.DISCONNECTED); bindToService(); @@ -326,7 +325,7 @@ public void onDestroy() { unbindFromService(); wifiLock.release(); - RobotLog.cancelWriteLogcatToDisk(this); + RobotLog.cancelWriteLogcatToDisk(); } protected void bindToService() { diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/MatrixControllerDemo.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/MatrixControllerDemo.java deleted file mode 100644 index 2ac4adf2d97..00000000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/MatrixControllerDemo.java +++ /dev/null @@ -1,238 +0,0 @@ -/* Copyright (c) 2015 Craig MacFarlane - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted (subject to the limitations in the disclaimer below) provided that -the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of Craig MacFarlane nor the names of its contributors -may be used to endorse or promote products derived from this software without -specific prior written permission. - -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS -LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -package org.firstinspires.ftc.robotcontroller.internal.testcode; - -import com.qualcomm.hardware.matrix.MatrixDcMotorController; -import com.qualcomm.robotcore.eventloop.opmode.Autonomous; -import com.qualcomm.robotcore.eventloop.opmode.Disabled; -import com.qualcomm.robotcore.eventloop.opmode.OpMode; -import com.qualcomm.robotcore.hardware.DcMotor; -import com.qualcomm.robotcore.hardware.Servo; -import com.qualcomm.robotcore.hardware.ServoController; -import com.qualcomm.robotcore.util.ElapsedTime; - -import java.util.HashSet; -import java.util.Set; - -/** - * A simple example of all motors and servos oscillating - */ -@Autonomous(name = "MatrixControllerDemo", group = "Examples") -@Disabled -public class MatrixControllerDemo extends OpMode { - - private ElapsedTime motorOscTimer = new ElapsedTime(0); - private ElapsedTime servoOscTimer = new ElapsedTime(0); - private ElapsedTime spamPrevention = new ElapsedTime(0); - - private DcMotor motor1; - private DcMotor motor2; - private DcMotor motor3; - private DcMotor motor4; - private Set motorSet = new HashSet(); - - private Servo servo1; - private Servo servo2; - private Servo servo3; - private Servo servo4; - - private MatrixDcMotorController mc; - private ServoController sc; - - private boolean loopOnce = false; - private boolean firstMotors = true; - private boolean firstServos = true; - private boolean firstBattery = true; - private int battery; - - private final static double MOTOR_OSC_FREQ = 2.0; - private final static double SERVO_OSC_FREQ = 1.0; - private final static double SPAM_PREVENTION_FREQ = 1.0; - - private double motorPower = 1.0; - private double servoPosition = 0.0; - - @Override - public void init() - { - motor1 = hardwareMap.dcMotor.get("motor_1"); - motor2 = hardwareMap.dcMotor.get("motor_2"); - motor3 = hardwareMap.dcMotor.get("motor_3"); - motor4 = hardwareMap.dcMotor.get("motor_4"); - - /* - * A set of motors to use with the Matrix motor controller's - * pending feature. See example below. Note that this is - * completely optional. - */ - motorSet.add(motor1); - motorSet.add(motor2); - motorSet.add(motor3); - motorSet.add(motor4); - - servo1 = hardwareMap.servo.get("servo_1"); - servo2 = hardwareMap.servo.get("servo_2"); - servo3 = hardwareMap.servo.get("servo_3"); - servo4 = hardwareMap.servo.get("servo_4"); - - /* - * Matrix controllers are special. - * - * A Matrix controller is one controller with both motors and servos - * but software wants to treat it as two distinct controllers, one - * DcMotorController, and one ServoController. - * - * We accomplish this by appending Motor and Servo to the name - * given in the configuration. In the example below the name - * of the controller is "MatrixController" so the motor controller - * instance is "MatrixControllerMotor" and the servo controller - * instance is "MatrixControllerServo". - */ - mc = (MatrixDcMotorController)hardwareMap.dcMotorController.get("MatrixController"); - motor1.setMode(DcMotor.RunMode.RUN_USING_ENCODER); - motor2.setMode(DcMotor.RunMode.RUN_USING_ENCODER); - motor3.setMode(DcMotor.RunMode.RUN_USING_ENCODER); - motor4.setMode(DcMotor.RunMode.RUN_USING_ENCODER); - - /* - * Servos are not enabled by default. Software must call pwmEnable() - * for servos to function. - */ - sc = hardwareMap.servoController.get("MatrixController"); - sc.pwmEnable(); - } - - @Override - public void start() - { - motorOscTimer.reset(); - servoOscTimer.reset(); - spamPrevention.reset(); - } - - @Override - public void stop() - { - /* - * An example of setting power for individual motors as normal. - * - * For the Matrix controller, the methods take effect immediately - * as each call to setPower(), or any other method that interacts - * with the controller, is transformed into an i2c transaction and - * queued. A separate thread is processing the queue. - * - * In practice this means that the first call to setPower will - * be applied 20 to 40 milliseconds before the last call as the - * processing thread works through the queue. Testing - * has shown that this latency is not large enough to have any - * real world negative impacts, however teams may choose to use - * the controller's setMotorPower() method if they desire precise - * simultaneous motor operations. See example in handleMotors(). - */ - motor1.setPower(0.0); - motor2.setPower(0.0); - motor3.setPower(0.0); - motor4.setPower(0.0); - sc.pwmDisable(); - } - - /* - * handleMotors - * - * Oscillate the motors. - */ - protected void handleMotors() - { - if ((firstMotors) || (motorOscTimer.time() > MOTOR_OSC_FREQ)) { - motorPower = -motorPower; - - /* - * The MatrixDcMotorController's setMotorPower() method may take - * a collection of motors. If this is chosen, then the controller will - * set a pending bit. The pending bit tells the controller to - * defer turning on, or changing the current set point, for a motor - * until the pending bit is cleared. - * - * When the pending bit is cleared all motor power values are applied - * simultaneously. setMotorPower() handles the pending bit for you. - */ - mc.setMotorPower(motorSet, motorPower); - motorOscTimer.reset(); - firstMotors = false; - } - } - - /* - * handleServos - * - * Oscillate the servos. - */ - protected void handleServos() - { - if ((firstServos) || (servoOscTimer.time() > SERVO_OSC_FREQ)) { - if (servoPosition == 0.0) { - servoPosition = 1.0; - } else { - servoPosition = 0.0; - } - servo1.setPosition(servoPosition); - servo2.setPosition(servoPosition); - servo3.setPosition(servoPosition); - servo4.setPosition(servoPosition); - servoOscTimer.reset(); - firstServos = false; - } - } - - /* - * handleBattery - * - * The Matrix controller has a separate battery whose voltage can be read. - */ - protected void handleBattery() - { - if ((firstBattery) || (spamPrevention.time() > SPAM_PREVENTION_FREQ)) { - battery = mc.getBattery(); - spamPrevention.reset(); - firstBattery = false; - } - telemetry.addData("Battery: ", ((float)battery/1000)); - } - - @Override - public void loop() - { - handleMotors(); - handleServos(); - handleBattery(); - } -} diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestBrakeFloat.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestBrakeFloat.java deleted file mode 100644 index 3b3fe534c6c..00000000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestBrakeFloat.java +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright (c) 2016 Robert Atkinson - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted (subject to the limitations in the disclaimer below) provided that -the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of Robert Atkinson nor the names of his contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS -LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -package org.firstinspires.ftc.robotcontroller.internal.testcode; - -import com.qualcomm.robotcore.eventloop.opmode.Autonomous; -import com.qualcomm.robotcore.eventloop.opmode.Disabled; -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; -import com.qualcomm.robotcore.hardware.DcMotor; - -/** - * An opmode that simply tests the brake and float behavior. - */ -@Autonomous(name="Test Brake/Float", group ="Tests") -@Disabled -public class TestBrakeFloat extends LinearOpMode - { - DcMotor motorLeft; - DcMotor motorRight; - - @Override - public void runOpMode() throws InterruptedException - { - motorLeft = this.hardwareMap.dcMotor.get("motorLeft"); - motorRight = this.hardwareMap.dcMotor.get("motorRight"); - - motorLeft.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER); - motorRight.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER); - - waitForStart(); - - int msInterval = 1500; - double power = 0.75; - while (opModeIsActive()) - { - motorLeft.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE); - motorRight.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE); - - motorLeft.setPower(power); - motorRight.setPower(power); - Thread.sleep(msInterval); - - motorLeft.setPower(0.0); - motorRight.setPower(0.0); - Thread.sleep(msInterval); - - - motorLeft.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.FLOAT); - motorRight.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.FLOAT); - - motorLeft.setPower(power); - motorRight.setPower(power); - Thread.sleep(msInterval); - - motorLeft.setPower(0.0); - motorRight.setPower(0.0); - Thread.sleep(msInterval); - } - } - - } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestCRServo.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestCRServo.java deleted file mode 100644 index 137cbaeae76..00000000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestCRServo.java +++ /dev/null @@ -1,63 +0,0 @@ -/* -Copyright (c) 2016 Robert Atkinson - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted (subject to the limitations in the disclaimer below) provided that -the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of Robert Atkinson nor the names of his contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS -LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -package org.firstinspires.ftc.robotcontroller.internal.testcode; - -import com.qualcomm.robotcore.eventloop.opmode.Autonomous; -import com.qualcomm.robotcore.eventloop.opmode.Disabled; -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; -import com.qualcomm.robotcore.hardware.CRServo; - -/** - * A simple test of a continuous rotation servo - */ -@Autonomous(name="Test CR Servo", group ="Tests") -@Disabled -public class TestCRServo extends LinearOpMode - { - @Override - public void runOpMode() throws InterruptedException - { - CRServo servo = this.hardwareMap.crservo.get("crservo"); - - waitForStart(); - - servo.setPower(1.0); - Thread.sleep(4000); - - servo.setPower(0.0); - Thread.sleep(1000); - - servo.setPower(-1.0); - Thread.sleep(4000); - } - } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestColorSensors.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestColorSensors.java deleted file mode 100644 index 3506b487c46..00000000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestColorSensors.java +++ /dev/null @@ -1,127 +0,0 @@ -/* Copyright (c) 2015 Qualcomm Technologies Inc - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted (subject to the limitations in the disclaimer below) provided that -the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of Qualcomm Technologies Inc nor the names of its contributors -may be used to endorse or promote products derived from this software without -specific prior written permission. - -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS -LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -package org.firstinspires.ftc.robotcontroller.internal.testcode; - -import android.app.Activity; -import android.graphics.Color; -import android.view.View; - -import com.qualcomm.ftcrobotcontroller.R; -import com.qualcomm.robotcore.eventloop.opmode.Autonomous; -import com.qualcomm.robotcore.eventloop.opmode.Disabled; -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; -import com.qualcomm.robotcore.hardware.ColorSensor; -import com.qualcomm.robotcore.hardware.DeviceInterfaceModule; -import com.qualcomm.robotcore.hardware.LED; -import com.qualcomm.robotcore.hardware.TouchSensor; - -@Autonomous(name = "TestColorSensors", group = "Tests") -@Disabled -public class TestColorSensors extends LinearOpMode { - - public enum ColorSensorDevice {ADAFRUIT, HITECHNIC_NXT, MODERN_ROBOTICS_I2C}; - - public ColorSensorDevice device = ColorSensorDevice.MODERN_ROBOTICS_I2C; - - ColorSensor colorSensor; - DeviceInterfaceModule cdim; - LED led; - TouchSensor t; - - @Override - public void runOpMode() throws InterruptedException { - hardwareMap.logDevices(); - - cdim = hardwareMap.deviceInterfaceModule.get("dim"); - switch (device) { - case HITECHNIC_NXT: - colorSensor = hardwareMap.colorSensor.get("nxt"); - break; - case ADAFRUIT: - colorSensor = hardwareMap.colorSensor.get("lady"); - break; - case MODERN_ROBOTICS_I2C: - colorSensor = hardwareMap.colorSensor.get("mr"); - break; - } - led = hardwareMap.led.get("led"); - t = hardwareMap.touchSensor.get("t"); - - waitForStart(); - - float hsvValues[] = {0,0,0}; - final float values[] = hsvValues; - final View relativeLayout = ((Activity) hardwareMap.appContext).findViewById(R.id.RelativeLayout); - while (opModeIsActive()) { - - enableLed(t.isPressed()); - - switch (device) { - case HITECHNIC_NXT: - Color.RGBToHSV(colorSensor.red(), colorSensor.green(), colorSensor.blue(), hsvValues); - break; - case ADAFRUIT: - Color.RGBToHSV((colorSensor.red() * 255) / 800, (colorSensor.green() * 255) / 800, (colorSensor.blue() * 255) / 800, hsvValues); - break; - case MODERN_ROBOTICS_I2C: - Color.RGBToHSV(colorSensor.red()*8, colorSensor.green()*8, colorSensor.blue()*8, hsvValues); - break; - } - telemetry.addData("Clear", colorSensor.alpha()); - telemetry.addData("Red ", colorSensor.red()); - telemetry.addData("Green", colorSensor.green()); - telemetry.addData("Blue ", colorSensor.blue()); - telemetry.addData("Hue", hsvValues[0]); - - relativeLayout.post(new Runnable() { - public void run() { - relativeLayout.setBackgroundColor(Color.HSVToColor(0xff, values)); - } - }); - waitOneFullHardwareCycle(); - } - } - - private void enableLed(boolean value) { - switch (device) { - case HITECHNIC_NXT: - colorSensor.enableLed(value); - break; - case ADAFRUIT: - led.enable(value); - break; - case MODERN_ROBOTICS_I2C: - colorSensor.enableLed(value); - break; - } - } -} \ No newline at end of file diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestDriveLinear.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestDriveLinear.java deleted file mode 100644 index 4c9cae6c695..00000000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestDriveLinear.java +++ /dev/null @@ -1,86 +0,0 @@ -/* -Copyright (c) 2016 Robert Atkinson - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted (subject to the limitations in the disclaimer below) provided that -the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of Robert Atkinson nor the names of his contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS -LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -package org.firstinspires.ftc.robotcontroller.internal.testcode; - -import com.qualcomm.robotcore.eventloop.opmode.Autonomous; -import com.qualcomm.robotcore.eventloop.opmode.Disabled; -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; -import com.qualcomm.robotcore.hardware.DcMotor; - -/** - * A simple test of a pair of motors - */ -@Autonomous(name="Test Two Motors", group ="Tests") -@Disabled -public class TestDriveLinear extends LinearOpMode - { - DcMotor motorLeft; - DcMotor motorRight; - - @Override - public void runOpMode() throws InterruptedException - { - motorLeft = this.hardwareMap.dcMotor.get("motorLeft"); - motorRight = this.hardwareMap.dcMotor.get("motorRight"); - - motorLeft.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER); - motorRight.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER); - - waitForStart(); - runMotorsBothDirections(1.0); - - Thread.sleep(500); - runMotorsBothDirections(0.1); - - Thread.sleep(500); - runMotorsBothDirections(1.0); - } - - void runMotorsBothDirections(double power) throws InterruptedException - { - motorLeft.setPower(-power); - motorRight.setPower(power); - - Thread.sleep(2000); - motorLeft.setPower(0); - motorRight.setPower(0); - - Thread.sleep(500); - motorLeft.setPower(power); - motorRight.setPower(-power); - - Thread.sleep(2000); - motorLeft.setPower(0); - motorRight.setPower(0); - } - } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestInfiniteLoopIterative.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestInfiniteLoopIterative.java deleted file mode 100644 index 6c5755b8f37..00000000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestInfiniteLoopIterative.java +++ /dev/null @@ -1,63 +0,0 @@ -/* -Copyright (c) 2016 Robert Atkinson - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted (subject to the limitations in the disclaimer below) provided that -the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of Robert Atkinson nor the names of his contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS -LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -package org.firstinspires.ftc.robotcontroller.internal.testcode; - -import com.qualcomm.robotcore.eventloop.opmode.Disabled; -import com.qualcomm.robotcore.eventloop.opmode.OpMode; -import com.qualcomm.robotcore.eventloop.opmode.TeleOp; - -/** - * {@link TestInfiniteLoopIterative} is a simple test that runs an infinite loop - */ -@TeleOp(name = "Test: Infinite Loop (Iterative)", group = "Tests") -@Disabled -public class TestInfiniteLoopIterative extends OpMode { - - @Override public void init() - { - // Nothing to do - } - - @Override public void loop() { - - telemetry.addData("message", "starting infinite loop..."); - updateTelemetry(telemetry); - - // Do nothing, forever - for (int count = 0; ; count++) { - telemetry.addData("count", count); - updateTelemetry(telemetry); - Thread.yield(); - } - } -} diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestInfiniteLoopLinear.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestInfiniteLoopLinear.java deleted file mode 100644 index c7ed6193591..00000000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestInfiniteLoopLinear.java +++ /dev/null @@ -1,61 +0,0 @@ -/* -Copyright (c) 2016 Robert Atkinson - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted (subject to the limitations in the disclaimer below) provided that -the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of Robert Atkinson nor the names of his contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS -LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -package org.firstinspires.ftc.robotcontroller.internal.testcode; - -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; -import com.qualcomm.robotcore.eventloop.opmode.TeleOp; -import com.qualcomm.robotcore.eventloop.opmode.Disabled; - -/** - * {@link TestInfiniteLoopLinear} is a simple test that runs an infinite loop - */ -@TeleOp(name = "Test: Infinite Loop (Linear)", group = "Tests") -@Disabled -public class TestInfiniteLoopLinear extends LinearOpMode { - - @Override public void runOpMode() throws InterruptedException { - - waitForStart(); - - // Do nothing, forever - for (int count = 0; ; count++) { - try { - telemetry.addData("count", count); - updateTelemetry(telemetry); - idle(); - } catch (InterruptedException e) { - // ignore: we're trying to do an infinite loop! - } - } - } -} diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestMaxSpeed.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestMaxSpeed.java deleted file mode 100644 index 7a0e79d778c..00000000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestMaxSpeed.java +++ /dev/null @@ -1,119 +0,0 @@ -/* -Copyright (c) 2016 Robert Atkinson - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted (subject to the limitations in the disclaimer below) provided that -the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of Robert Atkinson nor the names of his contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS -LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -package org.firstinspires.ftc.robotcontroller.internal.testcode; - -import com.qualcomm.robotcore.eventloop.opmode.Autonomous; -import com.qualcomm.robotcore.eventloop.opmode.Disabled; -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; -import com.qualcomm.robotcore.hardware.DcMotor; -import com.qualcomm.robotcore.hardware.configuration.HiTechnicConstants; - -/** - * Drives in a straight line at 1.0 power but with various max speed levels. - */ -@Autonomous(name="Test Max Speed", group ="Tests") -@Disabled -public class TestMaxSpeed extends LinearOpMode - { - // All hardware variables can only be initialized inside the main() function, - // not here at their member variable declarations. - DcMotor motorLeft = null; - DcMotor motorRight = null; - - @Override - public void runOpMode() throws InterruptedException - { - // Initialize our hardware variables. Note that the strings used here as parameters - // to 'get' must correspond to the names you assigned during the robot configuration - // step you did in the FTC Robot Controller app on the phone. - this.motorLeft = this.hardwareMap.dcMotor.get("motorLeft"); - this.motorRight = this.hardwareMap.dcMotor.get("motorRight"); - - // Configure the knobs of the hardware according to how you've wired your robot. - DcMotor.RunMode mode = DcMotor.RunMode.RUN_USING_ENCODER; - this.motorLeft.setMode(mode); - this.motorRight.setMode(mode); - - // One of the two motors (here, the left) should be set to reversed direction - // so that it can take the same power level values as the other motor. - this.motorLeft.setDirection(DcMotor.Direction.REVERSE); - - // Wait until we've been given the ok to go - this.waitForStart(); - - // Drive in a line at various speeds - for (int degreesPerSecond = 300; degreesPerSecond <= 1000; degreesPerSecond += 100) - { - int ticksPerSecond = ticksPerSecFromDegsPerSec(degreesPerSecond); - this.motorLeft.setMaxSpeed(ticksPerSecond); - this.motorRight.setMaxSpeed(ticksPerSecond); - - telemetry.addData("deg/s", degreesPerSecond); - telemetry.addData("ticks/s", ticksPerSecond); - updateTelemetry(telemetry); - - // Drive for a while, then stop - this.motorLeft.setPower(1); - this.motorRight.setPower(1); - - long msDeadline = System.currentTimeMillis() + 3000; - while (System.currentTimeMillis() < msDeadline) - { - Thread.yield(); - telemetry.addData("deg/s", degreesPerSecond); - telemetry.addData("ticks/s", ticksPerSecond); - telemetry.addData("left", motorLeft.getCurrentPosition()); - telemetry.addData("right", motorRight.getCurrentPosition()); - updateTelemetry(telemetry); - } - - this.motorRight.setPower(0); - this.motorLeft.setPower(0); - - Thread.sleep(3000); - } - } - - /** Computes the number of encoder ticks per second that correspond to given desired - * rotational rate. To perform this computation, the number of encoder ticks per second - * is required, which is motor dependent. Be sure to adjust the values here accordingly - * for the motors you are actually using. */ - int ticksPerSecFromDegsPerSec(int degreesPerSecond) - { - final int encoderTicksPerRevolution = HiTechnicConstants.TETRIX_MOTOR_TICKS_PER_REVOLUTION; // assume Tetrix motors; change if you use different motors! - final int degreesPerRevolution = 360; - - return encoderTicksPerRevolution * degreesPerSecond / degreesPerRevolution; - } - - } \ No newline at end of file diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestMotorControllerFlavors.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestMotorControllerFlavors.java deleted file mode 100644 index 4d1f2ec62a3..00000000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestMotorControllerFlavors.java +++ /dev/null @@ -1,161 +0,0 @@ -/* -Copyright (c) 2016 Robert Atkinson - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted (subject to the limitations in the disclaimer below) provided that -the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of Robert Atkinson nor the names of his contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS -LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -package org.firstinspires.ftc.robotcontroller.internal.testcode; - -import com.qualcomm.robotcore.eventloop.opmode.Autonomous; -import com.qualcomm.robotcore.eventloop.opmode.Disabled; -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; -import com.qualcomm.robotcore.hardware.DcMotor; -import com.qualcomm.robotcore.hardware.I2cControllerPortDevice; -import com.qualcomm.robotcore.hardware.usb.RobotArmingStateNotifier; -import com.qualcomm.robotcore.util.RobotLog; - -/** - * {@link TestMotorControllerFlavors} is a simple test that explores the behavior of - */ -@Autonomous(name = "Test MC Flavors", group = "Tests") -@Disabled -public class TestMotorControllerFlavors extends LinearOpMode - { - // We don't require all of these motors to be attached; we'll deal with what we find - DcMotor legacyMotor; - DcMotor v15Motor; - DcMotor v2Motor; - - @Override public void runOpMode() throws InterruptedException - { - legacyMotor = findMotor("legacy motor"); - v15Motor = findMotor("v1.5 motor"); - v2Motor = findMotor("v2 motor"); - - setModes(DcMotor.RunMode.STOP_AND_RESET_ENCODER); - setModes(DcMotor.RunMode.RUN_USING_ENCODER); - - waitForStart(); - - // Make the encoders be something other than zero - reportMotors(); - setPowers(0.5); - Thread.sleep(3000); - setPowers(0); - reportMotors(); - Thread.sleep(3000); - reportMotors(); - - setModes(DcMotor.RunMode.STOP_AND_RESET_ENCODER); - - // Sit there and watch the motors - while (opModeIsActive()) - { - reportMotors(); - idle(); - } - } - - DcMotor findMotor(String motorName) - { - try { - DcMotor motor = hardwareMap.dcMotor.get(motorName); - - // Find which device is the USB device - RobotArmingStateNotifier usbDevice = null; - if (motor.getController() instanceof RobotArmingStateNotifier) - { - usbDevice = (RobotArmingStateNotifier) motor.getController(); - } - else if (motor.getController() instanceof I2cControllerPortDevice) - { - I2cControllerPortDevice i2cControllerPortDevice = (I2cControllerPortDevice)motor.getController(); - if (i2cControllerPortDevice.getI2cController() instanceof RobotArmingStateNotifier) - { - usbDevice = (RobotArmingStateNotifier) i2cControllerPortDevice.getI2cController(); - } - } - - // Weed out controllers that aren't actually physically there (and so in pretend state) - if (usbDevice != null) - { - if (usbDevice.getArmingState() != RobotArmingStateNotifier.ARMINGSTATE.ARMED) - { - return null; - } - } - - return motor; - } - catch (Throwable ignored) - { - } - return null; - } - - void setModes(DcMotor.RunMode mode) - { - if (legacyMotor != null) legacyMotor.setMode(mode); - if (v15Motor != null) v15Motor.setMode(mode); - if (v2Motor != null) v2Motor.setMode(mode); - } - - void setPowers(double power) - { - if (legacyMotor != null) legacyMotor.setPower(power); - if (v15Motor != null) v15Motor.setPower(power); - if (v2Motor != null) v2Motor.setPower(power); - } - - void reportMotors() - { - telemetry.addData("Motor Report", ""); - reportMotor("legacy motor: ", legacyMotor); - reportMotor("v1.5 motor: ", v15Motor); - reportMotor("v2 motor: ", v2Motor); - telemetry.update(); - } - - void reportMotor(String caption, DcMotor motor) - { - if (motor != null) - { - int position = motor.getCurrentPosition(); - DcMotor.RunMode mode = motor.getMode(); - - telemetry.addLine(caption) - .addData("pos", "%d", position) - .addData("mode", "%s", mode.toString()); - - RobotLog.i("%s pos=%d mode=%s", caption, position, mode.toString()); - } - } - - } - diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestMotorModeSwitch.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestMotorModeSwitch.java deleted file mode 100644 index 4f70f6a5fae..00000000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestMotorModeSwitch.java +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright (c) 2016 Robert Atkinson - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted (subject to the limitations in the disclaimer below) provided that -the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of Robert Atkinson nor the names of his contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS -LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -package org.firstinspires.ftc.robotcontroller.internal.testcode; - -import com.qualcomm.robotcore.eventloop.opmode.Disabled; -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; -import com.qualcomm.robotcore.eventloop.opmode.TeleOp; -import com.qualcomm.robotcore.hardware.DcMotor; -import com.qualcomm.robotcore.util.RobotLog; - -/** - * This simple test stress-tests the motor mode switch logic in both the SDK - * and in the motor controller firmware. - */ -@TeleOp(name = "TestMotorModeSwitch", group = "Tests") -@Disabled -public class TestMotorModeSwitch extends LinearOpMode - { - DcMotor motor; - - public void runOpMode() throws InterruptedException - { - motor = hardwareMap.dcMotor.get("v1.5 motor"); - - DcMotor.RunMode[] modes = new DcMotor.RunMode[] - { - DcMotor.RunMode.RUN_WITHOUT_ENCODER, // 1 - DcMotor.RunMode.RUN_USING_ENCODER, // 2 - DcMotor.RunMode.STOP_AND_RESET_ENCODER, // 3 - - DcMotor.RunMode.RUN_WITHOUT_ENCODER, // 1 - DcMotor.RunMode.STOP_AND_RESET_ENCODER, // 3 - DcMotor.RunMode.RUN_USING_ENCODER, // 2 - - DcMotor.RunMode.RUN_USING_ENCODER, // 2 - DcMotor.RunMode.RUN_WITHOUT_ENCODER, // 1 - DcMotor.RunMode.STOP_AND_RESET_ENCODER, // 3 - - DcMotor.RunMode.RUN_USING_ENCODER, // 2 - DcMotor.RunMode.STOP_AND_RESET_ENCODER, // 3 - DcMotor.RunMode.RUN_WITHOUT_ENCODER, // 1 - - DcMotor.RunMode.STOP_AND_RESET_ENCODER, // 3 - DcMotor.RunMode.RUN_WITHOUT_ENCODER, // 1 - DcMotor.RunMode.RUN_USING_ENCODER, // 2 - - DcMotor.RunMode.STOP_AND_RESET_ENCODER, // 3 - DcMotor.RunMode.RUN_USING_ENCODER, // 2 - DcMotor.RunMode.RUN_WITHOUT_ENCODER, // 1 - }; - - waitForStart(); - - int count = 0; - while (opModeIsActive()) - { - DcMotor.RunMode mode = modes[count % modes.length]; - - motor.setMode(mode); - telemetry.addData("count", "%d", count++); - telemetry.addData("mode", "%s", motor.getMode()); - telemetry.update(); - idle(); - } - } - } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestMotorServoLinear.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestMotorServoLinear.java deleted file mode 100644 index 1e49efb1ac6..00000000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestMotorServoLinear.java +++ /dev/null @@ -1,93 +0,0 @@ -/* -Copyright (c) 2016 Robert Atkinson - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted (subject to the limitations in the disclaimer below) provided that -the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of Robert Atkinson nor the names of his contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS -LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -package org.firstinspires.ftc.robotcontroller.internal.testcode; - -import com.qualcomm.robotcore.eventloop.opmode.Autonomous; -import com.qualcomm.robotcore.eventloop.opmode.Disabled; -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; -import com.qualcomm.robotcore.hardware.DcMotor; -import com.qualcomm.robotcore.hardware.Servo; -import com.qualcomm.robotcore.util.ElapsedTime; - -/** - * A simple test that runs one motor and one servo at a time. - */ -@Autonomous(name = "TestMotorServo", group = "Tests") -@Disabled -public class TestMotorServoLinear extends LinearOpMode - { - @Override - public void runOpMode() throws InterruptedException - { - DcMotor motor = this.hardwareMap.dcMotor.get("motorRight"); - Servo servo = this.hardwareMap.servo.get("servo"); - - waitForStart(); - - double servoPosition = 0; - servo.setPosition(servoPosition); - - motor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER); - - ElapsedTime elapsedTime = new ElapsedTime(); - int spinCount = 0; - - while (this.opModeIsActive()) - { - servoPosition += 1. / 256.; - if (servoPosition >= 1) - servoPosition = 0; - servo.setPosition(servoPosition); - - motor.setPower(0.15); - - spinCount++; - double ms = elapsedTime.milliseconds(); - telemetry.addData("position", format(servoPosition)); - telemetry.addData("#spin", format(spinCount)); - telemetry.addData("ms/spin", format(ms / spinCount)); - this.updateTelemetry(telemetry); - } - - motor.setPower(0); - } - - static String format(double d) - { - return String.format("%.3f", d); - } - static String format(int i) - { - return String.format("%d", i); - } - } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestOpModeException.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestOpModeException.java deleted file mode 100644 index c2ff1c08fd8..00000000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestOpModeException.java +++ /dev/null @@ -1,53 +0,0 @@ -/* -Copyright (c) 2016 Robert Atkinson - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted (subject to the limitations in the disclaimer below) provided that -the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of Robert Atkinson nor the names of his contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS -LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -package org.firstinspires.ftc.robotcontroller.internal.testcode; - -import com.qualcomm.robotcore.eventloop.opmode.Autonomous; -import com.qualcomm.robotcore.eventloop.opmode.Disabled; -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; - -/** - * {@link TestOpModeException} is an opmode that simply throws an exception when started - */ -@Autonomous(name = "Test OpMode Exception", group = "Tests") -@Disabled -public class TestOpModeException extends LinearOpMode - { - @Override public void runOpMode() throws InterruptedException - { - waitForStart(); - - Thread.sleep(5000); - throw new RuntimeException("this is a runtime exception"); - } - } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestTelemetry.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestTelemetry.java deleted file mode 100644 index 5c1e4a5ed5b..00000000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TestTelemetry.java +++ /dev/null @@ -1,139 +0,0 @@ -/* -Copyright (c) 2016 Robert Atkinson - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted (subject to the limitations in the disclaimer below) provided that -the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of Robert Atkinson nor the names of his contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS -LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -package org.firstinspires.ftc.robotcontroller.internal.testcode; - -import com.qualcomm.robotcore.eventloop.opmode.Autonomous; -import com.qualcomm.robotcore.eventloop.opmode.Disabled; -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; - -import org.firstinspires.ftc.robotcore.external.Func; -import org.firstinspires.ftc.robotcore.external.Telemetry; -import org.firstinspires.ftc.robotcore.internal.TelemetryInternal; - -import java.util.Locale; - -/** - * {@link TestTelemetry} is a simple test of telemetry. - */ -@Autonomous(name = "Test Telemetry", group = "Tests") -@Disabled -public class TestTelemetry extends LinearOpMode - { - @Override public void runOpMode() throws InterruptedException - { - waitForStart(); - - testNonAutoClear(); - testLogDashboardInteraction(); - - while (opModeIsActive()) - { - idle(); - } - } - - void testNonAutoClear() throws InterruptedException - { - ((TelemetryInternal)telemetry).resetTelemetryForOpMode(); - - telemetry.setAutoClear(false); - - Telemetry.Item counting = telemetry.addData("counting", 1).setRetained(true); - telemetry.addData("unretained", "red"); - telemetry.addData("retained", new Func() { - @Override public String value() { - return String.format(Locale.getDefault(), "%dms", System.currentTimeMillis()); - }}); - telemetry.addData("unretained", "green"); - telemetry.update(); - delay(); - - counting.setValue(2); - telemetry.update(); - delay(); - - counting.setValue(3); - telemetry.update(); - delay(); - - telemetry.clear(); - delay(); - - counting.setValue(4); - telemetry.update(); - delay(); - } - - void testLogDashboardInteraction() throws InterruptedException - { - ((TelemetryInternal)telemetry).resetTelemetryForOpMode(); - - int count = 0; - - telemetry.log().add("one"); - delay(); - - telemetry.addData("count", count++); - delay(); - - telemetry.addData("count", count++); - delay(); - - telemetry.log().add("two"); - delay(); - - telemetry.update(); - delay(); - - telemetry.log().add("three (should see count 0 & 1)"); - delay(); - - telemetry.addData("count", count++); - delay(); - - telemetry.log().add("four (should see count 0 & 1)"); - delay(); - - telemetry.update(); - delay(); - - telemetry.log().add("five (should see count 2)"); - delay(); - } - - void delay() throws InterruptedException - { - Thread.sleep(2000); - } - - } diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TwoColorSensorsTelemetry.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TwoColorSensorsTelemetry.java deleted file mode 100644 index 0a0157da510..00000000000 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/testcode/TwoColorSensorsTelemetry.java +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright (c) 2016 Robert Atkinson - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted (subject to the limitations in the disclaimer below) provided that -the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of Robert Atkinson nor the names of his contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS -LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -package org.firstinspires.ftc.robotcontroller.internal.testcode; - -import android.graphics.Color; - -import com.qualcomm.hardware.ams.AMSColorSensor; -import com.qualcomm.robotcore.eventloop.opmode.Autonomous; -import com.qualcomm.robotcore.eventloop.opmode.Disabled; -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; - -/** - * A simple test of a pair of color sensors - */ -@Autonomous(name="Test Two Color Sensors", group ="Tests") -@Disabled -public class TwoColorSensorsTelemetry extends LinearOpMode - { - AMSColorSensor leftColorSensor; - AMSColorSensor rightColorSensor; - - @Override - public void runOpMode() throws InterruptedException - { - leftColorSensor = (AMSColorSensor)hardwareMap.colorSensor.get("leftColorSensor"); - rightColorSensor = (AMSColorSensor)hardwareMap.colorSensor.get("rightColorSensor"); - - AMSColorSensor.Parameters params = leftColorSensor.getParameters(); - // possibly change some (notably gain and / or integration time), then - // leftColorSensor.initialize(params); - - params = rightColorSensor.getParameters(); - // possibly change some (notably gain and / or integration time), then - // rightColorSensor.initialize(params); - - waitForStart(); - - while (opModeIsActive()) - { - int left = leftColorSensor.argb(); - int right = rightColorSensor.argb(); - telemetry.addData("left", String.format("a=%d r=%d g=%d b=%d", Color.alpha(left), Color.red(left), Color.green(left), Color.blue(left))); - telemetry.addData("right", String.format("a=%d r=%d g=%d b=%d", Color.alpha(right), Color.red(right), Color.green(right), Color.blue(right))); - this.updateTelemetry(telemetry); - - Thread.sleep(500); - } - - } - } diff --git a/README.md b/README.md index 2226e59f25e..f057888841e 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,30 @@ Documentation for the FTC SDK are included with this repository. There is a sub For technical questions regarding the SDK, please visit the FTC Technology forum: http://ftcforum.usfirst.org/forumdisplay.php?156-FTC-Technology +************************************************************************************** + +Version 2.30 (released on 16.10.05) + * Blockly programming mode: + - Mechanism added to save Blockly op modes from Programming Mode Server onto local device + - To avoid clutter, blocks are displayed in categorized folders + - Added support for DigitalChannel + - Added support for ModernRoboticsI2cCompassSensor + - Added support for ModernRoboticsI2cRangeSensor + - Added support for VoltageSensor + - Added support for AnalogInput + - Added support for AnalogOutput + - Fix for CompassSensor setMode block + * Vuforia + - Fix deadlock / make camera data available while Vuforia is running. + - Update to Vuforia 6.0.117 (recommended by Vuforia and Google to close security loophole). + * Fix for autonomous 30 second timer bug (where timer was in effect, even though it appeared to have timed out). + * opModeIsActive changes to allow cleanup after op mode is stopped (with enforced 2 second safety timeout). + * Fix to avoid reading i2c twice. + * Updated sample Op Modes. + * Improved logging and fixed intermittent freezing. + * Added digital I/O sample. + * Cleaned up device names in sample op modes to be consistent with Pushbot guide. + * Fix to allow use of IrSeekerSensorV3. ************************************************************************************** diff --git a/build.common.gradle b/build.common.gradle index 91df8632843..76a8e61ac89 100644 --- a/build.common.gradle +++ b/build.common.gradle @@ -70,7 +70,7 @@ android { // Advanced user code might just want to use Vuforia directly, so we set up the libs as needed buildTypes { release { - debuggable true + //debuggable true ndk { abiFilters "armeabi-v7a" } diff --git a/doc/apk/FtcDriverStation-release.apk b/doc/apk/FtcDriverStation-release.apk index 358d874ff19..63079628209 100644 Binary files a/doc/apk/FtcDriverStation-release.apk and b/doc/apk/FtcDriverStation-release.apk differ diff --git a/doc/apk/FtcRobotController-release.apk b/doc/apk/FtcRobotController-release.apk index b00e429b540..eec18ab5de7 100644 Binary files a/doc/apk/FtcRobotController-release.apk and b/doc/apk/FtcRobotController-release.apk differ diff --git a/doc/javadoc/allclasses-frame.html b/doc/javadoc/allclasses-frame.html index 64f3d12c3de..46006652fb5 100644 --- a/doc/javadoc/allclasses-frame.html +++ b/doc/javadoc/allclasses-frame.html @@ -36,6 +36,7 @@

All Classes

  • ConfigWifiDirectActivity
  • ConfigWifiDirectActivity.Flag
  • Const
  • +
  • Consumer
  • CRServo
  • CRServoImpl
  • DbgLog
  • @@ -187,6 +188,7 @@

    All Classes

  • VoltageSensor
  • VuforiaLocalizer
  • VuforiaLocalizer.CameraDirection
  • +
  • VuforiaLocalizer.CloseableFrame
  • VuforiaLocalizer.Parameters
  • VuforiaLocalizer.Parameters.CameraMonitorFeedback
  • VuforiaTrackable
  • diff --git a/doc/javadoc/allclasses-noframe.html b/doc/javadoc/allclasses-noframe.html index 1f1adf67b8b..11f413d952f 100644 --- a/doc/javadoc/allclasses-noframe.html +++ b/doc/javadoc/allclasses-noframe.html @@ -36,6 +36,7 @@

    All Classes

  • ConfigWifiDirectActivity
  • ConfigWifiDirectActivity.Flag
  • Const
  • +
  • Consumer
  • CRServo
  • CRServoImpl
  • DbgLog
  • @@ -187,6 +188,7 @@

    All Classes

  • VoltageSensor
  • VuforiaLocalizer
  • VuforiaLocalizer.CameraDirection
  • +
  • VuforiaLocalizer.CloseableFrame
  • VuforiaLocalizer.Parameters
  • VuforiaLocalizer.Parameters.CameraMonitorFeedback
  • VuforiaTrackable
  • diff --git a/doc/javadoc/com/qualcomm/ftccommon/package-tree.html b/doc/javadoc/com/qualcomm/ftccommon/package-tree.html index 18ee7284733..d64029be73b 100644 --- a/doc/javadoc/com/qualcomm/ftccommon/package-tree.html +++ b/doc/javadoc/com/qualcomm/ftccommon/package-tree.html @@ -87,17 +87,17 @@

    Class Hierarchy

  • Activity
  • Activity
  • Activity
  • Activity @@ -107,7 +107,7 @@

    Class Hierarchy

  • Activity
  • Binder diff --git a/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/LinearOpMode.html b/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/LinearOpMode.html index 30b6cb7e464..791fe906cb4 100644 --- a/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/LinearOpMode.html +++ b/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/LinearOpMode.html @@ -140,7 +140,7 @@

    Field Summary

    Fields inherited from class com.qualcomm.robotcore.eventloop.opmode.OpMode

    -gamepad1, gamepad2, hardwareMap, telemetry, time
  • +gamepad1, gamepad2, hardwareMap, msStuckDetectInit, msStuckDetectInitLoop, msStuckDetectLoop, msStuckDetectStart, msStuckDetectStop, telemetry, time @@ -240,7 +240,7 @@

    Method Summary

    void sleep(long milliseconds) -
    Sleep for the given amount of milliseconds.
    +
    Sleeps for the given amount of milliseconds, or until the thread is interrupted.
    @@ -270,7 +270,8 @@

    Method Summary

    void waitForStart() -
    Pause the Linear Op Mode until start has been pressed
    +
    Pauses the Linear Op Mode until start has been pressed or until the current thread + is interrupted.
    @@ -353,11 +354,9 @@

    runOpMode

    • waitForStart

      -
      public void waitForStart()
      -                  throws java.lang.InterruptedException
      -
      Pause the Linear Op Mode until start has been pressed
      -
      Throws:
      -
      java.lang.InterruptedException
      +
      public void waitForStart()
      +
      Pauses the Linear Op Mode until start has been pressed or until the current thread + is interrupted.
    @@ -420,20 +419,18 @@

    waitForNextHardwareCycle

    @@ -442,13 +439,10 @@

    idle

    • sleep

      -
      public final void sleep(long milliseconds)
      -                 throws java.lang.InterruptedException
      -
      Sleep for the given amount of milliseconds. This is simple shorthand for the operating-system- - provided sleep() method.
      -
      Parameters:
      milliseconds - amount of time to sleep, in milliseconds
      -
      Throws:
      -
      java.lang.InterruptedException
      See Also:
      Thread.sleep(long)
      +
      public final void sleep(long milliseconds)
      +
      Sleeps for the given amount of milliseconds, or until the thread is interrupted. This is + simple shorthand for the operating-system-provided sleep() method.
      +
      Parameters:
      milliseconds - amount of time to sleep, in milliseconds
      See Also:
      Thread.sleep(long)
    @@ -459,7 +453,9 @@

    sleep

    opModeIsActive

    public final boolean opModeIsActive()
    Answer as to whether this opMode is active and the robot should continue onwards. If the - opMode is not active, the OpMode should terminate at its earliest convenience.
    + opMode is not active, the OpMode should terminate at its earliest convenience. + +

    Note that internally this method calls idle()

    Returns:
    whether the OpMode is currently active. If this returns false, you should break out of the loop in your runOpMode() method and return to its caller.
    See Also:
    runOpMode(), isStarted(), diff --git a/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpMode.html b/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpMode.html index 9deed7c9e86..537b77c1fb2 100644 --- a/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpMode.html +++ b/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpMode.html @@ -137,13 +137,33 @@

    Field Summary

    +protected int +msStuckDetectInit  + + +protected int +msStuckDetectInitLoop  + + +protected int +msStuckDetectLoop  + + +protected int +msStuckDetectStart  + + +protected int +msStuckDetectStop  + + Telemetry telemetry
    The telemetry field contains an object in which a user may accumulate data which is to be transmitted to the driver station.
    - + double time
    number of seconds this op mode has been running, this is @@ -324,7 +344,7 @@

    hardwareMap

    -
      +
      • time

        public double time
        @@ -332,6 +352,51 @@

        time

        updated before every call to loop.
    + + + +
      +
    • +

      msStuckDetectInit

      +
      protected int msStuckDetectInit
      +
    • +
    + + + +
      +
    • +

      msStuckDetectInitLoop

      +
      protected int msStuckDetectInitLoop
      +
    • +
    + + + +
      +
    • +

      msStuckDetectStart

      +
      protected int msStuckDetectStart
      +
    • +
    + + + +
      +
    • +

      msStuckDetectLoop

      +
      protected int msStuckDetectLoop
      +
    • +
    + + + +
      +
    • +

      msStuckDetectStop

      +
      protected int msStuckDetectStop
      +
    • +
    diff --git a/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpModeManagerImpl.DefaultOpMode.html b/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpModeManagerImpl.DefaultOpMode.html index d3164e9f32e..c5728d173c7 100644 --- a/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpModeManagerImpl.DefaultOpMode.html +++ b/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpModeManagerImpl.DefaultOpMode.html @@ -124,7 +124,7 @@

    Field Summary

    Fields inherited from class com.qualcomm.robotcore.eventloop.opmode.OpMode

    -gamepad1, gamepad2, hardwareMap, telemetry, time +gamepad1, gamepad2, hardwareMap, msStuckDetectInit, msStuckDetectInitLoop, msStuckDetectLoop, msStuckDetectStart, msStuckDetectStop, telemetry, time diff --git a/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpModeManagerImpl.OpModeStuckCodeMonitor.html b/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpModeManagerImpl.OpModeStuckCodeMonitor.html index eb700a741b6..89203c69ee0 100644 --- a/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpModeManagerImpl.OpModeStuckCodeMonitor.html +++ b/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpModeManagerImpl.OpModeStuckCodeMonitor.html @@ -166,7 +166,8 @@

    Method Summary

    void -startMonitoring(java.lang.String method, +startMonitoring(int msTimeout, + java.lang.String method, boolean resetDebuggerCheck)  @@ -212,13 +213,14 @@

    OpModeManagerImpl.OpModeStuckCodeMonitor

    Method Detail

    - +
    • startMonitoring

      -
      public void startMonitoring(java.lang.String method,
      +
      public void startMonitoring(int msTimeout,
      +                   java.lang.String method,
                          boolean resetDebuggerCheck)
    diff --git a/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpModeManagerImpl.html b/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpModeManagerImpl.html index 236868da2b0..d0e41cfb9eb 100644 --- a/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpModeManagerImpl.html +++ b/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/OpModeManagerImpl.html @@ -306,12 +306,14 @@

    Method Summary

    protected void -detectStuck(java.lang.String method, +detectStuck(int msTimeout, + java.lang.String method, java.lang.Runnable runnable)  protected void -detectStuck(java.lang.String method, +detectStuck(int msTimeout, + java.lang.String method, java.lang.Runnable runnable, boolean resetDebuggerCheck)  @@ -943,23 +945,25 @@

    callActiveOpModeStop

    protected void callActiveOpModeStop()
    - +
    • detectStuck

      -
      protected void detectStuck(java.lang.String method,
      +
      protected void detectStuck(int msTimeout,
      +               java.lang.String method,
                      java.lang.Runnable runnable)
    - +
    • detectStuck

      -
      protected void detectStuck(java.lang.String method,
      +
      protected void detectStuck(int msTimeout,
      +               java.lang.String method,
                      java.lang.Runnable runnable,
                      boolean resetDebuggerCheck)
    • diff --git a/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/package-tree.html b/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/package-tree.html index 68878349d9d..4206eb1bb82 100644 --- a/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/package-tree.html +++ b/doc/javadoc/com/qualcomm/robotcore/eventloop/opmode/package-tree.html @@ -101,10 +101,10 @@

      Interface Hierarchy

    Annotation Type Hierarchy

      -
    • com.qualcomm.robotcore.eventloop.opmode.Disabled (implements java.lang.annotation.Annotation)
    • -
    • com.qualcomm.robotcore.eventloop.opmode.OpModeRegistrar (implements java.lang.annotation.Annotation)
    • com.qualcomm.robotcore.eventloop.opmode.Autonomous (implements java.lang.annotation.Annotation)
    • +
    • com.qualcomm.robotcore.eventloop.opmode.Disabled (implements java.lang.annotation.Annotation)
    • com.qualcomm.robotcore.eventloop.opmode.TeleOp (implements java.lang.annotation.Annotation)
    • +
    • com.qualcomm.robotcore.eventloop.opmode.OpModeRegistrar (implements java.lang.annotation.Annotation)

    Enum Hierarchy

    + + + +
      +
    • +

      deviceNames

      +
      protected java.util.Map<HardwareDevice,java.util.Set<java.lang.String>> deviceNames
      +
    • +
    @@ -724,6 +752,38 @@

    remove

    Returns:
    whether a device was removed or not
    + + + +
      +
    • +

      getNamesOf

      +
      public java.util.Set<java.lang.String> getNamesOf(HardwareDevice device)
      +
      Returns all the names by which the device is known. Virtually always, there is but + a single name.
      +
      Parameters:
      device - the device whose names are desired.
      +
      Returns:
      the set of names by which that device is known
      +
    • +
    + + + +
      +
    • +

      recordDeviceName

      +
      protected void recordDeviceName(java.lang.String deviceName,
      +                    HardwareDevice device)
      +
    • +
    + + + +
      +
    • +

      rebuildDeviceNamesIfNecessary

      +
      protected void rebuildDeviceNamesIfNecessary()
      +
    • +
    diff --git a/doc/javadoc/com/qualcomm/robotcore/hardware/I2cDeviceSynchImpl.Callback.html b/doc/javadoc/com/qualcomm/robotcore/hardware/I2cDeviceSynchImpl.Callback.html index c4303f794e0..89a798c4697 100644 --- a/doc/javadoc/com/qualcomm/robotcore/hardware/I2cDeviceSynchImpl.Callback.html +++ b/doc/javadoc/com/qualcomm/robotcore/hardware/I2cDeviceSynchImpl.Callback.html @@ -201,35 +201,31 @@

    Method Summary

    doModuleIsArmedWork(boolean arming)  -protected boolean -isControllerPortInReadMode()  - - protected void issueWrite()  - + void onModuleStateChange(RobotArmingStateNotifier robotUsbModule, RobotUsbModule.ARMINGSTATE armingstate)  - + void onPortIsReadyCallbacksBegin(int port)  - + void onPortIsReadyCallbacksEnd(int port)  - + void portIsReady(int port)  - + protected void startSwitchingToReadMode(I2cDeviceSynch.ReadWindow window)  - + protected void updateStateMachines()  @@ -446,15 +442,6 @@

    issueWrite

    protected void issueWrite()
    - - - -
      -
    • -

      isControllerPortInReadMode

      -
      protected boolean isControllerPortInReadMode()
      -
    • -
    diff --git a/doc/javadoc/com/qualcomm/robotcore/hardware/I2cDeviceSynchImpl.html b/doc/javadoc/com/qualcomm/robotcore/hardware/I2cDeviceSynchImpl.html index c9be9b812c8..860b75ef90c 100644 --- a/doc/javadoc/com/qualcomm/robotcore/hardware/I2cDeviceSynchImpl.html +++ b/doc/javadoc/com/qualcomm/robotcore/hardware/I2cDeviceSynchImpl.html @@ -206,37 +206,45 @@

    Field Summary

    dibCacheOverhead  +protected boolean +disableReadWindows  + + protected java.lang.Object engagementLock  - + protected boolean hasReadWindowChanged  - + protected I2cDeviceSynch.HeartbeatAction heartbeatAction  - + protected java.util.concurrent.ExecutorService heartbeatExecutor  - + protected I2cAddr i2cAddr  - + protected I2cDevice i2cDevice  - + protected int iregWriteFirst  - + protected boolean isClosing  + +protected boolean +isControllerLegacy  + protected boolean isEngaged  @@ -389,31 +397,35 @@

    Method Summary

    adjustHooking()  +protected void +assignReadWindow(I2cDeviceSynch.ReadWindow newWindow)  + + void close()
    Closes this device
    - + protected static byte[] concatenateByteArrays(byte[] left, byte[] right)  - + protected void disableReadsAndWrites()  - + void disengage()
    Disengage the object from underlying services it uses to render its function.
    - + protected void enableReadsAndWrites()  - + void enableWriteCoalescing(boolean enable)
    Enables or disables an optimization wherein writes to two sets of adjacent register @@ -421,87 +433,87 @@

    Method Summary

    while the first is still queued for writing.
    - + void engage()
    (Re)enage the object with its underlying services.
    - + void ensureReadWindow(I2cDeviceSynch.ReadWindow windowNeeded, I2cDeviceSynch.ReadWindow windowToSet)
    Ensure that the current register window covers the indicated set of registers.
    - + protected void forceDrainReadersAndWriters()  - + java.lang.String getConnectionInfo()
    Get connection information about this device in a human readable format
    - + java.lang.String getDeviceName()
    Returns a string suitable for display to the user as to the type of device
    - + I2cDeviceSynch.HeartbeatAction getHeartbeatAction()
    Returns the current action, if any, to take upon expiration of the heartbeat interval.
    - + int getHeartbeatInterval()
    Returns the interval within which communication must be received by the I2C device lest a timeout occur.
    - + I2cAddr getI2cAddr()
    Returns the I2C address currently being used by this device client
    - + I2cAddr getI2cAddress()
    Returns the I2C address currently in use to communicate with an I2C hardware device
    - + HardwareDevice.Manufacturer getManufacturer()
    Returns an indication of the manufacturer of this device.
    - + I2cDeviceSynch.ReadWindow getReadWindow()
    Returns the current register window used for reading.
    - + int getVersion()
    Version
    - + protected void gracefullyDrainReadersAndWriters()  - + protected void hook()  - + boolean isArmed()
    Returns whether, as of this instant, this device client is alive and operational in @@ -509,68 +521,68 @@

    Method Summary

    with its underlying hardware or whether it is in some other state.
    - + boolean isEngaged()
    Returns whether the object is currently in the engaged state.
    - + protected boolean isOpenForReading()  - + protected boolean isOpenForWriting()  - + boolean isWriteCoalescingEnabled()
    Answers as to whether write coalescing is currently enabled on this device.
    - + protected void log(int verbosity, java.lang.String message)  - + protected void log(int verbosity, java.lang.String format, java.lang.Object... args)  - + static I2cDeviceSynchSimple.TimestampedData makeFakeData(int ireg, int creg)  - + protected boolean newReadsAndWritesAllowed()  - + byte[] read(int ireg, int creg)
    Read a contiguous set of device I2C registers.
    - + byte read8(int ireg)
    Read the byte at the indicated register.
    - + protected boolean readCacheIsValid()  - + protected boolean readCacheValidityCurrentOrImminent()  - + I2cDeviceSynchSimple.TimestampedData readTimeStamped(int ireg, int creg) @@ -578,7 +590,7 @@

    Method Summary

    timestamp of when the actual I2C read occurred. - + I2cDeviceSynchSimple.TimestampedData readTimeStamped(int ireg, int creg, @@ -589,97 +601,97 @@

    Method Summary

    interrupting in the middle. - + protected byte[] readWriteCache()  - + protected void releaseReaderLockShared()  - + void resetDeviceConfigurationForOpMode()
    Resets the device's configuration to that which is expected at the beginning of an OpMode.
    - + void setHeartbeatAction(I2cDeviceSynch.HeartbeatAction action)
    Sets the action to take when the current heartbeat interval expires.
    - + void setHeartbeatInterval(int msHeartbeatInterval)
    Sets the interval within which communication must be received by the I2C device lest a timeout may occur.
    - + void setI2cAddr(I2cAddr i2cAddr)
    Sets the I2C address of the underlying client.
    - + void setI2cAddress(I2cAddr newAddress)
    Configures a new I2C address to use
    - + void setLogging(boolean enabled)
    Turn logging on or off.
    - + void setLoggingTag(java.lang.String loggingTag)
    Set the tag to use when logging is on.
    - + void setReadWindow(I2cDeviceSynch.ReadWindow newWindow)
    Set the set of registers that we will read and read and read again on every hardware cycle
    - + protected void setReadWindowInternal(I2cDeviceSynch.ReadWindow newWindow)  - + protected void unhook()  - + protected void waitForIdleWriteCache()  - + protected void waitForValidReadCache()  - + protected void waitForWriteCompletionInternal()  - + void waitForWriteCompletions()
    Waits for any previously issued writes to be written to the USB controller module.
    - + void write(int ireg, byte[] data)
    Writes data to a set of registers, beginning with the one indicated.
    - + void write(int ireg, byte[] data, @@ -687,14 +699,14 @@

    Method Summary

    Writes data to a set of registers, beginning with the one indicated.
    - + void write8(int ireg, int data)
    Writes a byte to the indicated register.
    - + void write8(int ireg, int data, @@ -760,6 +772,15 @@

    controller

    protected I2cController controller
    + + + +
      +
    • +

      isControllerLegacy

      +
      protected boolean isControllerLegacy
      +
    • +
    @@ -961,6 +982,15 @@

    callbackLock

    protected final java.lang.Object callbackLock
    + + + +
      +
    • +

      disableReadWindows

      +
      protected boolean disableReadWindows
      +
    • +
    @@ -1451,6 +1481,15 @@

    setReadWindowInternal

    protected void setReadWindowInternal(I2cDeviceSynch.ReadWindow newWindow)
    + + + + diff --git a/doc/javadoc/com/qualcomm/robotcore/hardware/package-tree.html b/doc/javadoc/com/qualcomm/robotcore/hardware/package-tree.html index 3a4c109a33c..f033cd8d06e 100644 --- a/doc/javadoc/com/qualcomm/robotcore/hardware/package-tree.html +++ b/doc/javadoc/com/qualcomm/robotcore/hardware/package-tree.html @@ -224,20 +224,20 @@

    Enum Hierarchy

    diff --git a/doc/javadoc/index-all.html b/doc/javadoc/index-all.html index 23da149effe..9a11bbd7419 100644 --- a/doc/javadoc/index-all.html +++ b/doc/javadoc/index-all.html @@ -92,6 +92,10 @@

    A

    accelerationSensor - Variable in class com.qualcomm.robotcore.hardware.HardwareMap
     
    +
    accept(T) - Method in interface org.firstinspires.ftc.robotcore.external.Consumer
    +
    +
    Performs this operation on the given argument.
    +
    acquireReaderLockShared() - Method in class com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl
     
    acquisitionTime - Variable in class org.firstinspires.ftc.robotcore.external.navigation.Acceleration
    @@ -330,6 +334,8 @@

    A

    Get the "hue"
    +
    assignReadWindow(I2cDeviceSynch.ReadWindow) - Method in class com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl
    +
     
    atRest() - Method in class com.qualcomm.robotcore.hardware.Gamepad
    Are all analog sticks and triggers in their rest position?
    @@ -587,6 +593,8 @@

    C

     
    close() - Method in class com.qualcomm.robotcore.hardware.ServoImpl
     
    +
    close() - Method in class org.firstinspires.ftc.robotcore.external.navigation.VuforiaLocalizer.CloseableFrame
    +
     
    closeAllUsbDevices() - Method in class com.qualcomm.ftccommon.FtcEventLoopHandler
     
    closeMotorControllers() - Method in class com.qualcomm.ftccommon.FtcEventLoopHandler
    @@ -739,6 +747,10 @@

    C

    Const documents a method that promises not to change the internal state of the method receiver.
    +
    Consumer<T> - Interface in org.firstinspires.ftc.robotcore.external
    +
    +
    Instances of Consumer are functions that act on an instance of a indicated type
    +
    contains(I2cDeviceSynch.ReadWindow) - Method in class com.qualcomm.robotcore.hardware.I2cDeviceSynch.ReadWindow
    Answers as to whether the receiver wholly contains the indicated window.
    @@ -1084,9 +1096,9 @@

    D

    Unregister for a port-ready callback
    -
    detectStuck(String, Runnable) - Method in class com.qualcomm.robotcore.eventloop.opmode.OpModeManagerImpl
    +
    detectStuck(int, String, Runnable) - Method in class com.qualcomm.robotcore.eventloop.opmode.OpModeManagerImpl
     
    -
    detectStuck(String, Runnable, boolean) - Method in class com.qualcomm.robotcore.eventloop.opmode.OpModeManagerImpl
    +
    detectStuck(int, String, Runnable, boolean) - Method in class com.qualcomm.robotcore.eventloop.opmode.OpModeManagerImpl
     
    Device - Class in com.qualcomm.ftccommon
    @@ -1112,6 +1124,8 @@

    D

    Enum of known USB Device Types (Note that the MR .AAR library has an internal copy of this)
    +
    deviceNames - Variable in class com.qualcomm.robotcore.hardware.HardwareMap
    +
     
    diagonalMatrix(int, float) - Static method in class org.firstinspires.ftc.robotcore.external.matrices.MatrixF
    Returns a new matrix which is zero everywhere except on the diagonal, where it has @@ -1166,6 +1180,8 @@

    D

    disableReadsAndWrites() - Method in class com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl
     
    +
    disableReadWindows - Variable in class com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl
    +
     
    disengage() - Method in interface com.qualcomm.robotcore.hardware.Engagable
    Disengage the object from underlying services it uses to render its function.
    @@ -1845,6 +1861,8 @@

    G

     
    getDeviceName() - Method in class com.qualcomm.robotcore.hardware.ServoImpl
     
    +
    getDeviceTypeClass() - Method in class com.qualcomm.robotcore.hardware.HardwareMap.DeviceMapping
    +
     
    getDigitalChannelMode(int) - Method in interface com.qualcomm.robotcore.hardware.DigitalChannelController
    Get the mode of a digital channel
    @@ -1903,6 +1921,15 @@

    G

    getEventLoopManager() - Method in class com.qualcomm.ftccommon.FtcEventLoopHandler
     
    +
    getFrameQueue() - Method in interface org.firstinspires.ftc.robotcore.external.navigation.VuforiaLocalizer
    +
    +
    (Advanced) Returns a queue into which, if requested, Vuforia Frames are placed + as they become available.
    +
    +
    getFrameQueueCapacity() - Method in interface org.firstinspires.ftc.robotcore.external.navigation.VuforiaLocalizer
    +
    +
    Returns the current capacity of the frame queue.
    +
    getGamepad() - Method in class com.qualcomm.robotcore.eventloop.EventLoopManager
    Get the current gamepad state
    @@ -2192,6 +2219,10 @@

    G

    Returns the user-specified name for this trackables.
    +
    getNamesOf(HardwareDevice) - Method in class com.qualcomm.robotcore.hardware.HardwareMap
    +
    +
    Returns all the names by which the device is known.
    +
    getNetworkConnection() - Method in class com.qualcomm.ftccommon.FtcRobotControllerService
     
    getNetworkConnectionStatus() - Method in class com.qualcomm.ftccommon.FtcRobotControllerService
    @@ -2681,7 +2712,7 @@

    H

    A DeviceMapping contains a subcollection of the devices registered in a HardwareMap comprised of all the devices of a particular device type
    -
    HardwareMap.DeviceMapping() - Constructor for class com.qualcomm.robotcore.hardware.HardwareMap.DeviceMapping
    +
    HardwareMap.DeviceMapping(Class<DEVICE_TYPE>) - Constructor for class com.qualcomm.robotcore.hardware.HardwareMap.DeviceMapping
     
    hashCode() - Method in class com.qualcomm.robotcore.eventloop.opmode.OpModeMeta
     
    @@ -3059,7 +3090,7 @@

    I

     
    isClosing - Variable in class com.qualcomm.robotcore.hardware.I2cDeviceSynchImplOnSimple
     
    -
    isControllerPortInReadMode() - Method in class com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl.Callback
    +
    isControllerLegacy - Variable in class com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl
     
    isEngaged() - Method in interface com.qualcomm.robotcore.hardware.Engagable
    @@ -3551,6 +3582,16 @@

    M

     
    msLastPlay - Variable in class com.qualcomm.ftccommon.SoundPlayer.SoundInfo
     
    +
    msStuckDetectInit - Variable in class com.qualcomm.robotcore.eventloop.opmode.OpMode
    +
     
    +
    msStuckDetectInitLoop - Variable in class com.qualcomm.robotcore.eventloop.opmode.OpMode
    +
     
    +
    msStuckDetectLoop - Variable in class com.qualcomm.robotcore.eventloop.opmode.OpMode
    +
     
    +
    msStuckDetectStart - Variable in class com.qualcomm.robotcore.eventloop.opmode.OpMode
    +
     
    +
    msStuckDetectStop - Variable in class com.qualcomm.robotcore.eventloop.opmode.OpMode
    +
     
    multiplied(MatrixF) - Method in class org.firstinspires.ftc.robotcore.external.matrices.MatrixF
    Returns a matrix which is the multiplication of the recevier with another matrix.
    @@ -4286,6 +4327,10 @@

    R

     
    readWriteCache() - Method in class com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl
     
    +
    rebuildDeviceNamesIfNecessary() - Method in class com.qualcomm.robotcore.hardware.HardwareMap
    +
     
    +
    recordDeviceName(String, HardwareDevice) - Method in class com.qualcomm.robotcore.hardware.HardwareMap
    +
     
    red() - Method in interface com.qualcomm.robotcore.hardware.ColorSensor
    Get the Red values detected by the sensor as an int.
    @@ -4851,6 +4896,11 @@

    S

    Replace the current event loop with a new event loop
    +
    setFrameQueueCapacity(int) - Method in interface org.firstinspires.ftc.robotcore.external.navigation.VuforiaLocalizer
    +
    +
    Sets the maximum number of Frames that will simultaneously be stored in the + frame queue.
    +
    setHardwareMap(HardwareMap) - Method in class com.qualcomm.robotcore.eventloop.opmode.OpModeManagerImpl
     
    setHeartbeatAction(I2cDeviceSynch.HeartbeatAction) - Method in interface com.qualcomm.robotcore.hardware.I2cDeviceSynch
    @@ -5249,7 +5299,7 @@

    S

    sleep(long) - Method in class com.qualcomm.robotcore.eventloop.opmode.LinearOpMode
    -
    Sleep for the given amount of milliseconds.
    +
    Sleeps for the given amount of milliseconds, or until the thread is interrupted.
    slice(int, int, int, int) - Method in class org.firstinspires.ftc.robotcore.external.matrices.MatrixF
    @@ -5314,7 +5364,7 @@

    S

    This method will be called to let the sync'd device know that it's ok to enter a blocking state.
    -
    startMonitoring(String, boolean) - Method in class com.qualcomm.robotcore.eventloop.opmode.OpModeManagerImpl.OpModeStuckCodeMonitor
    +
    startMonitoring(int, String, boolean) - Method in class com.qualcomm.robotcore.eventloop.opmode.OpModeManagerImpl.OpModeStuckCodeMonitor
     
    startProgrammingMode(FtcEventLoopHandler) - Method in interface com.qualcomm.ftccommon.ProgrammingModeController
    @@ -6120,6 +6170,15 @@

    V

    VuforiaLocalizer.CameraDirection enumerates the identities of the cameras that Vuforia can use.
    +
    VuforiaLocalizer.CloseableFrame - Class in org.firstinspires.ftc.robotcore.external.navigation
    +
    +
    VuforiaLocalizer.CloseableFrame exposes a close() method so that one can proactively + reduce memory pressure when we're done with a Frame
    +
    +
    VuforiaLocalizer.CloseableFrame(Frame) - Constructor for class org.firstinspires.ftc.robotcore.external.navigation.VuforiaLocalizer.CloseableFrame
    +
    +
    creating a CloseableFrame also has an effect equivalent to calling frame.clone()
    +
    VuforiaLocalizer.Parameters - Class in org.firstinspires.ftc.robotcore.external.navigation
    VuforiaLocalizer.Parameters provides configuration information for instantiating the Vuforia localizer
    @@ -6174,7 +6233,8 @@

    W

    waitForStart() - Method in class com.qualcomm.robotcore.eventloop.opmode.LinearOpMode
    -
    Pause the Linear Op Mode until start has been pressed
    +
    Pauses the Linear Op Mode until start has been pressed or until the current thread + is interrupted.
    waitForValidReadCache() - Method in class com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl
     
    diff --git a/doc/javadoc/org/firstinspires/ftc/robotcore/external/Const.html b/doc/javadoc/org/firstinspires/ftc/robotcore/external/Const.html index e7375ad264b..9cf1535403a 100644 --- a/doc/javadoc/org/firstinspires/ftc/robotcore/external/Const.html +++ b/doc/javadoc/org/firstinspires/ftc/robotcore/external/Const.html @@ -34,7 +34,7 @@