From 3da211eb2d3674acbb62fab3c900e668819c42ac Mon Sep 17 00:00:00 2001 From: FTCTechNH Date: Thu, 8 Sep 2016 13:20:04 -0400 Subject: [PATCH] Updated op modes to work with new 2.x FTC SDK software. --- opModes/PushBotAuto.java | 5 ++-- opModes/PushBotAutoSensors.java | 5 ++-- opModes/PushBotDriveTouch.java | 11 ++++++--- opModes/PushBotHardware.java | 21 ++++++++--------- opModes/PushBotHardwareSensors.java | 4 ++-- opModes/PushBotIrEvent.java | 4 ++-- opModes/PushBotIrSeek.java | 14 +++++++---- opModes/PushBotManual.java | 8 ++++++- opModes/PushBotManual1.java | 8 ++++++- opModes/PushBotManualSensors.java | 9 ++++++- opModes/PushBotOdsDetectEvent.java | 9 ++++++- opModes/PushBotOdsFollowEvent.java | 9 ++++++- opModes/PushBotSquare.java | 35 +++++++++++++++++++--------- opModes/PushBotTelemetry.java | 2 +- opModes/PushBotTelemetrySensors.java | 2 +- opModes/PushBotTouchEvent.java | 4 ++-- 16 files changed, 103 insertions(+), 47 deletions(-) mode change 100644 => 100755 opModes/PushBotAuto.java mode change 100644 => 100755 opModes/PushBotAutoSensors.java mode change 100644 => 100755 opModes/PushBotDriveTouch.java mode change 100644 => 100755 opModes/PushBotHardware.java mode change 100644 => 100755 opModes/PushBotHardwareSensors.java mode change 100644 => 100755 opModes/PushBotIrEvent.java mode change 100644 => 100755 opModes/PushBotIrSeek.java mode change 100644 => 100755 opModes/PushBotManual.java mode change 100644 => 100755 opModes/PushBotManual1.java mode change 100644 => 100755 opModes/PushBotManualSensors.java mode change 100644 => 100755 opModes/PushBotOdsDetectEvent.java mode change 100644 => 100755 opModes/PushBotOdsFollowEvent.java mode change 100644 => 100755 opModes/PushBotSquare.java mode change 100644 => 100755 opModes/PushBotTelemetry.java mode change 100644 => 100755 opModes/PushBotTelemetrySensors.java mode change 100644 => 100755 opModes/PushBotTouchEvent.java diff --git a/opModes/PushBotAuto.java b/opModes/PushBotAuto.java old mode 100644 new mode 100755 index e7eb9a5..1ef4232 --- a/opModes/PushBotAuto.java +++ b/opModes/PushBotAuto.java @@ -1,16 +1,17 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; //------------------------------------------------------------------------------ // // PushBotAuto // + /** * Provide a basic autonomous operational mode that uses the left and right * drive motors and associated encoders implemented using a state machine for * the Push Bot. * * @author SSI Robotics - * @version 2015-08-01-06-01 + * @version 2016-09-05-06-01 */ public class PushBotAuto extends PushBotTelemetry diff --git a/opModes/PushBotAutoSensors.java b/opModes/PushBotAutoSensors.java old mode 100644 new mode 100755 index 2114206..d878963 --- a/opModes/PushBotAutoSensors.java +++ b/opModes/PushBotAutoSensors.java @@ -1,9 +1,10 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; //------------------------------------------------------------------------------ // // PushBotAutoSensors // + /** * Provide a basic autonomous operational mode that uses the left and right * drive motors and associated encoders, the left arm motor and associated touch @@ -11,7 +12,7 @@ * machine for the Push Bot. * * @author SSI Robotics - * @version 2015-08-13-19-48 + * @version 2016-09-05-19-48 */ public class PushBotAutoSensors extends PushBotTelemetrySensors diff --git a/opModes/PushBotDriveTouch.java b/opModes/PushBotDriveTouch.java old mode 100644 new mode 100755 index 221d3ea..df98444 --- a/opModes/PushBotDriveTouch.java +++ b/opModes/PushBotDriveTouch.java @@ -1,6 +1,7 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; import com.qualcomm.robotcore.hardware.DcMotor; import com.qualcomm.robotcore.hardware.TouchSensor; @@ -10,6 +11,9 @@ * will run its motors unless a touch sensor * is pressed. */ +@TeleOp(name = "PushBotDriveTouch", group = "pushbot") +//@Disabled +// comment out the above line if you want this op mode to be enabled. public class PushBotDriveTouch extends LinearOpMode { DcMotor leftMotor; DcMotor rightMotor; @@ -42,9 +46,10 @@ public void runOpMode() throws InterruptedException { } telemetry.addData("isPressed", String.valueOf(touchSensor.isPressed())); + telemetry.update(); + + idle(); - // Wait for a hardware cycle to allow other processes to run - waitOneFullHardwareCycle(); } } diff --git a/opModes/PushBotHardware.java b/opModes/PushBotHardware.java old mode 100644 new mode 100755 index f60e513..22434d6 --- a/opModes/PushBotHardware.java +++ b/opModes/PushBotHardware.java @@ -1,9 +1,8 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; import com.qualcomm.ftccommon.DbgLog; import com.qualcomm.robotcore.eventloop.opmode.OpMode; import com.qualcomm.robotcore.hardware.DcMotor; -import com.qualcomm.robotcore.hardware.DcMotorController; import com.qualcomm.robotcore.hardware.Servo; import com.qualcomm.robotcore.util.Range; @@ -20,7 +19,7 @@ * calls to methods will fail, but will not cause the application to crash. * * @author SSI Robotics - * @version 2015-08-13-20-04 + * @version 2016-09-05-20-04 */ public class PushBotHardware extends OpMode @@ -391,7 +390,7 @@ public void run_using_left_drive_encoder () if (v_motor_left_drive != null) { v_motor_left_drive.setMode - ( DcMotorController.RunMode.RUN_USING_ENCODERS + ( DcMotor.RunMode.RUN_USING_ENCODER ); } @@ -410,7 +409,7 @@ public void run_using_right_drive_encoder () if (v_motor_right_drive != null) { v_motor_right_drive.setMode - ( DcMotorController.RunMode.RUN_USING_ENCODERS + ( DcMotor.RunMode.RUN_USING_ENCODER ); } @@ -447,10 +446,10 @@ public void run_without_left_drive_encoder () if (v_motor_left_drive != null) { if (v_motor_left_drive.getMode () == - DcMotorController.RunMode.RESET_ENCODERS) + DcMotor.RunMode.STOP_AND_RESET_ENCODER) { v_motor_left_drive.setMode - ( DcMotorController.RunMode.RUN_WITHOUT_ENCODERS + ( DcMotor.RunMode.RUN_WITHOUT_ENCODER ); } } @@ -470,10 +469,10 @@ public void run_without_right_drive_encoder () if (v_motor_right_drive != null) { if (v_motor_right_drive.getMode () == - DcMotorController.RunMode.RESET_ENCODERS) + DcMotor.RunMode.STOP_AND_RESET_ENCODER) { v_motor_right_drive.setMode - ( DcMotorController.RunMode.RUN_WITHOUT_ENCODERS + ( DcMotor.RunMode.RUN_WITHOUT_ENCODER ); } } @@ -511,7 +510,7 @@ public void reset_left_drive_encoder () if (v_motor_left_drive != null) { v_motor_left_drive.setMode - ( DcMotorController.RunMode.RESET_ENCODERS + ( DcMotor.RunMode.STOP_AND_RESET_ENCODER ); } @@ -530,7 +529,7 @@ public void reset_right_drive_encoder () if (v_motor_right_drive != null) { v_motor_right_drive.setMode - ( DcMotorController.RunMode.RESET_ENCODERS + ( DcMotor.RunMode.STOP_AND_RESET_ENCODER ); } diff --git a/opModes/PushBotHardwareSensors.java b/opModes/PushBotHardwareSensors.java old mode 100644 new mode 100755 index d07900a..9751566 --- a/opModes/PushBotHardwareSensors.java +++ b/opModes/PushBotHardwareSensors.java @@ -1,4 +1,4 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; import com.qualcomm.ftccommon.DbgLog; import com.qualcomm.robotcore.hardware.IrSeekerSensor; @@ -20,7 +20,7 @@ * calls to methods will fail, but will not cause the application to crash. * * @author SSI Robotics - * @version 2015-08-13-20-04 + * @version 2016-09-05-20-04 */ public class PushBotHardwareSensors extends PushBotTelemetry diff --git a/opModes/PushBotIrEvent.java b/opModes/PushBotIrEvent.java old mode 100644 new mode 100755 index 7268fa2..aa871c5 --- a/opModes/PushBotIrEvent.java +++ b/opModes/PushBotIrEvent.java @@ -1,4 +1,4 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; //------------------------------------------------------------------------------ // @@ -9,7 +9,7 @@ * IR seeker implemented using a state machine for the Push Bot. * * @author SSI Robotics - * @version 2015-08-16-08-41 + * @version 2016-09-05-08-41 */ public class PushBotIrEvent extends PushBotTelemetrySensors diff --git a/opModes/PushBotIrSeek.java b/opModes/PushBotIrSeek.java old mode 100644 new mode 100755 index d76e90d..7c03537 --- a/opModes/PushBotIrSeek.java +++ b/opModes/PushBotIrSeek.java @@ -1,8 +1,7 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; - -import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; +package org.firstinspires.ftc.teamcode; import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; import com.qualcomm.robotcore.hardware.DcMotor; import com.qualcomm.robotcore.hardware.IrSeekerSensor; import com.qualcomm.robotcore.util.Range; @@ -12,12 +11,16 @@ * An example linear op mode where the pushbot * will track an IR beacon. */ +@TeleOp(name = "PushBotIrSeek", group = "pushbot") +//@Disabled +// comment out the above line if you want this op mode to be enabled. public class PushBotIrSeek extends LinearOpMode { final static double kBaseSpeed = 0.15; // Higher values will cause the robot to move faster final static double kMinimumStrength = 0.08; // Higher values will cause the robot to follow closer final static double kMaximumStrength = 0.60; // Lower values will cause the robot to stop sooner + //IrSeekerSensor irSeeker; IrSeekerSensor irSeeker; DcMotor leftMotor; DcMotor rightMotor; @@ -48,8 +51,9 @@ public void runOpMode() throws InterruptedException { telemetry.addData("Seeker", irSeeker.toString()); telemetry.addData("Speed", " Left=" + leftMotor.getPower() + " Right=" + rightMotor.getPower()); - //Wait one hardware cycle to avoid taxing the processor - waitOneFullHardwareCycle(); + telemetry.update(); + + idle(); } } diff --git a/opModes/PushBotManual.java b/opModes/PushBotManual.java old mode 100644 new mode 100755 index 29c554b..22f953b --- a/opModes/PushBotManual.java +++ b/opModes/PushBotManual.java @@ -1,9 +1,12 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; //------------------------------------------------------------------------------ // // PushBotManual // + +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; + /** * Provide a basic manual operational mode that uses the left and right * drive motors, left arm motor, servo motors and gamepad input from two @@ -12,6 +15,9 @@ * @author SSI Robotics * @version 2015-08-01-06-01 */ +@TeleOp(name="PushBotManual", group = "pushbot") +//@Disabled +// comment out the above line if you want this op mode to be enabled. public class PushBotManual extends PushBotTelemetry { diff --git a/opModes/PushBotManual1.java b/opModes/PushBotManual1.java old mode 100644 new mode 100755 index bfa26f8..d3e29d6 --- a/opModes/PushBotManual1.java +++ b/opModes/PushBotManual1.java @@ -1,9 +1,13 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; //------------------------------------------------------------------------------ // // PushBotManual // + +import com.qualcomm.robotcore.eventloop.opmode.Disabled; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; + /** * Provide a basic manual operational mode that uses the left and right * drive motors, left arm motor, servo motors and gamepad input from only one @@ -12,6 +16,8 @@ * @author SSI Robotics * @version 2015-09-05-20-12 */ +@TeleOp(name="PushBotManual", group = "pushbot") +@Disabled public class PushBotManual1 extends PushBotTelemetry { diff --git a/opModes/PushBotManualSensors.java b/opModes/PushBotManualSensors.java old mode 100644 new mode 100755 index 6b967c0..e35e1d3 --- a/opModes/PushBotManualSensors.java +++ b/opModes/PushBotManualSensors.java @@ -1,9 +1,13 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; //------------------------------------------------------------------------------ // // PushBotManualSensors // + +import com.qualcomm.robotcore.eventloop.opmode.Disabled; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; + /** * Provide a basic manual operational mode that uses the left and right * drive motors, left arm motor, servo motors and gamepad input from two @@ -14,6 +18,9 @@ * @author SSI Robotics * @version 2015-08-25-14-40 */ +@TeleOp(name = "PushBotManualSensors", group = "pushbot") +@Disabled +// comment out the above line if you want this op mode to be enabled. public class PushBotManualSensors extends PushBotTelemetrySensors { diff --git a/opModes/PushBotOdsDetectEvent.java b/opModes/PushBotOdsDetectEvent.java old mode 100644 new mode 100755 index 46bc838..d6a249a --- a/opModes/PushBotOdsDetectEvent.java +++ b/opModes/PushBotOdsDetectEvent.java @@ -1,9 +1,13 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; //------------------------------------------------------------------------------ // // PushBotOdsDetectEvent // + +import com.qualcomm.robotcore.eventloop.opmode.Disabled; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; + /** * Provide a basic autonomous operational mode that demonstrates the use of an * optical distance sensor to detect a line implemented using a state machine @@ -12,6 +16,9 @@ * @author SSI Robotics * @version 2015-08-30-11-45 */ +@TeleOp(name = "PushBotOdsDetectEvent", group = "pushbot") +@Disabled +// comment out the above line if you want this op mode to be enabled. public class PushBotOdsDetectEvent extends PushBotTelemetrySensors { diff --git a/opModes/PushBotOdsFollowEvent.java b/opModes/PushBotOdsFollowEvent.java old mode 100644 new mode 100755 index 7b25452..ae5782e --- a/opModes/PushBotOdsFollowEvent.java +++ b/opModes/PushBotOdsFollowEvent.java @@ -1,9 +1,13 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; //------------------------------------------------------------------------------ // // PushBotOdsFollowEvent // + +import com.qualcomm.robotcore.eventloop.opmode.Disabled; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; + /** * Provide a basic autonomous operational mode that demonstrates the use of an * optical distance sensor to follow a line implemented using a state machine @@ -12,6 +16,9 @@ * @author SSI Robotics * @version 2015-08-30-11-45 */ +@TeleOp(name = "PushBotOdsFollowEvent", group = "pushbot") +@Disabled +// comment out the above line if you want this op mode to be enabled. public class PushBotOdsFollowEvent extends PushBotTelemetrySensors { diff --git a/opModes/PushBotSquare.java b/opModes/PushBotSquare.java old mode 100644 new mode 100755 index 3ebe2d6..f8394ee --- a/opModes/PushBotSquare.java +++ b/opModes/PushBotSquare.java @@ -1,14 +1,17 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; import com.qualcomm.robotcore.hardware.DcMotor; -import com.qualcomm.robotcore.hardware.DcMotorController; /* * An example linear op mode where the pushbot * will drive in a square pattern using sleep() * and a for loop. */ +@TeleOp(name = "PushBotSquare", group = "pushbot") +//@Disabled +// comment out the above line if you want this op mode to be enabled. public class PushBotSquare extends LinearOpMode { DcMotor leftMotor; DcMotor rightMotor; @@ -18,25 +21,35 @@ public void runOpMode() throws InterruptedException { leftMotor = hardwareMap.dcMotor.get("left_drive"); rightMotor = hardwareMap.dcMotor.get("right_drive"); rightMotor.setDirection(DcMotor.Direction.REVERSE); - leftMotor.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS); - rightMotor.setMode(DcMotorController.RunMode.RUN_USING_ENCODERS); + leftMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER); + rightMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER); waitForStart(); for(int i=0; i<4; i++) { - leftMotor.setPower(1.0); - rightMotor.setPower(1.0); + leftMotor.setPower(0.5); + rightMotor.setPower(0.5); + + telemetry.addData("i", i); + telemetry.addData("leftPow", leftMotor.getPower()); + telemetry.addData("rightPow", rightMotor.getPower()); + telemetry.update(); sleep(1000); - leftMotor.setPower(0.5); - rightMotor.setPower(-0.5); + leftMotor.setPower(0.25); + rightMotor.setPower(-0.25); + + telemetry.addData("i", i); + telemetry.addData("leftPow", leftMotor.getPower()); + telemetry.addData("rightPow", rightMotor.getPower()); + telemetry.update(); - sleep(500); + sleep(750); } - leftMotor.setPowerFloat(); - rightMotor.setPowerFloat(); + //leftMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.FLOAT); + //rightMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.FLOAT); } } diff --git a/opModes/PushBotTelemetry.java b/opModes/PushBotTelemetry.java old mode 100644 new mode 100755 index 8227a29..b000c20 --- a/opModes/PushBotTelemetry.java +++ b/opModes/PushBotTelemetry.java @@ -1,4 +1,4 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; //------------------------------------------------------------------------------ // diff --git a/opModes/PushBotTelemetrySensors.java b/opModes/PushBotTelemetrySensors.java old mode 100644 new mode 100755 index 61de0b8..c67c541 --- a/opModes/PushBotTelemetrySensors.java +++ b/opModes/PushBotTelemetrySensors.java @@ -1,4 +1,4 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; import com.qualcomm.robotcore.hardware.IrSeekerSensor; diff --git a/opModes/PushBotTouchEvent.java b/opModes/PushBotTouchEvent.java old mode 100644 new mode 100755 index e1c47cb..6ba9ff1 --- a/opModes/PushBotTouchEvent.java +++ b/opModes/PushBotTouchEvent.java @@ -1,4 +1,4 @@ -package com.qualcomm.ftcrobotcontroller.opmodes; +package org.firstinspires.ftc.teamcode; //------------------------------------------------------------------------------ // @@ -9,7 +9,7 @@ * touch sensor to control the arm using a state machine for the Push Bot. * * @author SSI Robotics - * @version 2015-08-30-11-45 + * @version 2016-09-05-11-45 */ public class PushBotTouchEvent extends PushBotTelemetrySensors