├── .github
├── CONTRIBUTING.md
└── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── FtcRobotController
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── org
│ │ └── firstinspires
│ │ └── ftc
│ │ └── robotcontroller
│ │ ├── external
│ │ └── samples
│ │ │ ├── BasicOmniOpMode_Linear.java
│ │ │ ├── BasicOpMode_Iterative.java
│ │ │ ├── BasicOpMode_Linear.java
│ │ │ ├── ConceptAprilTag.java
│ │ │ ├── ConceptAprilTagEasy.java
│ │ │ ├── ConceptAprilTagLocalization.java
│ │ │ ├── ConceptAprilTagMultiPortal.java
│ │ │ ├── ConceptAprilTagOptimizeExposure.java
│ │ │ ├── ConceptAprilTagSwitchableCameras.java
│ │ │ ├── ConceptExploringIMUOrientation.java
│ │ │ ├── ConceptExternalHardwareClass.java
│ │ │ ├── ConceptGamepadRumble.java
│ │ │ ├── ConceptGamepadTouchpad.java
│ │ │ ├── ConceptLEDStick.java
│ │ │ ├── ConceptMotorBulkRead.java
│ │ │ ├── ConceptNullOp.java
│ │ │ ├── ConceptRampMotorSpeed.java
│ │ │ ├── ConceptRevLED.java
│ │ │ ├── ConceptRevSPARKMini.java
│ │ │ ├── ConceptScanServo.java
│ │ │ ├── ConceptSoundsASJava.java
│ │ │ ├── ConceptSoundsOnBotJava.java
│ │ │ ├── ConceptSoundsSKYSTONE.java
│ │ │ ├── ConceptTelemetry.java
│ │ │ ├── ConceptVisionColorLocator.java
│ │ │ ├── ConceptVisionColorSensor.java
│ │ │ ├── RobotAutoDriveByEncoder_Linear.java
│ │ │ ├── RobotAutoDriveByGyro_Linear.java
│ │ │ ├── RobotAutoDriveByTime_Linear.java
│ │ │ ├── RobotAutoDriveToAprilTagOmni.java
│ │ │ ├── RobotAutoDriveToAprilTagTank.java
│ │ │ ├── RobotAutoDriveToLine_Linear.java
│ │ │ ├── RobotHardware.java
│ │ │ ├── RobotTeleopPOV_Linear.java
│ │ │ ├── RobotTeleopTank_Iterative.java
│ │ │ ├── SampleRevBlinkinLedDriver.java
│ │ │ ├── SensorBNO055IMU.java
│ │ │ ├── SensorBNO055IMUCalibration.java
│ │ │ ├── SensorColor.java
│ │ │ ├── SensorDigitalTouch.java
│ │ │ ├── SensorHuskyLens.java
│ │ │ ├── SensorIMUNonOrthogonal.java
│ │ │ ├── SensorIMUOrthogonal.java
│ │ │ ├── SensorKLNavxMicro.java
│ │ │ ├── SensorLimelight3A.java
│ │ │ ├── SensorMRColor.java
│ │ │ ├── SensorMRGyro.java
│ │ │ ├── SensorMROpticalDistance.java
│ │ │ ├── SensorMRRangeSensor.java
│ │ │ ├── SensorOctoQuad.java
│ │ │ ├── SensorOctoQuadAdv.java
│ │ │ ├── SensorREV2mDistance.java
│ │ │ ├── SensorSparkFunOTOS.java
│ │ │ ├── SensorTouch.java
│ │ │ ├── UtilityCameraFrameCapture.java
│ │ │ ├── UtilityOctoQuadConfigMenu.java
│ │ │ ├── readme.md
│ │ │ └── sample_conventions.md
│ │ └── internal
│ │ ├── FtcOpModeRegister.java
│ │ ├── FtcRobotControllerActivity.java
│ │ └── PermissionValidatorWrapper.java
│ └── res
│ ├── drawable-xhdpi
│ ├── icon_menu.png
│ └── icon_robotcontroller.png
│ ├── layout
│ └── activity_ftc_controller.xml
│ ├── menu
│ └── ftc_robot_controller.xml
│ ├── raw
│ ├── gold.wav
│ └── silver.wav
│ ├── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
│ └── xml
│ ├── app_settings.xml
│ └── device_filter.xml
├── LICENSE
├── README.md
├── TeamCode
├── build.gradle
├── lib
│ └── OpModeAnnotationProcessor.jar
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── org
│ │ └── firstinspires
│ │ └── ftc
│ │ └── teamcode
│ │ └── readme.md
│ └── res
│ ├── raw
│ └── readme.md
│ ├── values
│ └── strings.xml
│ └── xml
│ └── teamwebcamcalibrations.xml
├── build.common.gradle
├── build.dependencies.gradle
├── build.gradle
├── doc
├── legal
│ ├── AudioBlocksSounds.txt
│ ├── Exhibit A - LEGO Open Source License Agreement.txt
│ └── LEGO Open Source License.pdf
└── media
│ └── PullRequest.PNG
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── libs
├── README.txt
└── ftc.debug.keystore
└── settings.gradle
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to the FTC SDK
2 |
3 | The following is a set of guidelines for contributing the FIRST FTC SDK. The FTC Technology Team welcomes suggestions for improvements to core software, ideas for new features, requests for built-in support of new sensors, and well written bug reports.
4 |
5 | ## How can I contribute?
6 |
7 | ### Pull requests
8 |
9 | __STOP!__ If you are new to git, do not understand the mechanics of forks, branches, and pulls, if what you just read is confusing, __do not__ push this button. Most likely it won't do what you think it will.
10 |
11 | 
12 |
13 | If you are looking at this button then you've pushed some changes to your team's fork of ftctechnh/ftc_app. Congratulations! You are almost certainly finished.
14 |
15 | The vast majority of pull requests seen on the ftctechnh/ftc_app repository are not intended to be merged into the official SDK. Team software is just that, your team's. It's specific to the tasks you are trying to accomplish, the testing you are doing, and goals your team has. You don't want that pushed into the official SDK.
16 |
17 | If what you've read so far makes little sense, there are some very good git learning resources online.
18 | [Git Book](https://git-scm.com/book/en/v2)
19 | [Interactive Git Tutorial](https://try.github.io)
20 |
21 | ### Guidlines for experienced GIT users.
22 |
23 | If you are absolutely certain that you want to push the big green button above, read on. Otherwise back _slowly away from keyboard_.
24 |
25 | The real intent for advanced users is often to issue a pull request from the [branch](https://www.atlassian.com/git/tutorials/using-branches/git-branch) on a local fork back to master on either the same local fork or a child of the team fork and not on the parent ftctechnh/ftc_app. See [Creating a Pull Request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/).
26 |
27 | If that is indeed the intent, then you can merge your [topic branch](https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows#Topic-Branches) into master locally by hand before pushing it up to github, or if you want a pull request for pulls between branches on the same repository because, say, you want team members to look at your software before merging into master, you can select the base fork from the dropdown on the "Open a pull request" page and select your team repo instead of ftctechnh's.
28 |
29 | Alternatively, if you have a team repository forked from ftctechnh/ftc_app, and then team members individually fork from your team repository, then pull requests from the individual team member's forks will have the main team repository automatically selected as the base fork for the pull. And you won't inadvertently request to pull your team software into ftctechnh's repository.
30 |
31 | The latter would be the "best" way to manage software among a large team. But as with all things git there are many options.
32 |
33 | Pull requests that do not fall into the category above are evaluated by the FTC Technology Team on a case-by-case basis. Please note however that the deployment model of the SDK does not support direct pulls into ftctechnh/ftc_app.
34 |
35 | ### Report bugs
36 |
37 | This section guides you through filing a bug report. The better the report the more likely it is to be root caused and fixed. Please refrain from feature requests or software enhancements when opening new issues. See Suggesting Enhancements below.
38 |
39 | #### Before submitting a bug report
40 |
41 | - Check the [forums](http://ftcforum.firstinspires.org/forum.php) to see if someone else has run into the problem and whether there is an official solution that doesn't require a new SDK.
42 |
43 | - Perform a search of current [issues](https://github.com/FIRST-Tech-Challenge/FtcRobotController/issues) to see if the problem has already been reported. If so, add a comment to the existing issue instead of creating a new one.
44 |
45 | #### How Do I Submit A (Good) Bug Report?
46 |
47 | Bugs are tracked as GitHub issues. Create an issue on ftctechnh/ftc_app and provide the following information.
48 | Explain the problem and include additional details to help maintainers reproduce the problem:
49 |
50 | - Use a clear and descriptive title for the issue to identify the problem.
51 |
52 | - Describe the exact steps which reproduce the problem in as many details as possible.
53 |
54 | - Provide specific examples to demonstrate the steps.
55 |
56 | - Describe the behavior you observed after following the steps and point out what exactly is the problem with that behavior. Explain which behavior you expected to see instead and why. If applicable, include screenshots which show you following the described steps and clearly demonstrate the problem.
57 |
58 | - If you're reporting that the RobotController crashed, include the logfile with a stack trace of the crash. [Example of good bug report with stack trace](https://github.com/ftctechnh/ftc_app/issues/224)
59 |
60 | - If the problem wasn't triggered by a specific action, describe what you were doing before the problem happened and share more information using the guidelines below.
61 |
62 | ### Suggesting Enhancements
63 |
64 | FIRST volunteers are awesome. You all have great ideas and we want to hear them.
65 |
66 | Enhancements should be broadly applicable to a large majority of teams, should not force teams to change their workflow, and should provide real value to the mission of FIRST as it relates to engaging youth in engineering activities.
67 |
68 | The best way to get momentum behind new features is to post a description of your idea in the discussions section of this repository. Build community support for it. The FTC Technology Team monitors the discussions. We'll hear you and if there's a large enough call for the feature it's very likely to get put on the list for a future release.
69 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Before issuing a pull request, please see the contributing page.
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.aar
4 | *.ap_
5 | *.aab
6 |
7 | !libs/*.aar
8 |
9 | # Files for the ART/Dalvik VM
10 | *.dex
11 |
12 | # Java/JDK files
13 | *.class
14 | *.hprof
15 |
16 | # Generated files
17 | bin/
18 | gen/
19 | out/
20 | # Uncomment the following line in case you need and you don't have the release build type files in your app
21 | # release/
22 |
23 | # Gradle files
24 | .gradle/
25 | build/
26 |
27 | # Local configuration file (sdk path, etc)
28 | local.properties
29 |
30 | # Proguard folder generated by Eclipse
31 | proguard/
32 |
33 | # Log Files
34 | *.log
35 |
36 | # Android Studio Navigation editor temp files
37 | .navigation/
38 |
39 | # Android Studio captures folder
40 | captures/
41 |
42 | # IntelliJ
43 | *.iml
44 | .idea/
45 |
46 | # For Mac users
47 | .DS_Store
48 |
49 | # Keystore files
50 | # Uncomment the following lines if you do not want to check your keystore files in.
51 | #*.jks
52 | #*.keystore
53 |
54 | # External native build folder generated in Android Studio 2.2 and later
55 | .externalNativeBuild
56 | .cxx/
57 |
58 | # Google Services (e.g. APIs or Firebase)
59 | # google-services.json
60 |
61 | # Freeline
62 | freeline.py
63 | freeline/
64 | freeline_project_description.json
65 |
66 | # fastlane
67 | fastlane/report.xml
68 | fastlane/Preview.html
69 | fastlane/screenshots
70 | fastlane/test_output
71 | fastlane/readme.md
72 |
73 | # Version control
74 | vcs.xml
75 |
76 | # lint
77 | lint/intermediates/
78 | lint/generated/
79 | lint/outputs/
80 | lint/tmp/
81 | # lint/reports/
--------------------------------------------------------------------------------
/FtcRobotController/build.gradle:
--------------------------------------------------------------------------------
1 | import java.text.SimpleDateFormat
2 |
3 | //
4 | // build.gradle in FtcRobotController
5 | //
6 | apply plugin: 'com.android.library'
7 |
8 | android {
9 |
10 | defaultConfig {
11 | minSdkVersion 24
12 | //noinspection ExpiredTargetSdkVersion
13 | targetSdkVersion 28
14 | buildConfigField "String", "APP_BUILD_TIME", '"' + (new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.ROOT).format(new Date())) + '"'
15 | }
16 |
17 | buildFeatures {
18 | buildConfig = true
19 | }
20 |
21 | compileSdkVersion 30
22 |
23 | compileOptions {
24 | sourceCompatibility JavaVersion.VERSION_1_8
25 | targetCompatibility JavaVersion.VERSION_1_8
26 | }
27 | namespace = 'com.qualcomm.ftcrobotcontroller'
28 | }
29 |
30 | apply from: '../build.dependencies.gradle'
31 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
16 |
17 |
18 |
21 |
22 |
23 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
42 |
43 |
44 |
45 |
46 |
47 |
50 |
51 |
52 |
55 |
56 |
57 |
58 |
61 |
62 |
63 |
64 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOpMode_Iterative.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2017 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
33 | import com.qualcomm.robotcore.eventloop.opmode.OpMode;
34 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
35 | import com.qualcomm.robotcore.hardware.DcMotor;
36 | import com.qualcomm.robotcore.util.ElapsedTime;
37 | import com.qualcomm.robotcore.util.Range;
38 |
39 | /*
40 | * This file contains an example of an iterative (Non-Linear) "OpMode".
41 | * An OpMode is a 'program' that runs in either the autonomous or the teleop period of an FTC match.
42 | * The names of OpModes appear on the menu of the FTC Driver Station.
43 | * When a selection is made from the menu, the corresponding OpMode
44 | * class is instantiated on the Robot Controller and executed.
45 | *
46 | * This particular OpMode just executes a basic Tank Drive Teleop for a two wheeled robot
47 | * It includes all the skeletal structure that all iterative OpModes contain.
48 | *
49 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
50 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
51 | */
52 |
53 | @TeleOp(name="Basic: Iterative OpMode", group="Iterative OpMode")
54 | @Disabled
55 | public class BasicOpMode_Iterative extends OpMode
56 | {
57 | // Declare OpMode members.
58 | private ElapsedTime runtime = new ElapsedTime();
59 | private DcMotor leftDrive = null;
60 | private DcMotor rightDrive = null;
61 |
62 | /*
63 | * Code to run ONCE when the driver hits INIT
64 | */
65 | @Override
66 | public void init() {
67 | telemetry.addData("Status", "Initialized");
68 |
69 | // Initialize the hardware variables. Note that the strings used here as parameters
70 | // to 'get' must correspond to the names assigned during the robot configuration
71 | // step (using the FTC Robot Controller app on the phone).
72 | leftDrive = hardwareMap.get(DcMotor.class, "left_drive");
73 | rightDrive = hardwareMap.get(DcMotor.class, "right_drive");
74 |
75 | // To drive forward, most robots need the motor on one side to be reversed, because the axles point in opposite directions.
76 | // Pushing the left stick forward MUST make robot go forward. So adjust these two lines based on your first test drive.
77 | // Note: The settings here assume direct drive on left and right wheels. Gear Reduction or 90 Deg drives may require direction flips
78 | leftDrive.setDirection(DcMotor.Direction.REVERSE);
79 | rightDrive.setDirection(DcMotor.Direction.FORWARD);
80 |
81 | // Tell the driver that initialization is complete.
82 | telemetry.addData("Status", "Initialized");
83 | }
84 |
85 | /*
86 | * Code to run REPEATEDLY after the driver hits INIT, but before they hit START
87 | */
88 | @Override
89 | public void init_loop() {
90 | }
91 |
92 | /*
93 | * Code to run ONCE when the driver hits START
94 | */
95 | @Override
96 | public void start() {
97 | runtime.reset();
98 | }
99 |
100 | /*
101 | * Code to run REPEATEDLY after the driver hits START but before they hit STOP
102 | */
103 | @Override
104 | public void loop() {
105 | // Setup a variable for each drive wheel to save power level for telemetry
106 | double leftPower;
107 | double rightPower;
108 |
109 | // Choose to drive using either Tank Mode, or POV Mode
110 | // Comment out the method that's not used. The default below is POV.
111 |
112 | // POV Mode uses left stick to go forward, and right stick to turn.
113 | // - This uses basic math to combine motions and is easier to drive straight.
114 | double drive = -gamepad1.left_stick_y;
115 | double turn = gamepad1.right_stick_x;
116 | leftPower = Range.clip(drive + turn, -1.0, 1.0) ;
117 | rightPower = Range.clip(drive - turn, -1.0, 1.0) ;
118 |
119 | // Tank Mode uses one stick to control each wheel.
120 | // - This requires no math, but it is hard to drive forward slowly and keep straight.
121 | // leftPower = -gamepad1.left_stick_y ;
122 | // rightPower = -gamepad1.right_stick_y ;
123 |
124 | // Send calculated power to wheels
125 | leftDrive.setPower(leftPower);
126 | rightDrive.setPower(rightPower);
127 |
128 | // Show the elapsed game time and wheel power.
129 | telemetry.addData("Status", "Run Time: " + runtime.toString());
130 | telemetry.addData("Motors", "left (%.2f), right (%.2f)", leftPower, rightPower);
131 | }
132 |
133 | /*
134 | * Code to run ONCE after the driver hits STOP
135 | */
136 | @Override
137 | public void stop() {
138 | }
139 |
140 | }
141 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOpMode_Linear.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2017 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
33 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
34 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
35 | import com.qualcomm.robotcore.hardware.DcMotor;
36 | import com.qualcomm.robotcore.util.ElapsedTime;
37 | import com.qualcomm.robotcore.util.Range;
38 |
39 |
40 | /*
41 | * This file contains an minimal example of a Linear "OpMode". An OpMode is a 'program' that runs in either
42 | * the autonomous or the teleop period of an FTC match. The names of OpModes appear on the menu
43 | * of the FTC Driver Station. When a selection is made from the menu, the corresponding OpMode
44 | * class is instantiated on the Robot Controller and executed.
45 | *
46 | * This particular OpMode just executes a basic Tank Drive Teleop for a two wheeled robot
47 | * It includes all the skeletal structure that all linear OpModes contain.
48 | *
49 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
50 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
51 | */
52 |
53 | @TeleOp(name="Basic: Linear OpMode", group="Linear OpMode")
54 | @Disabled
55 | public class BasicOpMode_Linear extends LinearOpMode {
56 |
57 | // Declare OpMode members.
58 | private ElapsedTime runtime = new ElapsedTime();
59 | private DcMotor leftDrive = null;
60 | private DcMotor rightDrive = null;
61 |
62 | @Override
63 | public void runOpMode() {
64 | telemetry.addData("Status", "Initialized");
65 | telemetry.update();
66 |
67 | // Initialize the hardware variables. Note that the strings used here as parameters
68 | // to 'get' must correspond to the names assigned during the robot configuration
69 | // step (using the FTC Robot Controller app on the phone).
70 | leftDrive = hardwareMap.get(DcMotor.class, "left_drive");
71 | rightDrive = hardwareMap.get(DcMotor.class, "right_drive");
72 |
73 | // To drive forward, most robots need the motor on one side to be reversed, because the axles point in opposite directions.
74 | // Pushing the left stick forward MUST make robot go forward. So adjust these two lines based on your first test drive.
75 | // Note: The settings here assume direct drive on left and right wheels. Gear Reduction or 90 Deg drives may require direction flips
76 | leftDrive.setDirection(DcMotor.Direction.REVERSE);
77 | rightDrive.setDirection(DcMotor.Direction.FORWARD);
78 |
79 | // Wait for the game to start (driver presses START)
80 | waitForStart();
81 | runtime.reset();
82 |
83 | // run until the end of the match (driver presses STOP)
84 | while (opModeIsActive()) {
85 |
86 | // Setup a variable for each drive wheel to save power level for telemetry
87 | double leftPower;
88 | double rightPower;
89 |
90 | // Choose to drive using either Tank Mode, or POV Mode
91 | // Comment out the method that's not used. The default below is POV.
92 |
93 | // POV Mode uses left stick to go forward, and right stick to turn.
94 | // - This uses basic math to combine motions and is easier to drive straight.
95 | double drive = -gamepad1.left_stick_y;
96 | double turn = gamepad1.right_stick_x;
97 | leftPower = Range.clip(drive + turn, -1.0, 1.0) ;
98 | rightPower = Range.clip(drive - turn, -1.0, 1.0) ;
99 |
100 | // Tank Mode uses one stick to control each wheel.
101 | // - This requires no math, but it is hard to drive forward slowly and keep straight.
102 | // leftPower = -gamepad1.left_stick_y ;
103 | // rightPower = -gamepad1.right_stick_y ;
104 |
105 | // Send calculated power to wheels
106 | leftDrive.setPower(leftPower);
107 | rightDrive.setPower(rightPower);
108 |
109 | // Show the elapsed game time and wheel power.
110 | telemetry.addData("Status", "Run Time: " + runtime.toString());
111 | telemetry.addData("Motors", "left (%.2f), right (%.2f)", leftPower, rightPower);
112 | telemetry.update();
113 | }
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptAprilTagMultiPortal.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2024 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
33 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
34 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
35 |
36 | import org.firstinspires.ftc.robotcore.external.hardware.camera.BuiltinCameraDirection;
37 | import org.firstinspires.ftc.robotcore.external.hardware.camera.WebcamName;
38 | import org.firstinspires.ftc.vision.VisionPortal;
39 | import org.firstinspires.ftc.vision.apriltag.AprilTagProcessor;
40 |
41 | /**
42 | * This OpMode demonstrates the basics of using multiple vision portals simultaneously
43 | */
44 | @TeleOp(name = "Concept: AprilTagMultiPortal", group = "Concept")
45 | @Disabled
46 | public class ConceptAprilTagMultiPortal extends LinearOpMode
47 | {
48 | VisionPortal portal1;
49 | VisionPortal portal2;
50 |
51 | AprilTagProcessor aprilTagProcessor1;
52 | AprilTagProcessor aprilTagProcessor2;
53 |
54 | @Override
55 | public void runOpMode() throws InterruptedException
56 | {
57 | // Because we want to show two camera feeds simultaneously, we need to inform
58 | // the SDK that we want it to split the camera monitor area into two smaller
59 | // areas for us. It will then give us View IDs which we can pass to the individual
60 | // vision portals to allow them to properly hook into the UI in tandem.
61 | int[] viewIds = VisionPortal.makeMultiPortalView(2, VisionPortal.MultiPortalLayout.VERTICAL);
62 |
63 | // We extract the two view IDs from the array to make our lives a little easier later.
64 | // NB: the array is 2 long because we asked for 2 portals up above.
65 | int portal1ViewId = viewIds[0];
66 | int portal2ViewId = viewIds[1];
67 |
68 | // If we want to run AprilTag detection on two portals simultaneously,
69 | // we need to create two distinct instances of the AprilTag processor,
70 | // one for each portal. If you want to see more detail about different
71 | // options that you have when creating these processors, go check out
72 | // the ConceptAprilTag OpMode.
73 | aprilTagProcessor1 = AprilTagProcessor.easyCreateWithDefaults();
74 | aprilTagProcessor2 = AprilTagProcessor.easyCreateWithDefaults();
75 |
76 | // Now we build both portals. The CRITICAL thing to notice here is the call to
77 | // setLiveViewContainerId(), where we pass in the IDs we received earlier from
78 | // makeMultiPortalView().
79 | portal1 = new VisionPortal.Builder()
80 | .setCamera(hardwareMap.get(WebcamName.class, "Webcam 1"))
81 | .setLiveViewContainerId(portal1ViewId)
82 | .addProcessor(aprilTagProcessor1)
83 | .build();
84 | portal2 = new VisionPortal.Builder()
85 | .setCamera(hardwareMap.get(WebcamName.class, "Webcam 2"))
86 | .setLiveViewContainerId(portal2ViewId)
87 | .addProcessor(aprilTagProcessor2)
88 | .build();
89 |
90 | waitForStart();
91 |
92 | // Main Loop
93 | while (opModeIsActive())
94 | {
95 | // Just show some basic telemetry to demonstrate both processors are working in parallel
96 | // on their respective cameras. If you want to see more detail about the information you
97 | // can get back from the processor, you should look at ConceptAprilTag.
98 | telemetry.addData("Number of tags in Camera 1", aprilTagProcessor1.getDetections().size());
99 | telemetry.addData("Number of tags in Camera 2", aprilTagProcessor2.getDetections().size());
100 | telemetry.update();
101 | sleep(20);
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptGamepadTouchpad.java:
--------------------------------------------------------------------------------
1 | package org.firstinspires.ftc.robotcontroller.external.samples;
2 |
3 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
4 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
5 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
6 | import org.firstinspires.ftc.robotcore.external.Telemetry;
7 |
8 | /*
9 | * This OpMode illustrates using the touchpad feature found on some gamepads.
10 | *
11 | * The Sony PS4 gamepad can detect two distinct touches on the central touchpad.
12 | * Other gamepads with different touchpads may provide mixed results.
13 | *
14 | * The touchpads are accessed through the standard gamepad1 and gamepad2 objects.
15 | * Several new members were added to the Gamepad class in FTC SDK Rev 7
16 | *
17 | * .touchpad_finger_1 returns true if at least one finger is detected.
18 | * .touchpad_finger_1_x finger 1 X coordinate. Valid if touchpad_finger_1 is true
19 | * .touchpad_finger_1_y finger 1 Y coordinate. Valid if touchpad_finger_1 is true
20 | *
21 | * .touchpad_finger_2 returns true if a second finger is detected
22 | * .touchpad_finger_2_x finger 2 X coordinate. Valid if touchpad_finger_2 is true
23 | * .touchpad_finger_2_y finger 2 Y coordinate. Valid if touchpad_finger_2 is true
24 | *
25 | * Finger touches are reported with an X and Y coordinate in following coordinate system.
26 | *
27 | * 1) X is the Horizontal axis, and Y is the vertical axis
28 | * 2) The 0,0 origin is at the center of the touchpad.
29 | * 3) 1.0, 1.0 is at the top right corner of the touchpad.
30 | * 4) -1.0,-1.0 is at the bottom left corner of the touchpad.
31 | *
32 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
33 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list.
34 | */
35 |
36 | @Disabled
37 | @TeleOp(name="Concept: Gamepad Touchpad", group ="Concept")
38 | public class ConceptGamepadTouchpad extends LinearOpMode
39 | {
40 | @Override
41 | public void runOpMode()
42 | {
43 | telemetry.setDisplayFormat(Telemetry.DisplayFormat.MONOSPACE);
44 |
45 | telemetry.addData(">", "Press Start");
46 | telemetry.update();
47 |
48 | waitForStart();
49 |
50 | while (opModeIsActive())
51 | {
52 | boolean finger = false;
53 |
54 | // Display finger 1 x & y position if finger detected
55 | if(gamepad1.touchpad_finger_1)
56 | {
57 | finger = true;
58 | telemetry.addLine(String.format("Finger 1: x=%5.2f y=%5.2f\n", gamepad1.touchpad_finger_1_x, gamepad1.touchpad_finger_1_y));
59 | }
60 |
61 | // Display finger 2 x & y position if finger detected
62 | if(gamepad1.touchpad_finger_2)
63 | {
64 | finger = true;
65 | telemetry.addLine(String.format("Finger 2: x=%5.2f y=%5.2f\n", gamepad1.touchpad_finger_2_x, gamepad1.touchpad_finger_2_y));
66 | }
67 |
68 | if(!finger)
69 | {
70 | telemetry.addLine("No fingers");
71 | }
72 |
73 | telemetry.update();
74 | sleep(10);
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptLEDStick.java:
--------------------------------------------------------------------------------
1 | package org.firstinspires.ftc.robotcontroller.external.samples;
2 | /*
3 | Copyright (c) 2021-24 Alan Smith
4 |
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without modification,
8 | are permitted (subject to the limitations in the disclaimer below) provided that
9 | the following conditions are met:
10 |
11 | Redistributions of source code must retain the above copyright notice, this list
12 | of conditions and the following disclaimer.
13 |
14 | Redistributions in binary form must reproduce the above copyright notice, this
15 | list of conditions and the following disclaimer in the documentation and/or
16 | other materials provided with the distribution.
17 |
18 | Neither the name of Alan Smith nor the names of its contributors may be used to
19 | endorse or promote products derived from this software without specific prior
20 | written permission.
21 |
22 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
23 | LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE
26 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
27 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
31 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | import android.graphics.Color;
36 |
37 | import com.qualcomm.hardware.sparkfun.SparkFunLEDStick;
38 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
39 | import com.qualcomm.robotcore.eventloop.opmode.OpMode;
40 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
41 | import com.qualcomm.robotcore.util.Range;
42 |
43 | /*
44 | * This OpMode illustrates how to use the SparkFun QWIIC LED Strip
45 | *
46 | * This is a simple way to add a strip of 10 LEDs to your robot where you can set the color of each
47 | * LED or the whole strip. This allows for driver feedback or even just fun ways to show your team
48 | * colors.
49 | *
50 | * Why?
51 | * Because more LEDs == more fun!!
52 | *
53 | * This OpMode assumes that the QWIIC LED Stick is attached to an I2C interface named "back_leds" in the robot configuration.
54 | *
55 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
56 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
57 | *
58 | * You can buy this product here: https://www.sparkfun.com/products/18354
59 | * Don't forget to also buy this to make it easy to connect to your Control or Expansion Hub:
60 | * https://www.sparkfun.com/products/25596
61 | */
62 | @TeleOp(name = "Concept: LED Stick", group = "Concept")
63 | @Disabled
64 | public class ConceptLEDStick extends OpMode {
65 | private boolean wasUp;
66 | private boolean wasDown;
67 | private int brightness = 5; // this needs to be between 0 and 31
68 | private final static double END_GAME_TIME = 120 - 30;
69 |
70 | private SparkFunLEDStick ledStick;
71 |
72 | @Override
73 | public void init() {
74 | ledStick = hardwareMap.get(SparkFunLEDStick.class, "back_leds");
75 | ledStick.setBrightness(brightness);
76 | ledStick.setColor(Color.GREEN);
77 | }
78 |
79 | @Override
80 | public void start() {
81 | resetRuntime();
82 | }
83 |
84 | @Override
85 | public void loop() {
86 | telemetry.addLine("Hold the A button to turn blue");
87 | telemetry.addLine("Hold the B button to turn red");
88 | telemetry.addLine("Hold the left bumper to turn off");
89 | telemetry.addLine("Use DPAD Up/Down to change brightness");
90 |
91 | if (getRuntime() > END_GAME_TIME) {
92 | int[] ledColors = {Color.RED, Color.YELLOW, Color.RED, Color.YELLOW, Color.RED,
93 | Color.YELLOW, Color.RED, Color.YELLOW, Color.RED, Color.YELLOW};
94 | ledStick.setColors(ledColors);
95 | } else if (gamepad1.a) {
96 | ledStick.setColor(Color.BLUE);
97 | } else if (gamepad1.b) {
98 | ledStick.setColor(Color.RED);
99 | } else if (gamepad1.left_bumper) {
100 | ledStick.turnAllOff();
101 | } else {
102 | ledStick.setColor(Color.GREEN);
103 | }
104 |
105 | /*
106 | * Use DPAD up and down to change brightness
107 | */
108 | int newBrightness = brightness;
109 | if (gamepad1.dpad_up && !wasUp) {
110 | newBrightness = brightness + 1;
111 | } else if (gamepad1.dpad_down && !wasDown) {
112 | newBrightness = brightness - 1;
113 | }
114 | if (newBrightness != brightness) {
115 | brightness = Range.clip(newBrightness, 0, 31);
116 | ledStick.setBrightness(brightness);
117 | }
118 | telemetry.addData("Brightness", brightness);
119 |
120 | wasDown = gamepad1.dpad_down;
121 | wasUp = gamepad1.dpad_up;
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptNullOp.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2017 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
33 | import com.qualcomm.robotcore.eventloop.opmode.OpMode;
34 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
35 | import com.qualcomm.robotcore.util.ElapsedTime;
36 |
37 | /*
38 | * Demonstrates an empty iterative OpMode
39 | */
40 | @TeleOp(name = "Concept: NullOp", group = "Concept")
41 | @Disabled
42 | public class ConceptNullOp extends OpMode {
43 |
44 | private ElapsedTime runtime = new ElapsedTime();
45 |
46 | /**
47 | * This method will be called once, when the INIT button is pressed.
48 | */
49 | @Override
50 | public void init() {
51 | telemetry.addData("Status", "Initialized");
52 | }
53 |
54 | /**
55 | * This method will be called repeatedly during the period between when
56 | * the INIT button is pressed and when the START button is pressed (or the
57 | * OpMode is stopped).
58 | */
59 | @Override
60 | public void init_loop() {
61 | }
62 |
63 | /**
64 | * This method will be called once, when the START button is pressed.
65 | */
66 | @Override
67 | public void start() {
68 | runtime.reset();
69 | }
70 |
71 | /**
72 | * This method will be called repeatedly during the period between when
73 | * the START button is pressed and when the OpMode is stopped.
74 | */
75 | @Override
76 | public void loop() {
77 | telemetry.addData("Status", "Run Time: " + runtime.toString());
78 | }
79 |
80 | /**
81 | * This method will be called once, when this OpMode is stopped.
82 | *
83 | * Your ability to control hardware from this method will be limited.
84 | */
85 | @Override
86 | public void stop() {
87 |
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRampMotorSpeed.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2017 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
33 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
34 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
35 | import com.qualcomm.robotcore.hardware.DcMotor;
36 |
37 | /*
38 | * This OpMode ramps a single motor speed up and down repeatedly until Stop is pressed.
39 | * The code is structured as a LinearOpMode
40 | *
41 | * This code assumes a DC motor configured with the name "left_drive" as is found on a Robot.
42 | *
43 | * INCREMENT sets how much to increase/decrease the power each cycle
44 | * CYCLE_MS sets the update period.
45 | *
46 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
47 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
48 | */
49 | @TeleOp(name = "Concept: Ramp Motor Speed", group = "Concept")
50 | @Disabled
51 | public class ConceptRampMotorSpeed extends LinearOpMode {
52 |
53 | static final double INCREMENT = 0.01; // amount to ramp motor each CYCLE_MS cycle
54 | static final int CYCLE_MS = 50; // period of each cycle
55 | static final double MAX_FWD = 1.0; // Maximum FWD power applied to motor
56 | static final double MAX_REV = -1.0; // Maximum REV power applied to motor
57 |
58 | // Define class members
59 | DcMotor motor;
60 | double power = 0;
61 | boolean rampUp = true;
62 |
63 |
64 | @Override
65 | public void runOpMode() {
66 |
67 | // Connect to motor (Assume standard left wheel)
68 | // Change the text in quotes to match any motor name on your robot.
69 | motor = hardwareMap.get(DcMotor.class, "left_drive");
70 |
71 | // Wait for the start button
72 | telemetry.addData(">", "Press Start to run Motors." );
73 | telemetry.update();
74 | waitForStart();
75 |
76 | // Ramp motor speeds till stop pressed.
77 | while(opModeIsActive()) {
78 |
79 | // Ramp the motors, according to the rampUp variable.
80 | if (rampUp) {
81 | // Keep stepping up until we hit the max value.
82 | power += INCREMENT ;
83 | if (power >= MAX_FWD ) {
84 | power = MAX_FWD;
85 | rampUp = !rampUp; // Switch ramp direction
86 | }
87 | }
88 | else {
89 | // Keep stepping down until we hit the min value.
90 | power -= INCREMENT ;
91 | if (power <= MAX_REV ) {
92 | power = MAX_REV;
93 | rampUp = !rampUp; // Switch ramp direction
94 | }
95 | }
96 |
97 | // Display the current value
98 | telemetry.addData("Motor Power", "%5.2f", power);
99 | telemetry.addData(">", "Press Stop to end test." );
100 | telemetry.update();
101 |
102 | // Set the motor to the new power and pause;
103 | motor.setPower(power);
104 | sleep(CYCLE_MS);
105 | idle();
106 | }
107 |
108 | // Turn off motor and signal done;
109 | motor.setPower(0);
110 | telemetry.addData(">", "Done");
111 | telemetry.update();
112 |
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRevLED.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2024 Alan Smith
3 | All rights reserved.
4 | Redistribution and use in source and binary forms, with or without modification,
5 | are permitted (subject to the limitations in the disclaimer below) provided that
6 | the following conditions are met:
7 | Redistributions of source code must retain the above copyright notice, this list
8 | of conditions and the following disclaimer.
9 | Redistributions in binary form must reproduce the above copyright notice, this
10 | list of conditions and the following disclaimer in the documentation and/or
11 | other materials provided with the distribution.
12 | Neither the name of Alan Smith nor the names of its contributors may be used to
13 | endorse or promote products derived from this software without specific prior
14 | written permission.
15 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
16 | LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE
19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
24 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 | package org.firstinspires.ftc.robotcontroller.external.samples;
28 |
29 | /*
30 | * This OpMode illustrates how to use the REV Digital Indicator
31 | *
32 | * This is a simple way to add the REV Digital Indicator which has a red and green LED.
33 | * (and as you may remember, red + green = yellow so when they are both on you can get yellow)
34 | *
35 | * Why?
36 | * You can use this to show information to the driver. For example, green might be that you can
37 | * pick up more game elements and red would be that you already have the possession limit.
38 | *
39 | * This OpMode assumes that the REV Digital Indicator is setup as 2 Digital Channels named
40 | * front_led_green and front_led_red. (the green should be the lower of the 2 channels it is plugged
41 | * into and the red should be the higher)
42 | *
43 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
44 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
45 | *
46 | * You can buy this product here: https://www.revrobotics.com/rev-31-2010/
47 | */
48 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
49 | import com.qualcomm.robotcore.eventloop.opmode.OpMode;
50 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
51 | import com.qualcomm.robotcore.hardware.LED;
52 |
53 | @TeleOp(name = "Concept: RevLED", group = "Concept")
54 | @Disabled
55 | public class ConceptRevLED extends OpMode {
56 | LED frontLED_red;
57 | LED frontLED_green;
58 |
59 | @Override
60 | public void init() {
61 | frontLED_green = hardwareMap.get(LED.class, "front_led_green");
62 | frontLED_red = hardwareMap.get(LED.class, "front_led_red");
63 | }
64 |
65 | @Override
66 | public void loop() {
67 | if (gamepad1.a) {
68 | frontLED_red.on();
69 | } else {
70 | frontLED_red.off();
71 | }
72 | if (gamepad1.b) {
73 | frontLED_green.on();
74 | } else {
75 | frontLED_green.off();
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptRevSPARKMini.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2018 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
33 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
34 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
35 | import com.qualcomm.robotcore.hardware.DcMotorSimple;
36 | import com.qualcomm.robotcore.util.ElapsedTime;
37 | import com.qualcomm.robotcore.util.Range;
38 |
39 |
40 | /*
41 | * This OpMode demonstrates a POV Drive system, with commented-out code for a Tank Drive system,
42 | * for a two wheeled robot using two REV SPARKminis.
43 | * To use this example, connect two REV SPARKminis into servo ports on the Control Hub. On the
44 | * robot configuration, use the drop down list under 'Servos' to select 'REV SPARKmini Controller'
45 | * and name them 'left_drive' and 'right_drive'.
46 | *
47 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
48 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
49 | */
50 |
51 | @TeleOp(name="REV SPARKmini Simple Drive Example", group="Concept")
52 | @Disabled
53 | public class ConceptRevSPARKMini extends LinearOpMode {
54 |
55 | // Declare OpMode members.
56 | private ElapsedTime runtime = new ElapsedTime();
57 | private DcMotorSimple leftDrive = null;
58 | private DcMotorSimple rightDrive = null;
59 |
60 | @Override
61 | public void runOpMode() {
62 | telemetry.addData("Status", "Initialized");
63 | telemetry.update();
64 |
65 | // Initialize the hardware variables. Note that the strings used here as parameters
66 | // to 'get' must correspond to the names assigned during robot configuration.
67 | leftDrive = hardwareMap.get(DcMotorSimple.class, "left_drive");
68 | rightDrive = hardwareMap.get(DcMotorSimple.class, "right_drive");
69 |
70 | // Most robots need the motor on one side to be reversed to drive forward
71 | // Reverse the motor that runs backward when connected directly to the battery
72 | leftDrive.setDirection(DcMotorSimple.Direction.FORWARD);
73 | rightDrive.setDirection(DcMotorSimple.Direction.REVERSE);
74 |
75 | // Wait for the game to start (driver presses START)
76 | waitForStart();
77 | runtime.reset();
78 |
79 | // run until the end of the match (driver presses STOP)
80 | while (opModeIsActive()) {
81 |
82 | // Setup a variable for each drive wheel to save power level for telemetry
83 | double leftPower;
84 | double rightPower;
85 |
86 | // Choose to drive using either Tank Mode, or POV Mode
87 | // Comment out the method that's not used. The default below is POV.
88 |
89 | // POV Mode uses left stick to go forward, and right stick to turn.
90 | // - This uses basic math to combine motions and is easier to drive straight.
91 | double drive = -gamepad1.left_stick_y;
92 | double turn = gamepad1.right_stick_x;
93 | leftPower = Range.clip(drive + turn, -1.0, 1.0) ;
94 | rightPower = Range.clip(drive - turn, -1.0, 1.0) ;
95 |
96 | // Tank Mode uses one stick to control each wheel.
97 | // - This requires no math, but it is hard to drive forward slowly and keep straight.
98 | // leftPower = -gamepad1.left_stick_y ;
99 | // rightPower = -gamepad1.right_stick_y ;
100 |
101 | // Send calculated power to wheels
102 | leftDrive.setPower(leftPower);
103 | rightDrive.setPower(rightPower);
104 |
105 | // Show the elapsed game time and wheel power.
106 | telemetry.addData("Status", "Run Time: " + runtime.toString());
107 | telemetry.addData("Motors", "left (%.2f), right (%.2f)", leftPower, rightPower);
108 | telemetry.update();
109 | }
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptScanServo.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2017 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
33 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
34 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
35 | import com.qualcomm.robotcore.hardware.Servo;
36 |
37 | /*
38 | * This OpMode scans a single servo back and forward until Stop is pressed.
39 | * The code is structured as a LinearOpMode
40 | * INCREMENT sets how much to increase/decrease the servo position each cycle
41 | * CYCLE_MS sets the update period.
42 | *
43 | * This code assumes a Servo configured with the name "left_hand" as is found on a Robot.
44 | *
45 | * NOTE: When any servo position is set, ALL attached servos are activated, so ensure that any other
46 | * connected servos are able to move freely before running this test.
47 | *
48 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
49 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
50 | */
51 | @TeleOp(name = "Concept: Scan Servo", group = "Concept")
52 | @Disabled
53 | public class ConceptScanServo extends LinearOpMode {
54 |
55 | static final double INCREMENT = 0.01; // amount to slew servo each CYCLE_MS cycle
56 | static final int CYCLE_MS = 50; // period of each cycle
57 | static final double MAX_POS = 1.0; // Maximum rotational position
58 | static final double MIN_POS = 0.0; // Minimum rotational position
59 |
60 | // Define class members
61 | Servo servo;
62 | double position = (MAX_POS - MIN_POS) / 2; // Start at halfway position
63 | boolean rampUp = true;
64 |
65 |
66 | @Override
67 | public void runOpMode() {
68 |
69 | // Connect to servo (Assume Robot Left Hand)
70 | // Change the text in quotes to match any servo name on your robot.
71 | servo = hardwareMap.get(Servo.class, "left_hand");
72 |
73 | // Wait for the start button
74 | telemetry.addData(">", "Press Start to scan Servo." );
75 | telemetry.update();
76 | waitForStart();
77 |
78 |
79 | // Scan servo till stop pressed.
80 | while(opModeIsActive()){
81 |
82 | // slew the servo, according to the rampUp (direction) variable.
83 | if (rampUp) {
84 | // Keep stepping up until we hit the max value.
85 | position += INCREMENT ;
86 | if (position >= MAX_POS ) {
87 | position = MAX_POS;
88 | rampUp = !rampUp; // Switch ramp direction
89 | }
90 | }
91 | else {
92 | // Keep stepping down until we hit the min value.
93 | position -= INCREMENT ;
94 | if (position <= MIN_POS ) {
95 | position = MIN_POS;
96 | rampUp = !rampUp; // Switch ramp direction
97 | }
98 | }
99 |
100 | // Display the current value
101 | telemetry.addData("Servo Position", "%5.2f", position);
102 | telemetry.addData(">", "Press Stop to end test." );
103 | telemetry.update();
104 |
105 | // Set the servo to the new position and pause;
106 | servo.setPosition(position);
107 | sleep(CYCLE_MS);
108 | idle();
109 | }
110 |
111 | // Signal done;
112 | telemetry.addData(">", "Done");
113 | telemetry.update();
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptSoundsASJava.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2018 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.ftccommon.SoundPlayer;
33 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
34 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
35 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
36 |
37 | /*
38 | * This OpMode demonstrates how to play simple sounds on both the RC and DS phones.
39 | * It illustrates how to build sounds into your application as a resource.
40 | * This technique is best suited for use with Android Studio since it assumes you will be creating a new application
41 | *
42 | * If you are using OnBotJava, please see the ConceptSoundsOnBotJava sample
43 | *
44 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
45 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
46 | *
47 | * Operation:
48 | *
49 | * Gamepad X & B buttons are used to trigger sounds in this example, but any event can be used.
50 | * Note: Time should be allowed for sounds to complete before playing other sounds.
51 | *
52 | * For sound files to be used as a compiled-in resource, they need to be located in a folder called "raw" under your "res" (resources) folder.
53 | * You can create your own "raw" folder from scratch, or you can copy the one from the FtcRobotController module.
54 | *
55 | * Android Studio coders will ultimately need a folder in your path as follows:
56 | * /TeamCode/src/main/res/raw
57 | *
58 | * Copy any .wav files you want to play into this folder.
59 | * Make sure that your files ONLY use lower-case characters, and have no spaces or special characters other than underscore.
60 | *
61 | * The name you give your .wav files will become the resource ID for these sounds.
62 | * eg: gold.wav becomes R.raw.gold
63 | *
64 | * If you wish to use the sounds provided for this sample, they are located in:
65 | * /FtcRobotController/src/main/res/raw
66 | * You can copy and paste the entire 'raw' folder using Android Studio.
67 | *
68 | */
69 |
70 | @TeleOp(name="Concept: Sound Resources", group="Concept")
71 | @Disabled
72 | public class ConceptSoundsASJava extends LinearOpMode {
73 |
74 | // Declare OpMode members.
75 | private boolean goldFound; // Sound file present flags
76 | private boolean silverFound;
77 |
78 | private boolean isX = false; // Gamepad button state variables
79 | private boolean isB = false;
80 |
81 | private boolean wasX = false; // Gamepad button history variables
82 | private boolean WasB = false;
83 |
84 | @Override
85 | public void runOpMode() {
86 |
87 | // Determine Resource IDs for sounds built into the RC application.
88 | int silverSoundID = hardwareMap.appContext.getResources().getIdentifier("silver", "raw", hardwareMap.appContext.getPackageName());
89 | int goldSoundID = hardwareMap.appContext.getResources().getIdentifier("gold", "raw", hardwareMap.appContext.getPackageName());
90 |
91 | // Determine if sound resources are found.
92 | // Note: Preloading is NOT required, but it's a good way to verify all your sounds are available before you run.
93 | if (goldSoundID != 0)
94 | goldFound = SoundPlayer.getInstance().preload(hardwareMap.appContext, goldSoundID);
95 |
96 | if (silverSoundID != 0)
97 | silverFound = SoundPlayer.getInstance().preload(hardwareMap.appContext, silverSoundID);
98 |
99 | // Display sound status
100 | telemetry.addData("gold resource", goldFound ? "Found" : "NOT found\n Add gold.wav to /src/main/res/raw" );
101 | telemetry.addData("silver resource", silverFound ? "Found" : "Not found\n Add silver.wav to /src/main/res/raw" );
102 |
103 | // Wait for the game to start (driver presses START)
104 | telemetry.addData(">", "Press Start to continue");
105 | telemetry.update();
106 | waitForStart();
107 |
108 | telemetry.addData(">", "Press X, B to play sounds.");
109 | telemetry.update();
110 |
111 | // run until the end of the match (driver presses STOP)
112 | while (opModeIsActive()) {
113 |
114 | // say Silver each time gamepad X is pressed (This sound is a resource)
115 | if (silverFound && (isX = gamepad1.x) && !wasX) {
116 | SoundPlayer.getInstance().startPlaying(hardwareMap.appContext, silverSoundID);
117 | telemetry.addData("Playing", "Resource Silver");
118 | telemetry.update();
119 | }
120 |
121 | // say Gold each time gamepad B is pressed (This sound is a resource)
122 | if (goldFound && (isB = gamepad1.b) && !WasB) {
123 | SoundPlayer.getInstance().startPlaying(hardwareMap.appContext, goldSoundID);
124 | telemetry.addData("Playing", "Resource Gold");
125 | telemetry.update();
126 | }
127 |
128 | // Save last button states
129 | wasX = isX;
130 | WasB = isB;
131 | }
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptSoundsOnBotJava.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2018 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.ftccommon.SoundPlayer;
33 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
34 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
35 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
36 |
37 | import java.io.File;
38 |
39 | /*
40 | * This OpMode demonstrates how to play simple sounds on both the RC and DS phones.
41 | * It illustrates how to play sound files that have been copied to the RC Phone
42 | * This technique is best suited for use with OnBotJava since it does not require the app to be modified.
43 | *
44 | * Operation:
45 | *
46 | * Gamepad X & B buttons are used to trigger sounds in this example, but any event can be used.
47 | * Note: Time should be allowed for sounds to complete before playing other sounds.
48 | *
49 | * To play a new sound, you will need to copy the .wav files to the phone, and then provide the full path to them as part of your OpMode.
50 | * This is done in this sample for the two sound files. silver.wav and gold.wav
51 | *
52 | * You can put the files in a variety of soundPaths, but we recommend you put them in the /FIRST/blocks/sounds folder.
53 | * Your OpModes will have guaranteed access to this folder, and you can transfer files into this folder using the BLOCKS web page.
54 | * -- There is a link called "sounds" on the right hand side of the color bar on the BLOCKS page that can be used to send sound files to this folder by default.
55 | * Or you can use Windows File Manager, or ADB to transfer the sound files
56 | *
57 | * To get full use of THIS sample, you will need to copy two sound file called silver.wav and gold.wav to /FIRST/blocks/sounds on the RC phone.
58 | * They can be located here:
59 | * https://github.com/ftctechnh/ftc_app/tree/master/FtcRobotController/src/main/res/raw/gold.wav
60 | * https://github.com/ftctechnh/ftc_app/tree/master/FtcRobotController/src/main/res/raw/silver.wav
61 | */
62 |
63 | @TeleOp(name="Concept: Sound Files", group="Concept")
64 | @Disabled
65 | public class ConceptSoundsOnBotJava extends LinearOpMode {
66 |
67 | // Point to sound files on the phone's drive
68 | private String soundPath = "/FIRST/blocks/sounds";
69 | private File goldFile = new File("/sdcard" + soundPath + "/gold.wav");
70 | private File silverFile = new File("/sdcard" + soundPath + "/silver.wav");
71 |
72 | // Declare OpMode members.
73 | private boolean isX = false; // Gamepad button state variables
74 | private boolean isB = false;
75 |
76 | private boolean wasX = false; // Gamepad button history variables
77 | private boolean WasB = false;
78 |
79 | @Override
80 | public void runOpMode() {
81 |
82 | // Make sure that the sound files exist on the phone
83 | boolean goldFound = goldFile.exists();
84 | boolean silverFound = silverFile.exists();
85 |
86 | // Display sound status
87 | telemetry.addData("gold sound", goldFound ? "Found" : "NOT Found \nCopy gold.wav to " + soundPath );
88 | telemetry.addData("silver sound", silverFound ? "Found" : "NOT Found \nCopy silver.wav to " + soundPath );
89 |
90 | // Wait for the game to start (driver presses PLAY)
91 | telemetry.addData(">", "Press Start to continue");
92 | telemetry.update();
93 | waitForStart();
94 |
95 | telemetry.addData(">", "Press X or B to play sounds.");
96 | telemetry.update();
97 |
98 | // run until the end of the match (driver presses STOP)
99 | while (opModeIsActive()) {
100 |
101 | // say Silver each time gamepad X is pressed (This sound is a resource)
102 | if (silverFound && (isX = gamepad1.x) && !wasX) {
103 | SoundPlayer.getInstance().startPlaying(hardwareMap.appContext, silverFile);
104 | telemetry.addData("Playing", "Silver File");
105 | telemetry.update();
106 | }
107 |
108 | // say Gold each time gamepad B is pressed (This sound is a resource)
109 | if (goldFound && (isB = gamepad1.b) && !WasB) {
110 | SoundPlayer.getInstance().startPlaying(hardwareMap.appContext, goldFile);
111 | telemetry.addData("Playing", "Gold File");
112 | telemetry.update();
113 | }
114 |
115 | // Save last button states
116 | wasX = isX;
117 | WasB = isB;
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptSoundsSKYSTONE.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2018 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import android.content.Context;
33 | import com.qualcomm.ftccommon.SoundPlayer;
34 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
35 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
36 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
37 |
38 | /*
39 | * This OpMode demonstrates how to play one of the several SKYSTONE/Star Wars sounds loaded into the SDK.
40 | * It does this by creating a simple "chooser" controlled by the gamepad Up Down buttons.
41 | * This code also prevents sounds from stacking up by setting a "playing" flag, which is cleared when the sound finishes playing.
42 | *
43 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
44 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
45 | *
46 | * Operation:
47 | * Use the DPAD to change the selected sound, and the Right Bumper to play it.
48 | */
49 |
50 | @TeleOp(name="SKYSTONE Sounds", group="Concept")
51 | @Disabled
52 | public class ConceptSoundsSKYSTONE extends LinearOpMode {
53 |
54 | // List of available sound resources
55 | String sounds[] = {"ss_alarm", "ss_bb8_down", "ss_bb8_up", "ss_darth_vader", "ss_fly_by",
56 | "ss_mf_fail", "ss_laser", "ss_laser_burst", "ss_light_saber", "ss_light_saber_long", "ss_light_saber_short",
57 | "ss_light_speed", "ss_mine", "ss_power_up", "ss_r2d2_up", "ss_roger_roger", "ss_siren", "ss_wookie" };
58 | boolean soundPlaying = false;
59 |
60 | @Override
61 | public void runOpMode() {
62 |
63 | // Variables for choosing from the available sounds
64 | int soundIndex = 0;
65 | int soundID = -1;
66 | boolean was_dpad_up = false;
67 | boolean was_dpad_down = false;
68 |
69 | Context myApp = hardwareMap.appContext;
70 |
71 | // create a sound parameter that holds the desired player parameters.
72 | SoundPlayer.PlaySoundParams params = new SoundPlayer.PlaySoundParams();
73 | params.loopControl = 0;
74 | params.waitForNonLoopingSoundsToFinish = true;
75 |
76 | // In this sample, we will skip waiting for the user to press play, and start displaying sound choices right away
77 | while (!isStopRequested()) {
78 |
79 | // Look for DPAD presses to change the selection
80 | if (gamepad1.dpad_down && !was_dpad_down) {
81 | // Go to next sound (with list wrap) and display it
82 | soundIndex = (soundIndex + 1) % sounds.length;
83 | }
84 |
85 | if (gamepad1.dpad_up && !was_dpad_up) {
86 | // Go to previous sound (with list wrap) and display it
87 | soundIndex = (soundIndex + sounds.length - 1) % sounds.length;
88 | }
89 |
90 | // Look for trigger to see if we should play sound
91 | // Only start a new sound if we are currently not playing one.
92 | if (gamepad1.right_bumper && !soundPlaying) {
93 |
94 | // Determine Resource IDs for the sounds you want to play, and make sure it's valid.
95 | if ((soundID = myApp.getResources().getIdentifier(sounds[soundIndex], "raw", myApp.getPackageName())) != 0){
96 |
97 | // Signal that the sound is now playing.
98 | soundPlaying = true;
99 |
100 | // Start playing, and also Create a callback that will clear the playing flag when the sound is complete.
101 | SoundPlayer.getInstance().startPlaying(myApp, soundID, params, null,
102 | new Runnable() {
103 | public void run() {
104 | soundPlaying = false;
105 | }} );
106 | }
107 | }
108 |
109 | // Remember the last state of the dpad to detect changes.
110 | was_dpad_up = gamepad1.dpad_up;
111 | was_dpad_down = gamepad1.dpad_down;
112 |
113 | // Display the current sound choice, and the playing status.
114 | telemetry.addData("", "Use DPAD up/down to choose sound.");
115 | telemetry.addData("", "Press Right Bumper to play sound.");
116 | telemetry.addData("", "");
117 | telemetry.addData("Sound >", sounds[soundIndex]);
118 | telemetry.addData("Status >", soundPlaying ? "Playing" : "Stopped");
119 | telemetry.update();
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveByTime_Linear.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2017 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
33 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
34 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
35 | import com.qualcomm.robotcore.hardware.DcMotor;
36 | import com.qualcomm.robotcore.util.ElapsedTime;
37 |
38 | /*
39 | * This OpMode illustrates the concept of driving a path based on time.
40 | * The code is structured as a LinearOpMode
41 | *
42 | * The code assumes that you do NOT have encoders on the wheels,
43 | * otherwise you would use: RobotAutoDriveByEncoder;
44 | *
45 | * The desired path in this example is:
46 | * - Drive forward for 3 seconds
47 | * - Spin right for 1.3 seconds
48 | * - Drive Backward for 1 Second
49 | *
50 | * The code is written in a simple form with no optimizations.
51 | * However, there are several ways that this type of sequence could be streamlined,
52 | *
53 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
54 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
55 | */
56 |
57 | @Autonomous(name="Robot: Auto Drive By Time", group="Robot")
58 | @Disabled
59 | public class RobotAutoDriveByTime_Linear extends LinearOpMode {
60 |
61 | /* Declare OpMode members. */
62 | private DcMotor leftDrive = null;
63 | private DcMotor rightDrive = null;
64 |
65 | private ElapsedTime runtime = new ElapsedTime();
66 |
67 |
68 | static final double FORWARD_SPEED = 0.6;
69 | static final double TURN_SPEED = 0.5;
70 |
71 | @Override
72 | public void runOpMode() {
73 |
74 | // Initialize the drive system variables.
75 | leftDrive = hardwareMap.get(DcMotor.class, "left_drive");
76 | rightDrive = hardwareMap.get(DcMotor.class, "right_drive");
77 |
78 | // To drive forward, most robots need the motor on one side to be reversed, because the axles point in opposite directions.
79 | // When run, this OpMode should start both motors driving forward. So adjust these two lines based on your first test drive.
80 | // Note: The settings here assume direct drive on left and right wheels. Gear Reduction or 90 Deg drives may require direction flips
81 | leftDrive.setDirection(DcMotor.Direction.REVERSE);
82 | rightDrive.setDirection(DcMotor.Direction.FORWARD);
83 |
84 | // Send telemetry message to signify robot waiting;
85 | telemetry.addData("Status", "Ready to run"); //
86 | telemetry.update();
87 |
88 | // Wait for the game to start (driver presses START)
89 | waitForStart();
90 |
91 | // Step through each leg of the path, ensuring that the OpMode has not been stopped along the way.
92 |
93 | // Step 1: Drive forward for 3 seconds
94 | leftDrive.setPower(FORWARD_SPEED);
95 | rightDrive.setPower(FORWARD_SPEED);
96 | runtime.reset();
97 | while (opModeIsActive() && (runtime.seconds() < 3.0)) {
98 | telemetry.addData("Path", "Leg 1: %4.1f S Elapsed", runtime.seconds());
99 | telemetry.update();
100 | }
101 |
102 | // Step 2: Spin right for 1.3 seconds
103 | leftDrive.setPower(TURN_SPEED);
104 | rightDrive.setPower(-TURN_SPEED);
105 | runtime.reset();
106 | while (opModeIsActive() && (runtime.seconds() < 1.3)) {
107 | telemetry.addData("Path", "Leg 2: %4.1f S Elapsed", runtime.seconds());
108 | telemetry.update();
109 | }
110 |
111 | // Step 3: Drive Backward for 1 Second
112 | leftDrive.setPower(-FORWARD_SPEED);
113 | rightDrive.setPower(-FORWARD_SPEED);
114 | runtime.reset();
115 | while (opModeIsActive() && (runtime.seconds() < 1.0)) {
116 | telemetry.addData("Path", "Leg 3: %4.1f S Elapsed", runtime.seconds());
117 | telemetry.update();
118 | }
119 |
120 | // Step 4: Stop
121 | leftDrive.setPower(0);
122 | rightDrive.setPower(0);
123 |
124 | telemetry.addData("Path", "Complete");
125 | telemetry.update();
126 | sleep(1000);
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotAutoDriveToLine_Linear.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2017 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
33 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
34 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
35 | import com.qualcomm.robotcore.hardware.DcMotor;
36 | import com.qualcomm.robotcore.hardware.NormalizedColorSensor;
37 | import com.qualcomm.robotcore.hardware.NormalizedRGBA;
38 | import com.qualcomm.robotcore.hardware.SwitchableLight;
39 |
40 | /*
41 | * This OpMode illustrates the concept of driving up to a line and then stopping.
42 | * The code is structured as a LinearOpMode
43 | *
44 | * The Sensor used here can be a REV Color Sensor V2 or V3. Make sure the white LED is turned on.
45 | * The sensor can be plugged into any I2C port, and must be named "sensor_color" in the active configuration.
46 | *
47 | * Depending on the height of your color sensor, you may want to set the sensor "gain".
48 | * The higher the gain, the greater the reflected light reading will be.
49 | * Use the SensorColor sample in this folder to determine the minimum gain value that provides an
50 | * "Alpha" reading of 1.0 when you are on top of the white line. In this sample, we use a gain of 15
51 | * which works well with a Rev V2 color sensor
52 | *
53 | * Setting the correct WHITE_THRESHOLD value is key to stopping correctly.
54 | * This should be set halfway between the bare-tile, and white-line "Alpha" values.
55 | * The reflected light value can be read on the screen once the OpMode has been INIT, but before it is STARTED.
56 | * Move the sensor on and off the white line and note the min and max readings.
57 | * Edit this code to make WHITE_THRESHOLD halfway between the min and max.
58 | *
59 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
60 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
61 | */
62 |
63 | @Autonomous(name="Robot: Auto Drive To Line", group="Robot")
64 | @Disabled
65 | public class RobotAutoDriveToLine_Linear extends LinearOpMode {
66 |
67 | /* Declare OpMode members. */
68 | private DcMotor leftDrive = null;
69 | private DcMotor rightDrive = null;
70 |
71 | /** The variable to store a reference to our color sensor hardware object */
72 | NormalizedColorSensor colorSensor;
73 |
74 | static final double WHITE_THRESHOLD = 0.5; // spans between 0.0 - 1.0 from dark to light
75 | static final double APPROACH_SPEED = 0.25;
76 |
77 | @Override
78 | public void runOpMode() {
79 |
80 | // Initialize the drive system variables.
81 | leftDrive = hardwareMap.get(DcMotor.class, "left_drive");
82 | rightDrive = hardwareMap.get(DcMotor.class, "right_drive");
83 |
84 | // To drive forward, most robots need the motor on one side to be reversed, because the axles point in opposite directions.
85 | // When run, this OpMode should start both motors driving forward. So adjust these two lines based on your first test drive.
86 | // Note: The settings here assume direct drive on left and right wheels. Gear Reduction or 90 Deg drives may require direction flips
87 | leftDrive.setDirection(DcMotor.Direction.REVERSE);
88 | rightDrive.setDirection(DcMotor.Direction.FORWARD);
89 |
90 | // If there are encoders connected, switch to RUN_USING_ENCODER mode for greater accuracy
91 | // leftDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
92 | // rightDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
93 |
94 | // Get a reference to our sensor object. It's recommended to use NormalizedColorSensor over
95 | // ColorSensor, because NormalizedColorSensor consistently gives values between 0 and 1, while
96 | // the values you get from ColorSensor are dependent on the specific sensor you're using.
97 | colorSensor = hardwareMap.get(NormalizedColorSensor.class, "sensor_color");
98 |
99 | // If necessary, turn ON the white LED (if there is no LED switch on the sensor)
100 | if (colorSensor instanceof SwitchableLight) {
101 | ((SwitchableLight)colorSensor).enableLight(true);
102 | }
103 |
104 | // Some sensors allow you to set your light sensor gain for optimal sensitivity...
105 | // See the SensorColor sample in this folder for how to determine the optimal gain.
106 | // A gain of 15 causes a Rev Color Sensor V2 to produce an Alpha value of 1.0 at about 1.5" above the floor.
107 | colorSensor.setGain(15);
108 |
109 | // Wait for driver to press START)
110 | // Abort this loop is started or stopped.
111 | while (opModeInInit()) {
112 |
113 | // Send telemetry message to signify robot waiting;
114 | telemetry.addData("Status", "Ready to drive to white line."); //
115 |
116 | // Display the light level while we are waiting to start
117 | getBrightness();
118 | }
119 |
120 | // Start the robot moving forward, and then begin looking for a white line.
121 | leftDrive.setPower(APPROACH_SPEED);
122 | rightDrive.setPower(APPROACH_SPEED);
123 |
124 | // run until the white line is seen OR the driver presses STOP;
125 | while (opModeIsActive() && (getBrightness() < WHITE_THRESHOLD)) {
126 | sleep(5);
127 | }
128 |
129 | // Stop all motors
130 | leftDrive.setPower(0);
131 | rightDrive.setPower(0);
132 | }
133 |
134 | // to obtain reflected light, read the normalized values from the color sensor. Return the Alpha channel.
135 | double getBrightness() {
136 | NormalizedRGBA colors = colorSensor.getNormalizedColors();
137 | telemetry.addData("Light Level (0 to 1)", "%4.2f", colors.alpha);
138 | telemetry.update();
139 |
140 | return colors.alpha;
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/RobotTeleopTank_Iterative.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2017 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
33 | import com.qualcomm.robotcore.eventloop.opmode.OpMode;
34 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
35 | import com.qualcomm.robotcore.hardware.DcMotor;
36 | import com.qualcomm.robotcore.hardware.Servo;
37 | import com.qualcomm.robotcore.util.Range;
38 |
39 | /*
40 | * This OpMode executes a Tank Drive control TeleOp a direct drive robot
41 | * The code is structured as an Iterative OpMode
42 | *
43 | * In this mode, the left and right joysticks control the left and right motors respectively.
44 | * Pushing a joystick forward will make the attached motor drive forward.
45 | * It raises and lowers the claw using the Gamepad Y and A buttons respectively.
46 | * It also opens and closes the claws slowly using the left and right Bumper buttons.
47 | *
48 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
49 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
50 | */
51 |
52 | @TeleOp(name="Robot: Teleop Tank", group="Robot")
53 | @Disabled
54 | public class RobotTeleopTank_Iterative extends OpMode{
55 |
56 | /* Declare OpMode members. */
57 | public DcMotor leftDrive = null;
58 | public DcMotor rightDrive = null;
59 | public DcMotor leftArm = null;
60 | public Servo leftClaw = null;
61 | public Servo rightClaw = null;
62 |
63 | double clawOffset = 0;
64 |
65 | public static final double MID_SERVO = 0.5 ;
66 | public static final double CLAW_SPEED = 0.02 ; // sets rate to move servo
67 | public static final double ARM_UP_POWER = 0.50 ; // Run arm motor up at 50% power
68 | public static final double ARM_DOWN_POWER = -0.25 ; // Run arm motor down at -25% power
69 |
70 | /*
71 | * Code to run ONCE when the driver hits INIT
72 | */
73 | @Override
74 | public void init() {
75 | // Define and Initialize Motors
76 | leftDrive = hardwareMap.get(DcMotor.class, "left_drive");
77 | rightDrive = hardwareMap.get(DcMotor.class, "right_drive");
78 | leftArm = hardwareMap.get(DcMotor.class, "left_arm");
79 |
80 | // To drive forward, most robots need the motor on one side to be reversed, because the axles point in opposite directions.
81 | // Pushing the left and right sticks forward MUST make robot go forward. So adjust these two lines based on your first test drive.
82 | // Note: The settings here assume direct drive on left and right wheels. Gear Reduction or 90 Deg drives may require direction flips
83 | leftDrive.setDirection(DcMotor.Direction.REVERSE);
84 | rightDrive.setDirection(DcMotor.Direction.FORWARD);
85 |
86 | // If there are encoders connected, switch to RUN_USING_ENCODER mode for greater accuracy
87 | // leftDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
88 | // rightDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
89 |
90 | // Define and initialize ALL installed servos.
91 | leftClaw = hardwareMap.get(Servo.class, "left_hand");
92 | rightClaw = hardwareMap.get(Servo.class, "right_hand");
93 | leftClaw.setPosition(MID_SERVO);
94 | rightClaw.setPosition(MID_SERVO);
95 |
96 | // Send telemetry message to signify robot waiting;
97 | telemetry.addData(">", "Robot Ready. Press START."); //
98 | }
99 |
100 | /*
101 | * Code to run REPEATEDLY after the driver hits INIT, but before they hit START
102 | */
103 | @Override
104 | public void init_loop() {
105 | }
106 |
107 | /*
108 | * Code to run ONCE when the driver hits START
109 | */
110 | @Override
111 | public void start() {
112 | }
113 |
114 | /*
115 | * Code to run REPEATEDLY after the driver hits START but before they hit STOP
116 | */
117 | @Override
118 | public void loop() {
119 | double left;
120 | double right;
121 |
122 | // Run wheels in tank mode (note: The joystick goes negative when pushed forward, so negate it)
123 | left = -gamepad1.left_stick_y;
124 | right = -gamepad1.right_stick_y;
125 |
126 | leftDrive.setPower(left);
127 | rightDrive.setPower(right);
128 |
129 | // Use gamepad left & right Bumpers to open and close the claw
130 | if (gamepad1.right_bumper)
131 | clawOffset += CLAW_SPEED;
132 | else if (gamepad1.left_bumper)
133 | clawOffset -= CLAW_SPEED;
134 |
135 | // Move both servos to new position. Assume servos are mirror image of each other.
136 | clawOffset = Range.clip(clawOffset, -0.5, 0.5);
137 | leftClaw.setPosition(MID_SERVO + clawOffset);
138 | rightClaw.setPosition(MID_SERVO - clawOffset);
139 |
140 | // Use gamepad buttons to move the arm up (Y) and down (A)
141 | if (gamepad1.y)
142 | leftArm.setPower(ARM_UP_POWER);
143 | else if (gamepad1.a)
144 | leftArm.setPower(ARM_DOWN_POWER);
145 | else
146 | leftArm.setPower(0.0);
147 |
148 | // Send telemetry message to signify robot running;
149 | telemetry.addData("claw", "Offset = %.2f", clawOffset);
150 | telemetry.addData("left", "%.2f", left);
151 | telemetry.addData("right", "%.2f", right);
152 | }
153 |
154 | /*
155 | * Code to run ONCE after the driver hits STOP
156 | */
157 | @Override
158 | public void stop() {
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SampleRevBlinkinLedDriver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 Craig MacFarlane
3 | *
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without modification, are permitted
7 | * (subject to the limitations in the disclaimer below) provided that the following conditions are
8 | * met:
9 | *
10 | * Redistributions of source code must retain the above copyright notice, this list of conditions
11 | * and the following disclaimer.
12 | *
13 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
14 | * and the following disclaimer in the documentation and/or other materials provided with the
15 | * distribution.
16 | *
17 | * Neither the name of Craig MacFarlane nor the names of its contributors may be used to
18 | * endorse or promote products derived from this software without specific prior written permission.
19 | *
20 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS
21 | * SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | */
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.hardware.rev.RevBlinkinLedDriver;
33 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
34 | import com.qualcomm.robotcore.eventloop.opmode.OpMode;
35 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
36 | import org.firstinspires.ftc.robotcore.external.Telemetry;
37 | import org.firstinspires.ftc.robotcore.internal.system.Deadline;
38 |
39 | import java.util.concurrent.TimeUnit;
40 |
41 | /*
42 | * This OpMode demonstrates use of the REV Robotics Blinkin LED Driver.
43 | * AUTO mode cycles through all of the patterns.
44 | * MANUAL mode allows the user to manually change patterns using the
45 | * left and right bumpers of a gamepad.
46 | *
47 | * Configure the driver on a servo port, and name it "blinkin".
48 | *
49 | * Displays the first pattern upon init.
50 | */
51 | @TeleOp(name="BlinkinExample")
52 | @Disabled
53 | public class SampleRevBlinkinLedDriver extends OpMode {
54 |
55 | /*
56 | * Change the pattern every 10 seconds in AUTO mode.
57 | */
58 | private final static int LED_PERIOD = 10;
59 |
60 | /*
61 | * Rate limit gamepad button presses to every 500ms.
62 | */
63 | private final static int GAMEPAD_LOCKOUT = 500;
64 |
65 | RevBlinkinLedDriver blinkinLedDriver;
66 | RevBlinkinLedDriver.BlinkinPattern pattern;
67 |
68 | Telemetry.Item patternName;
69 | Telemetry.Item display;
70 | DisplayKind displayKind;
71 | Deadline ledCycleDeadline;
72 | Deadline gamepadRateLimit;
73 |
74 | protected enum DisplayKind {
75 | MANUAL,
76 | AUTO
77 | }
78 |
79 | @Override
80 | public void init()
81 | {
82 | displayKind = DisplayKind.AUTO;
83 |
84 | blinkinLedDriver = hardwareMap.get(RevBlinkinLedDriver.class, "blinkin");
85 | pattern = RevBlinkinLedDriver.BlinkinPattern.RAINBOW_RAINBOW_PALETTE;
86 | blinkinLedDriver.setPattern(pattern);
87 |
88 | display = telemetry.addData("Display Kind: ", displayKind.toString());
89 | patternName = telemetry.addData("Pattern: ", pattern.toString());
90 |
91 | ledCycleDeadline = new Deadline(LED_PERIOD, TimeUnit.SECONDS);
92 | gamepadRateLimit = new Deadline(GAMEPAD_LOCKOUT, TimeUnit.MILLISECONDS);
93 | }
94 |
95 | @Override
96 | public void loop()
97 | {
98 | handleGamepad();
99 |
100 | if (displayKind == DisplayKind.AUTO) {
101 | doAutoDisplay();
102 | } else {
103 | /*
104 | * MANUAL mode: Nothing to do, setting the pattern as a result of a gamepad event.
105 | */
106 | }
107 | }
108 |
109 | /*
110 | * handleGamepad
111 | *
112 | * Responds to a gamepad button press. Demonstrates rate limiting for
113 | * button presses. If loop() is called every 10ms and and you don't rate
114 | * limit, then any given button press may register as multiple button presses,
115 | * which in this application is problematic.
116 | *
117 | * A: Manual mode, Right bumper displays the next pattern, left bumper displays the previous pattern.
118 | * B: Auto mode, pattern cycles, changing every LED_PERIOD seconds.
119 | */
120 | protected void handleGamepad()
121 | {
122 | if (!gamepadRateLimit.hasExpired()) {
123 | return;
124 | }
125 |
126 | if (gamepad1.a) {
127 | setDisplayKind(DisplayKind.MANUAL);
128 | gamepadRateLimit.reset();
129 | } else if (gamepad1.b) {
130 | setDisplayKind(DisplayKind.AUTO);
131 | gamepadRateLimit.reset();
132 | } else if ((displayKind == DisplayKind.MANUAL) && (gamepad1.left_bumper)) {
133 | pattern = pattern.previous();
134 | displayPattern();
135 | gamepadRateLimit.reset();
136 | } else if ((displayKind == DisplayKind.MANUAL) && (gamepad1.right_bumper)) {
137 | pattern = pattern.next();
138 | displayPattern();
139 | gamepadRateLimit.reset();
140 | }
141 | }
142 |
143 | protected void setDisplayKind(DisplayKind displayKind)
144 | {
145 | this.displayKind = displayKind;
146 | display.setValue(displayKind.toString());
147 | }
148 |
149 | protected void doAutoDisplay()
150 | {
151 | if (ledCycleDeadline.hasExpired()) {
152 | pattern = pattern.next();
153 | displayPattern();
154 | ledCycleDeadline.reset();
155 | }
156 | }
157 |
158 | protected void displayPattern()
159 | {
160 | blinkinLedDriver.setPattern(pattern);
161 | patternName.setValue(pattern.toString());
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorDigitalTouch.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2024 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
33 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
34 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
35 | import com.qualcomm.robotcore.hardware.DigitalChannel;
36 |
37 | /*
38 | * This OpMode demonstrates how to use a digital channel.
39 | *
40 | * The OpMode assumes that the digital channel is configured with a name of "digitalTouch".
41 | *
42 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
43 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list.
44 | */
45 | @TeleOp(name = "Sensor: digital channel", group = "Sensor")
46 | @Disabled
47 | public class SensorDigitalTouch extends LinearOpMode {
48 | DigitalChannel digitalTouch; // Digital channel Object
49 |
50 | @Override
51 | public void runOpMode() {
52 |
53 | // get a reference to our touchSensor object.
54 | digitalTouch = hardwareMap.get(DigitalChannel.class, "digitalTouch");
55 |
56 | digitalTouch.setMode(DigitalChannel.Mode.INPUT);
57 | telemetry.addData("DigitalTouchSensorExample", "Press start to continue...");
58 | telemetry.update();
59 |
60 | // wait for the start button to be pressed.
61 | waitForStart();
62 |
63 | // while the OpMode is active, loop and read the digital channel.
64 | // Note we use opModeIsActive() as our loop condition because it is an interruptible method.
65 | while (opModeIsActive()) {
66 |
67 | // button is pressed if value returned is LOW or false.
68 | // send the info back to driver station using telemetry function.
69 | if (digitalTouch.getState() == false) {
70 | telemetry.addData("Button", "PRESSED");
71 | } else {
72 | telemetry.addData("Button", "NOT PRESSED");
73 | }
74 |
75 | telemetry.update();
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorKLNavxMicro.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2017 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.hardware.kauailabs.NavxMicroNavigationSensor;
33 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
34 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
35 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
36 | import com.qualcomm.robotcore.hardware.Gyroscope;
37 | import com.qualcomm.robotcore.hardware.IntegratingGyroscope;
38 | import com.qualcomm.robotcore.util.ElapsedTime;
39 | import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit;
40 | import org.firstinspires.ftc.robotcore.external.navigation.AngularVelocity;
41 | import org.firstinspires.ftc.robotcore.external.navigation.AxesOrder;
42 | import org.firstinspires.ftc.robotcore.external.navigation.AxesReference;
43 | import org.firstinspires.ftc.robotcore.external.navigation.Orientation;
44 |
45 | /*
46 | * This OpMode shows how to use Kauai Labs navX Micro Robotics Navigation
47 | * Sensor. It assumes that the sensor is configured with a name of "navx".
48 | *
49 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
50 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
51 | */
52 | @TeleOp(name = "Sensor: KL navX Micro", group = "Sensor")
53 | @Disabled
54 | public class SensorKLNavxMicro extends LinearOpMode {
55 |
56 | /** In this sample, for illustration purposes we use two interfaces on the one gyro object.
57 | * That's likely atypical: you'll probably use one or the other in any given situation,
58 | * depending on what you're trying to do. {@link IntegratingGyroscope} (and it's base interface,
59 | * {@link Gyroscope}) are common interfaces supported by possibly several different gyro
60 | * implementations. {@link NavxMicroNavigationSensor}, by contrast, provides functionality that
61 | * is unique to the navX Micro sensor.
62 | */
63 | IntegratingGyroscope gyro;
64 | NavxMicroNavigationSensor navxMicro;
65 |
66 | // A timer helps provide feedback while calibration is taking place
67 | ElapsedTime timer = new ElapsedTime();
68 |
69 | @Override public void runOpMode() throws InterruptedException {
70 | // Get a reference to a Modern Robotics GyroSensor object. We use several interfaces
71 | // on this object to illustrate which interfaces support which functionality.
72 | navxMicro = hardwareMap.get(NavxMicroNavigationSensor.class, "navx");
73 | gyro = (IntegratingGyroscope)navxMicro;
74 | // If you're only interested int the IntegratingGyroscope interface, the following will suffice.
75 | // gyro = hardwareMap.get(IntegratingGyroscope.class, "navx");
76 |
77 | // The gyro automatically starts calibrating. This takes a few seconds.
78 | telemetry.log().add("Gyro Calibrating. Do Not Move!");
79 |
80 | // Wait until the gyro calibration is complete
81 | timer.reset();
82 | while (navxMicro.isCalibrating()) {
83 | telemetry.addData("calibrating", "%s", Math.round(timer.seconds())%2==0 ? "|.." : "..|");
84 | telemetry.update();
85 | Thread.sleep(50);
86 | }
87 | telemetry.log().clear(); telemetry.log().add("Gyro Calibrated. Press Start.");
88 | telemetry.clear(); telemetry.update();
89 |
90 | // Wait for the start button to be pressed
91 | waitForStart();
92 | telemetry.log().clear();
93 |
94 | while (opModeIsActive()) {
95 |
96 | // Read dimensionalized data from the gyro. This gyro can report angular velocities
97 | // about all three axes. Additionally, it internally integrates the Z axis to
98 | // be able to report an absolute angular Z orientation.
99 | AngularVelocity rates = gyro.getAngularVelocity(AngleUnit.DEGREES);
100 | Orientation angles = gyro.getAngularOrientation(AxesReference.INTRINSIC, AxesOrder.ZYX, AngleUnit.DEGREES);
101 |
102 | telemetry.addLine()
103 | .addData("dx", formatRate(rates.xRotationRate))
104 | .addData("dy", formatRate(rates.yRotationRate))
105 | .addData("dz", "%s deg/s", formatRate(rates.zRotationRate));
106 |
107 | telemetry.addLine()
108 | .addData("heading", formatAngle(angles.angleUnit, angles.firstAngle))
109 | .addData("roll", formatAngle(angles.angleUnit, angles.secondAngle))
110 | .addData("pitch", "%s deg", formatAngle(angles.angleUnit, angles.thirdAngle));
111 | telemetry.update();
112 |
113 | idle(); // Always call idle() at the bottom of your while(opModeIsActive()) loop
114 | }
115 | }
116 |
117 | String formatRate(float rate) {
118 | return String.format("%.3f", rate);
119 | }
120 |
121 | String formatAngle(AngleUnit angleUnit, double angle) {
122 | return formatDegrees(AngleUnit.DEGREES.fromUnit(angleUnit, angle));
123 | }
124 |
125 | String formatDegrees(double degrees){
126 | return String.format("%.1f", AngleUnit.DEGREES.normalize(degrees));
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRColor.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2017 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import android.app.Activity;
33 | import android.graphics.Color;
34 | import android.view.View;
35 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
36 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
37 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
38 | import com.qualcomm.robotcore.hardware.ColorSensor;
39 |
40 | /*
41 | *
42 | * This OpMode that shows how to use
43 | * a Modern Robotics Color Sensor.
44 | *
45 | * The OpMode assumes that the color sensor
46 | * is configured with a name of "sensor_color".
47 | *
48 | * You can use the X button on gamepad1 to toggle the LED on and off.
49 | *
50 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
51 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
52 | */
53 | @TeleOp(name = "Sensor: MR Color", group = "Sensor")
54 | @Disabled
55 | public class SensorMRColor extends LinearOpMode {
56 |
57 | ColorSensor colorSensor; // Hardware Device Object
58 |
59 |
60 | @Override
61 | public void runOpMode() {
62 |
63 | // hsvValues is an array that will hold the hue, saturation, and value information.
64 | float hsvValues[] = {0F,0F,0F};
65 |
66 | // values is a reference to the hsvValues array.
67 | final float values[] = hsvValues;
68 |
69 | // get a reference to the RelativeLayout so we can change the background
70 | // color of the Robot Controller app to match the hue detected by the RGB sensor.
71 | int relativeLayoutId = hardwareMap.appContext.getResources().getIdentifier("RelativeLayout", "id", hardwareMap.appContext.getPackageName());
72 | final View relativeLayout = ((Activity) hardwareMap.appContext).findViewById(relativeLayoutId);
73 |
74 | // bPrevState and bCurrState represent the previous and current state of the button.
75 | boolean bPrevState = false;
76 | boolean bCurrState = false;
77 |
78 | // bLedOn represents the state of the LED.
79 | boolean bLedOn = true;
80 |
81 | // get a reference to our ColorSensor object.
82 | colorSensor = hardwareMap.get(ColorSensor.class, "sensor_color");
83 |
84 | // Set the LED in the beginning
85 | colorSensor.enableLed(bLedOn);
86 |
87 | // wait for the start button to be pressed.
88 | waitForStart();
89 |
90 | // while the OpMode is active, loop and read the RGB data.
91 | // Note we use opModeIsActive() as our loop condition because it is an interruptible method.
92 | while (opModeIsActive()) {
93 |
94 | // check the status of the x button on either gamepad.
95 | bCurrState = gamepad1.x;
96 |
97 | // check for button state transitions.
98 | if (bCurrState && (bCurrState != bPrevState)) {
99 |
100 | // button is transitioning to a pressed state. So Toggle LED
101 | bLedOn = !bLedOn;
102 | colorSensor.enableLed(bLedOn);
103 | }
104 |
105 | // update previous state variable.
106 | bPrevState = bCurrState;
107 |
108 | // convert the RGB values to HSV values.
109 | Color.RGBToHSV(colorSensor.red() * 8, colorSensor.green() * 8, colorSensor.blue() * 8, hsvValues);
110 |
111 | // send the info back to driver station using telemetry function.
112 | telemetry.addData("LED", bLedOn ? "On" : "Off");
113 | telemetry.addData("Clear", colorSensor.alpha());
114 | telemetry.addData("Red ", colorSensor.red());
115 | telemetry.addData("Green", colorSensor.green());
116 | telemetry.addData("Blue ", colorSensor.blue());
117 | telemetry.addData("Hue", hsvValues[0]);
118 |
119 | // change the background color to match the color detected by the RGB sensor.
120 | // pass a reference to the hue, saturation, and value array as an argument
121 | // to the HSVToColor method.
122 | relativeLayout.post(new Runnable() {
123 | public void run() {
124 | relativeLayout.setBackgroundColor(Color.HSVToColor(0xff, values));
125 | }
126 | });
127 |
128 | telemetry.update();
129 | }
130 |
131 | // Set the panel back to the default color
132 | relativeLayout.post(new Runnable() {
133 | public void run() {
134 | relativeLayout.setBackgroundColor(Color.WHITE);
135 | }
136 | });
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMROpticalDistance.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2017 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
33 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
34 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
35 | import com.qualcomm.robotcore.hardware.OpticalDistanceSensor;
36 |
37 | /*
38 | * This OpMode shows how to use a Modern Robotics Optical Distance Sensor
39 | * It assumes that the ODS sensor is configured with a name of "sensor_ods".
40 | *
41 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
42 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
43 | */
44 | @TeleOp(name = "Sensor: MR ODS", group = "Sensor")
45 | @Disabled
46 | public class SensorMROpticalDistance extends LinearOpMode {
47 |
48 | OpticalDistanceSensor odsSensor; // Hardware Device Object
49 |
50 | @Override
51 | public void runOpMode() {
52 |
53 | // get a reference to our Light Sensor object.
54 | odsSensor = hardwareMap.get(OpticalDistanceSensor.class, "sensor_ods");
55 |
56 | // wait for the start button to be pressed.
57 | waitForStart();
58 |
59 | // while the OpMode is active, loop and read the light levels.
60 | // Note we use opModeIsActive() as our loop condition because it is an interruptible method.
61 | while (opModeIsActive()) {
62 |
63 | // send the info back to driver station using telemetry function.
64 | telemetry.addData("Raw", odsSensor.getRawLightDetected());
65 | telemetry.addData("Normal", odsSensor.getLightDetected());
66 |
67 | telemetry.update();
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRRangeSensor.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2017 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.hardware.modernrobotics.ModernRoboticsI2cRangeSensor;
33 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
34 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
35 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
36 | import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
37 |
38 | /*
39 | * This OpMode illustrates how to use the Modern Robotics Range Sensor.
40 | *
41 | * The OpMode assumes that the range sensor is configured with a name of "sensor_range".
42 | *
43 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
44 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
45 | *
46 | * @see MR Range Sensor
47 | */
48 | @TeleOp(name = "Sensor: MR range sensor", group = "Sensor")
49 | @Disabled // comment out or remove this line to enable this OpMode
50 | public class SensorMRRangeSensor extends LinearOpMode {
51 |
52 | ModernRoboticsI2cRangeSensor rangeSensor;
53 |
54 | @Override public void runOpMode() {
55 |
56 | // get a reference to our compass
57 | rangeSensor = hardwareMap.get(ModernRoboticsI2cRangeSensor.class, "sensor_range");
58 |
59 | // wait for the start button to be pressed
60 | waitForStart();
61 |
62 | while (opModeIsActive()) {
63 | telemetry.addData("raw ultrasonic", rangeSensor.rawUltrasonic());
64 | telemetry.addData("raw optical", rangeSensor.rawOptical());
65 | telemetry.addData("cm optical", "%.2f cm", rangeSensor.cmOptical());
66 | telemetry.addData("cm", "%.2f cm", rangeSensor.getDistance(DistanceUnit.CM));
67 | telemetry.update();
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorOctoQuad.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024 DigitalChickenLabs
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | * SOFTWARE.
20 | */
21 |
22 | package org.firstinspires.ftc.robotcontroller.external.samples;
23 |
24 | import com.qualcomm.hardware.digitalchickenlabs.OctoQuad;
25 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
26 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
27 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
28 | import org.firstinspires.ftc.robotcore.external.Telemetry;
29 |
30 | /*
31 | * This OpMode illustrates how to use the DigitalChickenLabs OctoQuad Quadrature Encoder & Pulse Width Interface Module
32 | *
33 | * The OctoQuad has 8 input channels that can used to read either Relative Quadrature Encoders or Pulse-Width Absolute Encoder inputs.
34 | * Relative Quadrature encoders are found on most FTC motors, and some stand-alone position sensors like the REV Thru-Bore encoder.
35 | * Pulse-Width encoders are less common. The REV Thru-Bore encoder can provide its absolute position via a variable pulse width,
36 | * as can several sonar rangefinders such as the MaxBotix MB1000 series.
37 | *
38 | * This basic sample shows how an OctoQuad can be used to read the position three Odometry pods fitted
39 | * with REV Thru-Bore encoders. For a more advanced example showing additional OctoQuad capabilities, see the SensorOctoQuadAdv sample.
40 | *
41 | * This OpMode assumes that the OctoQuad is attached to an I2C interface named "octoquad" in the robot configuration.
42 | *
43 | * The code assumes the first three OctoQuad inputs are connected as follows
44 | * - Chan 0: for measuring forward motion on the left side of the robot.
45 | * - Chan 1: for measuring forward motion on the right side of the robot.
46 | * - Chan 2: for measuring Lateral (strafing) motion.
47 | *
48 | * The encoder values may be reset to zero by pressing the X (left most) button on Gamepad 1.
49 | *
50 | * This sample does not show how to interpret these readings, just how to obtain and display them.
51 | *
52 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
53 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
54 | *
55 | * See the sensor's product page: https://www.tindie.com/products/35114/
56 | */
57 | @TeleOp(name = "OctoQuad Basic", group="OctoQuad")
58 | @Disabled
59 | public class SensorOctoQuad extends LinearOpMode {
60 |
61 | // Identify which encoder OctoQuad inputs are connected to each odometry pod.
62 | private final int ODO_LEFT = 0; // Facing forward direction on left side of robot (Axial motion)
63 | private final int ODO_RIGHT = 1; // Facing forward direction on right side or robot (Axial motion)
64 | private final int ODO_PERP = 2; // Facing perpendicular direction at the center of the robot (Lateral motion)
65 |
66 | // Declare the OctoQuad object and members to store encoder positions and velocities
67 | private OctoQuad octoquad;
68 |
69 | private int posLeft;
70 | private int posRight;
71 | private int posPerp;
72 |
73 | /**
74 | * This function is executed when this OpMode is selected from the Driver Station.
75 | */
76 | @Override
77 | public void runOpMode() {
78 |
79 | // Connect to OctoQuad by referring to its name in the Robot Configuration.
80 | octoquad = hardwareMap.get(OctoQuad.class, "octoquad");
81 |
82 | // Read the Firmware Revision number from the OctoQuad and display it as telemetry.
83 | telemetry.addData("OctoQuad Firmware Version ", octoquad.getFirmwareVersion());
84 |
85 | // Reverse the count-direction of any encoder that is not what you require.
86 | // e.g. if you push the robot forward and the left encoder counts down, then reverse it so it counts up.
87 | octoquad.setSingleEncoderDirection(ODO_LEFT, OctoQuad.EncoderDirection.REVERSE);
88 | octoquad.setSingleEncoderDirection(ODO_RIGHT, OctoQuad.EncoderDirection.FORWARD);
89 | octoquad.setSingleEncoderDirection(ODO_PERP, OctoQuad.EncoderDirection.FORWARD);
90 |
91 | // Any changes that are made should be saved in FLASH just in case there is a sensor power glitch.
92 | octoquad.saveParametersToFlash();
93 |
94 | telemetry.addLine("\nPress START to read encoder values");
95 | telemetry.update();
96 |
97 | waitForStart();
98 |
99 | // Configure the telemetry for optimal display of data.
100 | telemetry.setDisplayFormat(Telemetry.DisplayFormat.MONOSPACE);
101 | telemetry.setMsTransmissionInterval(50);
102 |
103 | // Set all the encoder inputs to zero.
104 | octoquad.resetAllPositions();
105 |
106 | // Loop while displaying the odometry pod positions.
107 | while (opModeIsActive()) {
108 | telemetry.addData(">", "Press X to Reset Encoders\n");
109 |
110 | // Check for X button to reset encoders.
111 | if (gamepad1.x) {
112 | // Reset the position of all encoders to zero.
113 | octoquad.resetAllPositions();
114 | }
115 |
116 | // Read all the encoder data. Load into local members.
117 | readOdometryPods();
118 |
119 | // Display the values.
120 | telemetry.addData("Left ", "%8d counts", posLeft);
121 | telemetry.addData("Right", "%8d counts", posRight);
122 | telemetry.addData("Perp ", "%8d counts", posPerp);
123 | telemetry.update();
124 | }
125 | }
126 |
127 | private void readOdometryPods() {
128 | // For best performance, we should only perform ONE transaction with the OctoQuad each cycle.
129 | // Since this example only needs to read positions from a few channels, we could use either
130 | // readPositionRange(idxFirst, idxLast) to get a select number of sequential channels
131 | // or
132 | // readAllPositions() to get all 8 encoder readings
133 | //
134 | // Since both calls take almost the same amount of time, and the actual channels may not end up
135 | // being sequential, we will read all of the encoder positions, and then pick out the ones we need.
136 | int[] positions = octoquad.readAllPositions();
137 | posLeft = positions[ODO_LEFT];
138 | posRight = positions[ODO_RIGHT];
139 | posPerp = positions[ODO_PERP];
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorREV2mDistance.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2018 FIRST
3 |
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without modification,
7 | are permitted (subject to the limitations in the disclaimer below) provided that
8 | the following conditions are met:
9 |
10 | Redistributions of source code must retain the above copyright notice, this list
11 | of conditions and the following disclaimer.
12 |
13 | Redistributions in binary form must reproduce the above copyright notice, this
14 | list of conditions and the following disclaimer in the documentation and/or
15 | other materials provided with the distribution.
16 |
17 | Neither the name of FIRST nor the names of its contributors may be used to
18 | endorse or promote products derived from this software without specific prior
19 | written permission.
20 |
21 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
22 | LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
26 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 | */
33 | package org.firstinspires.ftc.robotcontroller.external.samples;
34 |
35 | import com.qualcomm.hardware.rev.Rev2mDistanceSensor;
36 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
37 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
38 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
39 | import com.qualcomm.robotcore.hardware.DistanceSensor;
40 | import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
41 |
42 | /*
43 | * This OpMode illustrates how to use the REV Robotics 2M Distance Sensor.
44 | *
45 | * The OpMode assumes that the sensor is configured with a name of "sensor_distance".
46 | *
47 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
48 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list
49 | *
50 | * See the sensor's product page: https://www.revrobotics.com/rev-31-1505/
51 | */
52 | @TeleOp(name = "Sensor: REV2mDistance", group = "Sensor")
53 | @Disabled
54 | public class SensorREV2mDistance extends LinearOpMode {
55 |
56 | private DistanceSensor sensorDistance;
57 |
58 | @Override
59 | public void runOpMode() {
60 | // you can use this as a regular DistanceSensor.
61 | sensorDistance = hardwareMap.get(DistanceSensor.class, "sensor_distance");
62 |
63 | // you can also cast this to a Rev2mDistanceSensor if you want to use added
64 | // methods associated with the Rev2mDistanceSensor class.
65 | Rev2mDistanceSensor sensorTimeOfFlight = (Rev2mDistanceSensor) sensorDistance;
66 |
67 | telemetry.addData(">>", "Press start to continue");
68 | telemetry.update();
69 |
70 | waitForStart();
71 | while(opModeIsActive()) {
72 | // generic DistanceSensor methods.
73 | telemetry.addData("deviceName", sensorDistance.getDeviceName() );
74 | telemetry.addData("range", String.format("%.01f mm", sensorDistance.getDistance(DistanceUnit.MM)));
75 | telemetry.addData("range", String.format("%.01f cm", sensorDistance.getDistance(DistanceUnit.CM)));
76 | telemetry.addData("range", String.format("%.01f m", sensorDistance.getDistance(DistanceUnit.METER)));
77 | telemetry.addData("range", String.format("%.01f in", sensorDistance.getDistance(DistanceUnit.INCH)));
78 |
79 | // Rev2mDistanceSensor specific methods.
80 | telemetry.addData("ID", String.format("%x", sensorTimeOfFlight.getModelID()));
81 | telemetry.addData("did time out", Boolean.toString(sensorTimeOfFlight.didTimeoutOccur()));
82 |
83 | telemetry.update();
84 | }
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorTouch.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2017 FIRST. All rights reserved.
2 | *
3 | * Redistribution and use in source and binary forms, with or without modification,
4 | * are permitted (subject to the limitations in the disclaimer below) provided that
5 | * the following conditions are met:
6 | *
7 | * Redistributions of source code must retain the above copyright notice, this list
8 | * of conditions and the following disclaimer.
9 | *
10 | * Redistributions in binary form must reproduce the above copyright notice, this
11 | * list of conditions and the following disclaimer in the documentation and/or
12 | * other materials provided with the distribution.
13 | *
14 | * Neither the name of FIRST nor the names of its contributors may be used to endorse or
15 | * promote products derived from this software without specific prior written permission.
16 | *
17 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
18 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | package org.firstinspires.ftc.robotcontroller.external.samples;
31 |
32 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
33 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
34 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
35 | import com.qualcomm.robotcore.hardware.TouchSensor;
36 |
37 | /*
38 | * This OpMode demonstrates how to use a REV Robotics Touch Sensor, REV Robotics Magnetic Limit Switch, or other device
39 | * that implements the TouchSensor interface. Any touch sensor that connects its output to ground when pressed
40 | * (known as "active low") can be configured as a "REV Touch Sensor". This includes REV's Magnetic Limit Switch.
41 | *
42 | * The OpMode assumes that the touch sensor is configured with a name of "sensor_touch".
43 | *
44 | * A REV Robotics Touch Sensor must be configured on digital port number 1, 3, 5, or 7.
45 | * A Magnetic Limit Switch can be configured on any digital port.
46 | *
47 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
48 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list.
49 | */
50 | @TeleOp(name = "Sensor: REV touch sensor", group = "Sensor")
51 | @Disabled
52 | public class SensorTouch extends LinearOpMode {
53 | TouchSensor touchSensor; // Touch sensor Object
54 |
55 | @Override
56 | public void runOpMode() {
57 |
58 | // get a reference to our touchSensor object.
59 | touchSensor = hardwareMap.get(TouchSensor.class, "sensor_touch");
60 |
61 | // wait for the start button to be pressed.
62 | waitForStart();
63 |
64 | // while the OpMode is active, loop and read whether the sensor is being pressed.
65 | // Note we use opModeIsActive() as our loop condition because it is an interruptible method.
66 | while (opModeIsActive()) {
67 |
68 | // send the info back to driver station using telemetry function.
69 | if (touchSensor.isPressed()) {
70 | telemetry.addData("Touch Sensor", "Is Pressed");
71 | } else {
72 | telemetry.addData("Touch Sensor", "Is Not Pressed");
73 | }
74 |
75 | telemetry.update();
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/UtilityCameraFrameCapture.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 FIRST
3 | *
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without modification,
7 | * are permitted (subject to the limitations in the disclaimer below) provided that
8 | * the following conditions are met:
9 | *
10 | * Redistributions of source code must retain the above copyright notice, this list
11 | * of conditions and the following disclaimer.
12 | *
13 | * Redistributions in binary form must reproduce the above copyright notice, this
14 | * list of conditions and the following disclaimer in the documentation and/or
15 | * other materials provided with the distribution.
16 | *
17 | * Neither the name of FIRST nor the names of its contributors may be used to
18 | * endorse or promote products derived from this software without specific prior
19 | * written permission.
20 | *
21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
22 | * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | package org.firstinspires.ftc.robotcontroller.external.samples;
35 |
36 | import android.util.Size;
37 | import com.qualcomm.robotcore.eventloop.opmode.Disabled;
38 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
39 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
40 | import org.firstinspires.ftc.robotcore.external.hardware.camera.BuiltinCameraDirection;
41 | import org.firstinspires.ftc.robotcore.external.hardware.camera.WebcamName;
42 | import org.firstinspires.ftc.vision.VisionPortal;
43 |
44 | import java.util.Locale;
45 |
46 | /*
47 | * This OpMode helps calibrate a webcam or RC phone camera, useful for AprilTag pose estimation
48 | * with the FTC VisionPortal. It captures a camera frame (image) and stores it on the Robot Controller
49 | * (Control Hub or RC phone), with each press of the gamepad button X (or Square).
50 | * Full calibration instructions are here:
51 | *
52 | * https://ftc-docs.firstinspires.org/camera-calibration
53 | *
54 | * In Android Studio, copy this class into your "teamcode" folder with a new name.
55 | * Remove or comment out the @Disabled line to add this OpMode to the Driver Station OpMode list.
56 | *
57 | * In OnBot Java, use "Add File" to add this OpMode from the list of Samples.
58 | */
59 |
60 | @TeleOp(name = "Utility: Camera Frame Capture", group = "Utility")
61 | @Disabled
62 | public class UtilityCameraFrameCapture extends LinearOpMode
63 | {
64 | /*
65 | * EDIT THESE PARAMETERS AS NEEDED
66 | */
67 | final boolean USING_WEBCAM = false;
68 | final BuiltinCameraDirection INTERNAL_CAM_DIR = BuiltinCameraDirection.BACK;
69 | final int RESOLUTION_WIDTH = 640;
70 | final int RESOLUTION_HEIGHT = 480;
71 |
72 | // Internal state
73 | boolean lastX;
74 | int frameCount;
75 | long capReqTime;
76 |
77 | @Override
78 | public void runOpMode()
79 | {
80 | VisionPortal portal;
81 |
82 | if (USING_WEBCAM)
83 | {
84 | portal = new VisionPortal.Builder()
85 | .setCamera(hardwareMap.get(WebcamName.class, "Webcam 1"))
86 | .setCameraResolution(new Size(RESOLUTION_WIDTH, RESOLUTION_HEIGHT))
87 | .build();
88 | }
89 | else
90 | {
91 | portal = new VisionPortal.Builder()
92 | .setCamera(INTERNAL_CAM_DIR)
93 | .setCameraResolution(new Size(RESOLUTION_WIDTH, RESOLUTION_HEIGHT))
94 | .build();
95 | }
96 |
97 | while (!isStopRequested())
98 | {
99 | boolean x = gamepad1.x;
100 |
101 | if (x && !lastX)
102 | {
103 | portal.saveNextFrameRaw(String.format(Locale.US, "CameraFrameCapture-%06d", frameCount++));
104 | capReqTime = System.currentTimeMillis();
105 | }
106 |
107 | lastX = x;
108 |
109 | telemetry.addLine("######## Camera Capture Utility ########");
110 | telemetry.addLine(String.format(Locale.US, " > Resolution: %dx%d", RESOLUTION_WIDTH, RESOLUTION_HEIGHT));
111 | telemetry.addLine(" > Press X (or Square) to capture a frame");
112 | telemetry.addData(" > Camera Status", portal.getCameraState());
113 |
114 | if (capReqTime != 0)
115 | {
116 | telemetry.addLine("\nCaptured Frame!");
117 | }
118 |
119 | if (capReqTime != 0 && System.currentTimeMillis() - capReqTime > 1000)
120 | {
121 | capReqTime = 0;
122 | }
123 |
124 | telemetry.update();
125 | }
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/readme.md:
--------------------------------------------------------------------------------
1 |
2 | ## Caution
3 | No Team-specific code should be placed or modified in this ``.../samples`` folder.
4 |
5 | Samples should be Copied from here, and then Pasted into the team's
6 | [/TeamCode/src/main/java/org/firstinspires/ftc/teamcode](../../../../../../../../../../TeamCode/src/main/java/org/firstinspires/ftc/teamcode)
7 | folder, using the Android Studio cut and paste commands. This automatically changes all file and
8 | class names to be consistent. From there, the sample can be modified to suit the team's needs.
9 |
10 | For more detailed instructions see the /teamcode readme.
11 |
12 | ### Naming of Samples
13 |
14 | To gain a better understanding of how the samples are organized, and how to interpret the
15 | naming system, it will help to understand the conventions that were used during their creation.
16 |
17 | These conventions are described (in detail) in the sample_conventions.md file in this folder.
18 |
19 | To summarize: A range of different samples classes will reside in the java/external/samples.
20 | The class names will follow a naming convention which indicates the purpose of each class.
21 | The prefix of the name will be one of the following:
22 |
23 | Basic: This is a minimally functional OpMode used to illustrate the skeleton/structure
24 | of a particular style of OpMode. These are bare bones examples.
25 |
26 | Sensor: This is a Sample OpMode that shows how to use a specific sensor.
27 | It is not intended to drive a functioning robot, it is simply showing the minimal code
28 | required to read and display the sensor values.
29 |
30 | Robot: This is a Sample OpMode that assumes a simple two-motor (differential) drive base.
31 | It may be used to provide a common baseline driving OpMode, or
32 | to demonstrate how a particular sensor or concept can be used to navigate.
33 |
34 | Concept: This is a sample OpMode that illustrates performing a specific function or concept.
35 | These may be complex, but their operation should be explained clearly in the comments,
36 | or the comments should reference an external doc, guide or tutorial.
37 | Each OpMode should try to only demonstrate a single concept so they are easy to
38 | locate based on their name. These OpModes may not produce a drivable robot.
39 |
40 | After the prefix, other conventions will apply:
41 |
42 | * Sensor class names are constructed as: Sensor - Company - Type
43 | * Robot class names are constructed as: Robot - Mode - Action - OpModetype
44 | * Concept class names are constructed as: Concept - Topic - OpModetype
45 |
46 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/sample_conventions.md:
--------------------------------------------------------------------------------
1 | ## Sample Class/Opmode conventions
2 | #### V 1.1.0 8/9/2017
3 |
4 | This document defines the FTC Sample OpMode and Class conventions.
5 |
6 | ### OpMode Name
7 |
8 | To gain a better understanding of how the samples are organized, and how to interpret the
9 | naming system, it will help to understand the conventions that were used during their creation.
10 |
11 | To summarize: A range of different samples classes will reside in the java/external/samples.
12 | The class names will follow a naming convention which indicates the purpose of each class.
13 | The prefix of the name will be one of the following:
14 |
15 | Basic: This is a minimally functional OpMode used to illustrate the skeleton/structure
16 | of a particular style of OpMode. These are bare bones examples.
17 |
18 | Sensor: This is a Sample OpMode that shows how to use a specific sensor.
19 | It is not intended to drive a functioning robot, it is simply showing the minimal code
20 | required to read and display the sensor values.
21 |
22 | Robot: This is a Sample OpMode that assumes a simple two-motor (differential) drive base.
23 | It may be used to provide a common baseline driving OpMode, or
24 | to demonstrate how a particular sensor or concept can be used to navigate.
25 |
26 | Concept: This is a sample OpMode that illustrates performing a specific function or concept.
27 | These may be complex, but their operation should be explained clearly in the comments,
28 | or the comments should reference an external doc, guide or tutorial.
29 | Each OpMode should try to only demonstrate a single concept so they are easy to
30 | locate based on their name. These OpModes may not produce a drivable robot.
31 |
32 | Utility: This sample type is provided as a useful tool, or aide, to perform some specific development task.
33 | It is not expected to be something you would include in your own robot code.
34 | To use the tool, comment out the @Disabled annotation and build the App.
35 | Read the comments found in the sample for an explanation of its intended use.
36 |
37 | After the prefix, other conventions will apply:
38 |
39 | * Sensor class names should constructed as: Sensor - Company - Type
40 | * Robot class names should be constructed as: Robot - Mode - Action - OpModetype
41 | * Concept class names should be constructed as: Concept - Topic - OpModetype
42 |
43 | ### Sample OpMode Content/Style
44 |
45 | Code is formatted as per the Google Style Guide:
46 |
47 | https://google.github.io/styleguide/javaguide.html
48 |
49 | With “Sensor” and “Hardware” samples, the code should demonstrate the essential function,
50 | and not be embellished with too much additional “clever” code. If a sensor has special
51 | addressing needs, or has a variety of modes or outputs, these should be demonstrated as
52 | simply as possible.
53 |
54 | Special programming methods, or robot control techniques should be reserved for “Concept” Samples,
55 | and where possible, Samples should strive to only demonstrate a single concept,
56 | eg: State machine coding, or a User Menu system, and not combine them into a single “all inclusive”
57 | sample. This will prevent an “all inclusive” Sample being deleted just because one part of it
58 | becomes obsolete.
59 |
60 | ### Device Configuration Names
61 |
62 | The following device names are used in the external samples
63 |
64 | ** Motors:
65 | left_drive
66 | right_drive
67 | left_arm
68 |
69 | ** Servos:
70 | left_hand
71 | right_hand
72 | arm
73 | claw
74 |
75 | ** Sensors:
76 | sensor_color
77 | sensor_ir
78 | sensor_light
79 | sensor_ods
80 | sensor_range
81 | sensor_touch
82 | sensor_color_distance
83 | sensor_digital
84 | digin
85 | digout
86 |
87 | ** Localization:
88 | compass
89 | gyro
90 | imu
91 | navx
92 |
93 | ### Device Object Names
94 |
95 | Device Object names should use the same words as the device’s configuration name, but they
96 | should be re-structured to be a suitable Java variable name. This should keep the same word order,
97 | but adopt the style of beginning with a lower case letter, and then each subsequent word
98 | starting with an upper case letter.
99 |
100 | Eg: from the examples above: tool, leftMotor, rightClawServo, rearLightSensor.
101 |
102 | Note: Sometimes it’s helpful to put the device type first, followed by the variant.
103 | eg: motorLeft and motorRight, but this should only be done if the same word order
104 | is used on the device configuration name.
105 |
106 | ### OpMode code Comments
107 |
108 | Sample comments should read like normal code comments, that is, as an explanation of what the
109 | sample code is doing. They should NOT be directives to the user,
110 | like: “insert your joystick code here” as these comments typically aren’t
111 | detailed enough to be useful. They also often get left in the code and become garbage.
112 |
113 | Instead, an example of the joystick code should be shown with a comment describing what it is doing.
114 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/FtcOpModeRegister.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2014, 2015 Qualcomm Technologies Inc
2 |
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without modification,
6 | are permitted (subject to the limitations in the disclaimer below) provided that
7 | the following conditions are met:
8 |
9 | Redistributions of source code must retain the above copyright notice, this list
10 | of conditions and the following disclaimer.
11 |
12 | Redistributions in binary form must reproduce the above copyright notice, this
13 | list of conditions and the following disclaimer in the documentation and/or
14 | other materials provided with the distribution.
15 |
16 | Neither the name of Qualcomm Technologies Inc nor the names of its contributors
17 | may be used to endorse or promote products derived from this software without
18 | specific prior written permission.
19 |
20 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
21 | LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
31 |
32 | package org.firstinspires.ftc.robotcontroller.internal;
33 |
34 | import com.qualcomm.robotcore.eventloop.opmode.OpModeManager;
35 | import com.qualcomm.robotcore.eventloop.opmode.OpModeRegister;
36 |
37 | /**
38 | * {@link FtcOpModeRegister} is responsible for registering OpModes for use in an FTC game.
39 | * @see #register(OpModeManager)
40 | */
41 | public class FtcOpModeRegister implements OpModeRegister {
42 |
43 | /**
44 | * {@link #register(OpModeManager)} is called by the SDK game in order to register
45 | * OpMode classes or instances that will participate in an FTC game.
46 | *
47 | * There are two mechanisms by which an OpMode may be registered.
48 | *
49 | * 1) The preferred method is by means of class annotations in the OpMode itself.
50 | * See, for example the class annotations in {@link org.firstinspires.ftc.robotcontroller.external.samples.ConceptNullOp}.
51 | *
52 | * 2) The other, retired, method is to modify this {@link #register(OpModeManager)}
53 | * method to include explicit calls to OpModeManager.register().
54 | * This method of modifying this file directly is discouraged, as it
55 | * makes updates to the SDK harder to integrate into your code.
56 | *
57 | * @param manager the object which contains methods for carrying out OpMode registrations
58 | *
59 | * @see com.qualcomm.robotcore.eventloop.opmode.TeleOp
60 | * @see com.qualcomm.robotcore.eventloop.opmode.Autonomous
61 | */
62 | public void register(OpModeManager manager) {
63 |
64 | /**
65 | * Any manual OpMode class registrations should go here.
66 | */
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/PermissionValidatorWrapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 Craig MacFarlane
3 | *
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without modification, are permitted
7 | * (subject to the limitations in the disclaimer below) provided that the following conditions are
8 | * met:
9 | *
10 | * Redistributions of source code must retain the above copyright notice, this list of conditions
11 | * and the following disclaimer.
12 | *
13 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
14 | * and the following disclaimer in the documentation and/or other materials provided with the
15 | * distribution.
16 | *
17 | * Neither the name of Craig MacFarlane nor the names of its contributors may be used to
18 | * endorse or promote products derived from this software without specific prior written permission.
19 | *
20 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS
21 | * SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
26 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | */
30 | package org.firstinspires.ftc.robotcontroller.internal;
31 |
32 | import android.Manifest;
33 | import android.os.Bundle;
34 |
35 | import com.qualcomm.ftcrobotcontroller.R;
36 |
37 | import org.firstinspires.ftc.robotcore.internal.system.Misc;
38 | import org.firstinspires.ftc.robotcore.internal.system.PermissionValidatorActivity;
39 |
40 | import java.util.ArrayList;
41 | import java.util.List;
42 |
43 | public class PermissionValidatorWrapper extends PermissionValidatorActivity {
44 |
45 | private final String TAG = "PermissionValidatorWrapper";
46 |
47 | /*
48 | * The list of dangerous permissions the robot controller needs.
49 | */
50 | protected List robotControllerPermissions = new ArrayList() {{
51 | add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
52 | add(Manifest.permission.READ_EXTERNAL_STORAGE);
53 | add(Manifest.permission.CAMERA);
54 | add(Manifest.permission.ACCESS_COARSE_LOCATION);
55 | add(Manifest.permission.ACCESS_FINE_LOCATION);
56 | add(Manifest.permission.READ_PHONE_STATE);
57 | }};
58 |
59 | private final static Class startApplication = FtcRobotControllerActivity.class;
60 |
61 | public String mapPermissionToExplanation(final String permission) {
62 | if (permission.equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
63 | return Misc.formatForUser(R.string.permRcWriteExternalStorageExplain);
64 | } else if (permission.equals(Manifest.permission.READ_EXTERNAL_STORAGE)) {
65 | return Misc.formatForUser(R.string.permRcReadExternalStorageExplain);
66 | } else if (permission.equals(Manifest.permission.CAMERA)) {
67 | return Misc.formatForUser(R.string.permRcCameraExplain);
68 | } else if (permission.equals(Manifest.permission.ACCESS_COARSE_LOCATION)) {
69 | return Misc.formatForUser(R.string.permAccessLocationExplain);
70 | } else if (permission.equals(Manifest.permission.ACCESS_FINE_LOCATION)) {
71 | return Misc.formatForUser(R.string.permAccessLocationExplain);
72 | } else if (permission.equals(Manifest.permission.READ_PHONE_STATE)) {
73 | return Misc.formatForUser(R.string.permReadPhoneState);
74 | }
75 | return Misc.formatForUser(R.string.permGenericExplain);
76 | }
77 |
78 | @Override
79 | protected void onCreate(Bundle savedInstanceState)
80 | {
81 | super.onCreate(savedInstanceState);
82 |
83 | permissions = robotControllerPermissions;
84 | }
85 |
86 | protected Class onStartApplication()
87 | {
88 | FtcRobotControllerActivity.setPermissionsValidated();
89 | return startApplication;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/res/drawable-xhdpi/icon_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FIRST-Tech-Challenge/FtcRobotController/28d52462d144e6594cb81379872c015c88228f48/FtcRobotController/src/main/res/drawable-xhdpi/icon_menu.png
--------------------------------------------------------------------------------
/FtcRobotController/src/main/res/drawable-xhdpi/icon_robotcontroller.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FIRST-Tech-Challenge/FtcRobotController/28d52462d144e6594cb81379872c015c88228f48/FtcRobotController/src/main/res/drawable-xhdpi/icon_robotcontroller.png
--------------------------------------------------------------------------------
/FtcRobotController/src/main/res/layout/activity_ftc_controller.xml:
--------------------------------------------------------------------------------
1 |
33 |
34 |
43 |
44 |
45 |
50 |
51 |
58 |
59 |
68 |
69 |
82 |
83 |
84 |
85 |
86 |
88 |
89 |
99 |
100 |
106 |
107 |
114 |
115 |
122 |
123 |
128 |
129 |
134 |
135 |
143 |
144 |
145 |
146 |
151 |
158 |
159 |
160 |
161 |
168 |
169 |
176 |
177 |
178 |
179 |
183 |
184 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/res/menu/ftc_robot_controller.xml:
--------------------------------------------------------------------------------
1 |
33 |
34 |
79 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/res/raw/gold.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FIRST-Tech-Challenge/FtcRobotController/28d52462d144e6594cb81379872c015c88228f48/FtcRobotController/src/main/res/raw/gold.wav
--------------------------------------------------------------------------------
/FtcRobotController/src/main/res/raw/silver.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FIRST-Tech-Challenge/FtcRobotController/28d52462d144e6594cb81379872c015c88228f48/FtcRobotController/src/main/res/raw/silver.wav
--------------------------------------------------------------------------------
/FtcRobotController/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
33 |
34 |
35 |
36 |
37 | 16dp
38 | 5dp
39 |
40 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
38 |
39 |
40 |
41 | FTC Robot Controller
42 |
43 |
44 | Self Inspect
45 | Program & Manage
46 | Blocks
47 | Settings
48 | Restart Robot
49 | Configure Robot
50 | About
51 | Exit
52 |
53 |
54 | Configuration Complete
55 | Restarting Robot
56 | The Robot Controller must be fully up and running before entering Program and Manage Mode.
57 |
58 |
59 |
60 | - @style/AppThemeRedRC
61 | - @style/AppThemeGreenRC
62 | - @style/AppThemeBlueRC
63 | - @style/AppThemePurpleRC
64 | - @style/AppThemeOrangeRC
65 | - @style/AppThemeTealRC
66 |
67 |
68 | pref_ftc_season_year_of_current_rc_new
69 |
70 | @string/packageNameRobotController
71 |
72 |
73 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 |
10 |
11 |
13 |
14 |
16 |
17 |
19 |
20 |
22 |
23 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/res/xml/app_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
40 |
41 |
45 |
46 |
48 |
49 |
55 |
56 |
64 |
65 |
71 |
72 |
76 |
80 |
81 |
82 |
86 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/FtcRobotController/src/main/res/xml/device_filter.xml:
--------------------------------------------------------------------------------
1 |
33 |
34 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
45 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014-2022 FIRST. All rights reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without modification,
4 | are permitted (subject to the limitations in the disclaimer below) provided that
5 | the following conditions are met:
6 |
7 | Redistributions of source code must retain the above copyright notice, this list
8 | of conditions and the following disclaimer.
9 |
10 | Redistributions in binary form must reproduce the above copyright notice, this
11 | list of conditions and the following disclaimer in the documentation and/or
12 | other materials provided with the distribution.
13 |
14 | Neither the name of FIRST nor the names of its contributors
15 | may be used to endorse or promote products derived from this software without
16 | specific prior written permission.
17 |
18 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
19 | LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 |
--------------------------------------------------------------------------------
/TeamCode/build.gradle:
--------------------------------------------------------------------------------
1 | //
2 | // build.gradle in TeamCode
3 | //
4 | // Most of the definitions for building your module reside in a common, shared
5 | // file 'build.common.gradle'. Being factored in this way makes it easier to
6 | // integrate updates to the FTC into your code. If you really need to customize
7 | // the build definitions, you can place those customizations in this file, but
8 | // please think carefully as to whether such customizations are really necessary
9 | // before doing so.
10 |
11 |
12 | // Custom definitions may go here
13 |
14 | // Include common definitions from above.
15 | apply from: '../build.common.gradle'
16 | apply from: '../build.dependencies.gradle'
17 |
18 | android {
19 | namespace = 'org.firstinspires.ftc.teamcode'
20 |
21 | packagingOptions {
22 | jniLibs.useLegacyPackaging true
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation project(':FtcRobotController')
28 | }
29 |
--------------------------------------------------------------------------------
/TeamCode/lib/OpModeAnnotationProcessor.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FIRST-Tech-Challenge/FtcRobotController/28d52462d144e6594cb81379872c015c88228f48/TeamCode/lib/OpModeAnnotationProcessor.jar
--------------------------------------------------------------------------------
/TeamCode/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/readme.md:
--------------------------------------------------------------------------------
1 | ## TeamCode Module
2 |
3 | Welcome!
4 |
5 | This module, TeamCode, is the place where you will write/paste the code for your team's
6 | robot controller App. This module is currently empty (a clean slate) but the
7 | process for adding OpModes is straightforward.
8 |
9 | ## Creating your own OpModes
10 |
11 | The easiest way to create your own OpMode is to copy a Sample OpMode and make it your own.
12 |
13 | Sample opmodes exist in the FtcRobotController module.
14 | To locate these samples, find the FtcRobotController module in the "Project/Android" tab.
15 |
16 | Expand the following tree elements:
17 | FtcRobotController/java/org.firstinspires.ftc.robotcontroller/external/samples
18 |
19 | ### Naming of Samples
20 |
21 | To gain a better understanding of how the samples are organized, and how to interpret the
22 | naming system, it will help to understand the conventions that were used during their creation.
23 |
24 | These conventions are described (in detail) in the sample_conventions.md file in this folder.
25 |
26 | To summarize: A range of different samples classes will reside in the java/external/samples.
27 | The class names will follow a naming convention which indicates the purpose of each class.
28 | The prefix of the name will be one of the following:
29 |
30 | Basic: This is a minimally functional OpMode used to illustrate the skeleton/structure
31 | of a particular style of OpMode. These are bare bones examples.
32 |
33 | Sensor: This is a Sample OpMode that shows how to use a specific sensor.
34 | It is not intended to drive a functioning robot, it is simply showing the minimal code
35 | required to read and display the sensor values.
36 |
37 | Robot: This is a Sample OpMode that assumes a simple two-motor (differential) drive base.
38 | It may be used to provide a common baseline driving OpMode, or
39 | to demonstrate how a particular sensor or concept can be used to navigate.
40 |
41 | Concept: This is a sample OpMode that illustrates performing a specific function or concept.
42 | These may be complex, but their operation should be explained clearly in the comments,
43 | or the comments should reference an external doc, guide or tutorial.
44 | Each OpMode should try to only demonstrate a single concept so they are easy to
45 | locate based on their name. These OpModes may not produce a drivable robot.
46 |
47 | After the prefix, other conventions will apply:
48 |
49 | * Sensor class names are constructed as: Sensor - Company - Type
50 | * Robot class names are constructed as: Robot - Mode - Action - OpModetype
51 | * Concept class names are constructed as: Concept - Topic - OpModetype
52 |
53 | Once you are familiar with the range of samples available, you can choose one to be the
54 | basis for your own robot. In all cases, the desired sample(s) needs to be copied into
55 | your TeamCode module to be used.
56 |
57 | This is done inside Android Studio directly, using the following steps:
58 |
59 | 1) Locate the desired sample class in the Project/Android tree.
60 |
61 | 2) Right click on the sample class and select "Copy"
62 |
63 | 3) Expand the TeamCode/java folder
64 |
65 | 4) Right click on the org.firstinspires.ftc.teamcode folder and select "Paste"
66 |
67 | 5) You will be prompted for a class name for the copy.
68 | Choose something meaningful based on the purpose of this class.
69 | Start with a capital letter, and remember that there may be more similar classes later.
70 |
71 | Once your copy has been created, you should prepare it for use on your robot.
72 | This is done by adjusting the OpMode's name, and enabling it to be displayed on the
73 | Driver Station's OpMode list.
74 |
75 | Each OpMode sample class begins with several lines of code like the ones shown below:
76 |
77 | ```
78 | @TeleOp(name="Template: Linear OpMode", group="Linear Opmode")
79 | @Disabled
80 | ```
81 |
82 | The name that will appear on the driver station's "opmode list" is defined by the code:
83 | ``name="Template: Linear OpMode"``
84 | You can change what appears between the quotes to better describe your opmode.
85 | The "group=" portion of the code can be used to help organize your list of OpModes.
86 |
87 | As shown, the current OpMode will NOT appear on the driver station's OpMode list because of the
88 | ``@Disabled`` annotation which has been included.
89 | This line can simply be deleted , or commented out, to make the OpMode visible.
90 |
91 |
92 |
93 | ## ADVANCED Multi-Team App management: Cloning the TeamCode Module
94 |
95 | In some situations, you have multiple teams in your club and you want them to all share
96 | a common code organization, with each being able to *see* the others code but each having
97 | their own team module with their own code that they maintain themselves.
98 |
99 | In this situation, you might wish to clone the TeamCode module, once for each of these teams.
100 | Each of the clones would then appear along side each other in the Android Studio module list,
101 | together with the FtcRobotController module (and the original TeamCode module).
102 |
103 | Selective Team phones can then be programmed by selecting the desired Module from the pulldown list
104 | prior to clicking to the green Run arrow.
105 |
106 | Warning: This is not for the inexperienced Software developer.
107 | You will need to be comfortable with File manipulations and managing Android Studio Modules.
108 | These changes are performed OUTSIDE of Android Studios, so close Android Studios before you do this.
109 |
110 | Also.. Make a full project backup before you start this :)
111 |
112 | To clone TeamCode, do the following:
113 |
114 | Note: Some names start with "Team" and others start with "team". This is intentional.
115 |
116 | 1) Using your operating system file management tools, copy the whole "TeamCode"
117 | folder to a sibling folder with a corresponding new name, eg: "Team0417".
118 |
119 | 2) In the new Team0417 folder, delete the TeamCode.iml file.
120 |
121 | 3) the new Team0417 folder, rename the "src/main/java/org/firstinspires/ftc/teamcode" folder
122 | to a matching name with a lowercase 'team' eg: "team0417".
123 |
124 | 4) In the new Team0417/src/main folder, edit the "AndroidManifest.xml" file, change the line that contains
125 | package="org.firstinspires.ftc.teamcode"
126 | to be
127 | package="org.firstinspires.ftc.team0417"
128 |
129 | 5) Add: include ':Team0417' to the "/settings.gradle" file.
130 |
131 | 6) Open up Android Studios and clean out any old files by using the menu to "Build/Clean Project""
--------------------------------------------------------------------------------
/TeamCode/src/main/res/raw/readme.md:
--------------------------------------------------------------------------------
1 | Place your sound files in this folder to use them as project resources.
--------------------------------------------------------------------------------
/TeamCode/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/build.common.gradle:
--------------------------------------------------------------------------------
1 | /**
2 | * build.common.gradle
3 | *
4 | * Try to avoid editing this file, as it may be updated from time to time as the FTC SDK
5 | * evolves. Rather, if it is necessary to customize the build process, do those edits in
6 | * the build.gradle file in TeamCode.
7 | *
8 | * This file contains the necessary content of the 'build.gradle' files for robot controller
9 | * applications built using the FTC SDK. Each individual 'build.gradle' in those applications
10 | * can simply contain the one line:
11 | *
12 | * apply from: '../build.common.gradle'
13 | *
14 | * which will pick up this file here. This approach allows makes it easier to integrate
15 | * updates to the FTC SDK into your code.
16 | */
17 |
18 | import java.util.regex.Pattern
19 |
20 | apply plugin: 'com.android.application'
21 |
22 | android {
23 |
24 | compileSdkVersion 30
25 |
26 | signingConfigs {
27 | release {
28 | def apkStoreFile = System.getenv("APK_SIGNING_STORE_FILE")
29 | if (apkStoreFile != null) {
30 | keyAlias System.getenv("APK_SIGNING_KEY_ALIAS")
31 | keyPassword System.getenv("APK_SIGNING_KEY_PASSWORD")
32 | storeFile file(System.getenv("APK_SIGNING_STORE_FILE"))
33 | storePassword System.getenv("APK_SIGNING_STORE_PASSWORD")
34 | } else {
35 | keyAlias 'androiddebugkey'
36 | keyPassword 'android'
37 | storeFile rootProject.file('libs/ftc.debug.keystore')
38 | storePassword 'android'
39 | }
40 | }
41 |
42 | debug {
43 | keyAlias 'androiddebugkey'
44 | keyPassword 'android'
45 | storeFile rootProject.file('libs/ftc.debug.keystore')
46 | storePassword 'android'
47 | }
48 | }
49 |
50 | defaultConfig {
51 | signingConfig signingConfigs.debug
52 | applicationId 'com.qualcomm.ftcrobotcontroller'
53 | minSdkVersion 24
54 | //noinspection ExpiredTargetSdkVersion
55 | targetSdkVersion 28
56 |
57 | /**
58 | * We keep the versionCode and versionName of robot controller applications in sync with
59 | * the master information published in the AndroidManifest.xml file of the FtcRobotController
60 | * module. This helps avoid confusion that might arise from having multiple versions of
61 | * a robot controller app simultaneously installed on a robot controller device.
62 | *
63 | * We accomplish this with the help of a funky little Groovy script that maintains that
64 | * correspondence automatically.
65 | *
66 | * @see Configure Your Build
67 | * @see Versioning Your App
68 | */
69 | def manifestFile = project(':FtcRobotController').file('src/main/AndroidManifest.xml');
70 | def manifestText = manifestFile.getText()
71 | //
72 | def vCodePattern = Pattern.compile("versionCode=\"(\\d+(\\.\\d+)*)\"")
73 | def matcher = vCodePattern.matcher(manifestText)
74 | matcher.find()
75 | def vCode = Integer.parseInt(matcher.group(1))
76 | //
77 | def vNamePattern = Pattern.compile("versionName=\"(.*)\"")
78 | matcher = vNamePattern.matcher(manifestText);
79 | matcher.find()
80 | def vName = matcher.group(1)
81 | //
82 | versionCode vCode
83 | versionName vName
84 | }
85 |
86 | // http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.BuildType.html
87 | buildTypes {
88 | release {
89 | signingConfig signingConfigs.release
90 |
91 | ndk {
92 | abiFilters "armeabi-v7a", "arm64-v8a"
93 | }
94 | }
95 | debug {
96 | debuggable true
97 | jniDebuggable true
98 | ndk {
99 | abiFilters "armeabi-v7a", "arm64-v8a"
100 | }
101 | }
102 | }
103 |
104 | compileOptions {
105 | sourceCompatibility JavaVersion.VERSION_1_8
106 | targetCompatibility JavaVersion.VERSION_1_8
107 | }
108 |
109 | packagingOptions {
110 | pickFirst '**/*.so'
111 | }
112 | ndkVersion '21.3.6528147'
113 | }
114 |
115 | repositories {
116 | }
117 |
118 |
--------------------------------------------------------------------------------
/build.dependencies.gradle:
--------------------------------------------------------------------------------
1 | repositories {
2 | mavenCentral()
3 | google() // Needed for androidx
4 | }
5 |
6 | dependencies {
7 | implementation 'org.firstinspires.ftc:Inspection:10.2.0'
8 | implementation 'org.firstinspires.ftc:Blocks:10.2.0'
9 | implementation 'org.firstinspires.ftc:RobotCore:10.2.0'
10 | implementation 'org.firstinspires.ftc:RobotServer:10.2.0'
11 | implementation 'org.firstinspires.ftc:OnBotJava:10.2.0'
12 | implementation 'org.firstinspires.ftc:Hardware:10.2.0'
13 | implementation 'org.firstinspires.ftc:FtcCommon:10.2.0'
14 | implementation 'org.firstinspires.ftc:Vision:10.2.0'
15 | implementation 'androidx.appcompat:appcompat:1.2.0'
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | /**
2 | * Top-level build file for ftc_app project.
3 | *
4 | * It is extraordinarily rare that you will ever need to edit this file.
5 | */
6 |
7 | buildscript {
8 | repositories {
9 | mavenCentral()
10 | google()
11 | }
12 | dependencies {
13 | // Note for FTC Teams: Do not modify this yourself.
14 | classpath 'com.android.tools.build:gradle:8.7.0'
15 | }
16 | }
17 |
18 | // This is now required because aapt2 has to be downloaded from the
19 | // google() repository beginning with version 3.2 of the Android Gradle Plugin
20 | allprojects {
21 | repositories {
22 | mavenCentral()
23 | google()
24 | }
25 | }
26 |
27 | repositories {
28 | mavenCentral()
29 | }
30 |
--------------------------------------------------------------------------------
/doc/legal/AudioBlocksSounds.txt:
--------------------------------------------------------------------------------
1 | The sound files listed below in this SDK were purchased from www.audioblocks.com under the
2 | following license.
3 |
4 | http://support.audioblocks.com/customer/en/portal/topics/610636-licensing-faq-s/articles
5 |
6 | How am I allowed to use your content?
7 | Last Updated: Aug 11, 2016 01:51PM EDT
8 | Our content may be used for nearly any project, commercial or otherwise, including feature
9 | films, broadcast, commercial, industrial, educational video, print projects, multimedia,
10 | games, and the internet, so long as substantial value is added to the content. (For example,
11 | incorporating an audio clip into a commercial qualifies, while reposting our audio clip on
12 | YouTube with no modification or no visual component does not.) Once you download a file it is
13 | yours to keep and use forever, royalty- free, even if you change your subscription or cancel
14 | your account.
15 |
16 | List of applicable sound files
17 |
18 | chimeconnect.wav
19 | chimedisconnect.wav
20 | errormessage.wav
21 | warningmessage.wav
--------------------------------------------------------------------------------
/doc/legal/Exhibit A - LEGO Open Source License Agreement.txt:
--------------------------------------------------------------------------------
1 | EXHIBIT A - LEGO® Open Source License Agreement
2 |
3 | The contents of the file 'nxtstartupsound.wav' contained in this SDK are subject to the
4 | LEGO® Open Source License Agreement Version 1.0 (the "License"); you may not use this
5 | file except in compliance with the License. You may obtain a copy of the License
6 | at "LEGO Open Source License.pdf" contained in the same directory as this exhibit.
7 |
8 | Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
9 | WARRANTY OF ANY KIND, either express or implied. See the License for the specific
10 | language governing rights and limitations under the License.
11 |
12 | The Original Code is \AT91SAM7S256\Resource\SOUNDS\!Startup.rso.
13 | LEGO is the owner of the Original Code. Portions created by Robert Atkinson are
14 | Copyright (C) 2015. All Rights Reserved.
15 | Contributor(s): Robert Atkinson.
--------------------------------------------------------------------------------
/doc/legal/LEGO Open Source License.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FIRST-Tech-Challenge/FtcRobotController/28d52462d144e6594cb81379872c015c88228f48/doc/legal/LEGO Open Source License.pdf
--------------------------------------------------------------------------------
/doc/media/PullRequest.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FIRST-Tech-Challenge/FtcRobotController/28d52462d144e6594cb81379872c015c88228f48/doc/media/PullRequest.PNG
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # AndroidX package structure to make it clearer which packages are bundled with the
2 | # Android operating system, and which are packaged with your app's APK
3 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
4 | android.useAndroidX=true
5 |
6 | # We no longer need to auto-convert third-party libraries to use AndroidX, which slowed down the build
7 | android.enableJetifier=false
8 |
9 | # Allow Gradle to use up to 1 GB of RAM
10 | org.gradle.jvmargs=-Xmx1024M
11 |
12 | android.nonTransitiveRClass=false
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FIRST-Tech-Challenge/FtcRobotController/28d52462d144e6594cb81379872c015c88228f48/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/libs/README.txt:
--------------------------------------------------------------------------------
1 | Location of external libs
2 |
--------------------------------------------------------------------------------
/libs/ftc.debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FIRST-Tech-Challenge/FtcRobotController/28d52462d144e6594cb81379872c015c88228f48/libs/ftc.debug.keystore
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':FtcRobotController'
2 | include ':TeamCode'
3 |
--------------------------------------------------------------------------------