├── .github ├── CONTRIBUTING.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── FtcRobotController ├── LICENSE ├── build.gradle ├── build.release.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ ├── FTC_2016-17.dat │ ├── FTC_2016-17.xml │ ├── RelicVuMark.dat │ ├── RelicVuMark.xml │ ├── RoverRuckus.dat │ ├── RoverRuckus.tflite │ ├── RoverRuckus.xml │ ├── Skystone.dat │ ├── Skystone.tflite │ ├── Skystone.xml │ ├── StonesAndChips.dat │ ├── StonesAndChips.xml │ ├── UltimateGoal.dat │ ├── UltimateGoal.tflite │ └── UltimateGoal.xml │ ├── java │ └── org │ │ └── firstinspires │ │ └── ftc │ │ └── robotcontroller │ │ ├── external │ │ └── samples │ │ │ ├── BasicOpMode_Iterative.java │ │ │ ├── BasicOpMode_Linear.java │ │ │ ├── ConceptCompassCalibration.java │ │ │ ├── ConceptDIMAsIndicator.java │ │ │ ├── ConceptI2cAddressChange.java │ │ │ ├── ConceptMotorBulkRead.java │ │ │ ├── ConceptNullOp.java │ │ │ ├── ConceptRampMotorSpeed.java │ │ │ ├── ConceptRevSPARKMini.java │ │ │ ├── ConceptScanServo.java │ │ │ ├── ConceptSoundsASJava.java │ │ │ ├── ConceptSoundsOnBotJava.java │ │ │ ├── ConceptSoundsSKYSTONE.java │ │ │ ├── ConceptTelemetry.java │ │ │ ├── ConceptTensorFlowObjectDetection.java │ │ │ ├── ConceptTensorFlowObjectDetectionSwitchableCameras.java │ │ │ ├── ConceptTensorFlowObjectDetectionWebcam.java │ │ │ ├── ConceptVuMarkIdentification.java │ │ │ ├── ConceptVuMarkIdentificationWebcam.java │ │ │ ├── ConceptVuforiaNavigation.java │ │ │ ├── ConceptVuforiaNavigationWebcam.java │ │ │ ├── ConceptVuforiaSkyStoneNavigation.java │ │ │ ├── ConceptVuforiaSkyStoneNavigationWebcam.java │ │ │ ├── ConceptVuforiaUltimateGoalNavigation.java │ │ │ ├── ConceptVuforiaUltimateGoalNavigationWebcam.java │ │ │ ├── ConceptWebcam.java │ │ │ ├── HardwarePushbot.java │ │ │ ├── PushbotAutoDriveByEncoder_Linear.java │ │ │ ├── PushbotAutoDriveByGyro_Linear.java │ │ │ ├── PushbotAutoDriveByTime_Linear.java │ │ │ ├── PushbotAutoDriveToLine_Linear.java │ │ │ ├── PushbotTeleopPOV_Linear.java │ │ │ ├── PushbotTeleopTank_Iterative.java │ │ │ ├── SampleRevBlinkinLedDriver.java │ │ │ ├── SensorAdafruitRGB.java │ │ │ ├── SensorBNO055IMU.java │ │ │ ├── SensorBNO055IMUCalibration.java │ │ │ ├── SensorColor.java │ │ │ ├── SensorDIO.java │ │ │ ├── SensorDigitalTouch.java │ │ │ ├── SensorKLNavxMicro.java │ │ │ ├── SensorMRColor.java │ │ │ ├── SensorMRCompass.java │ │ │ ├── SensorMRGyro.java │ │ │ ├── SensorMRIrSeeker.java │ │ │ ├── SensorMROpticalDistance.java │ │ │ ├── SensorMRRangeSensor.java │ │ │ ├── SensorREV2mDistance.java │ │ │ ├── SensorREVColorDistance.java │ │ │ ├── readme.md │ │ │ └── sample_conventions.md │ │ └── internal │ │ ├── FtcOpModeRegister.java │ │ ├── FtcRobotControllerActivity.java │ │ └── PermissionValidatorWrapper.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ ├── ic_launcher.png │ ├── icon_menu.png │ └── icon_robotcontroller.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── layout │ └── activity_ftc_controller.xml │ ├── menu │ └── ftc_robot_controller.xml │ ├── raw │ ├── gold.wav │ └── silver.wav │ ├── values-sw600dp │ └── dimens.xml │ ├── values-sw720dp-land │ └── dimens.xml │ ├── values-w820dp │ └── dimens.xml │ ├── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml │ └── xml │ ├── app_settings.xml │ └── device_filter.xml ├── README.md ├── TeamCode ├── LICENSE ├── build.gradle ├── build.release.gradle ├── lib │ └── OpModeAnnotationProcessor.jar ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── org │ │ └── firstinspires │ │ └── ftc │ │ └── teamcode │ │ ├── commands │ │ ├── MecanumDriveCommand.java │ │ ├── RunCommand.java │ │ ├── TrajectoryFollowerCommand.java │ │ └── TurnCommand.java │ │ ├── drive │ │ ├── DriveConstants.java │ │ ├── SampleMecanumDrive.java │ │ ├── SampleTankDrive.java │ │ ├── StandardTrackingWheelLocalizer.java │ │ └── opmode │ │ │ ├── AutomaticFeedforwardTuner.java │ │ │ ├── BackAndForth.java │ │ │ ├── DriveVelocityPIDTuner.java │ │ │ ├── FieldCentricTest.java │ │ │ ├── FollowerPIDTuner.java │ │ │ ├── LocalizationTest.java │ │ │ ├── ManualFeedforwardTuner.java │ │ │ ├── MaxVelocityTuner.java │ │ │ ├── SplineTest.java │ │ │ ├── StrafeTest.java │ │ │ ├── StraightTest.java │ │ │ ├── TrackWidthTuner.java │ │ │ ├── TrackingWheelLateralDistanceTuner.java │ │ │ └── TurnTest.java │ │ ├── readme.md │ │ ├── subsystems │ │ └── MecanumDriveSubsystem.java │ │ └── util │ │ ├── AssetsTrajectoryManager.java │ │ ├── AxesSigns.java │ │ ├── BNO055IMUUtil.java │ │ ├── DashboardUtil.java │ │ ├── Encoder.java │ │ ├── LoggingUtil.java │ │ ├── LynxModuleUtil.java │ │ ├── Pose2dUtil.kt │ │ └── RegressionUtil.java │ └── res │ ├── raw │ └── readme.md │ ├── values │ └── strings.xml │ └── xml │ └── teamwebcamcalibrations.xml ├── build.common.gradle ├── build.gradle ├── doc ├── apk │ ├── FtcDriverStation-release.apk │ └── FtcRobotController-release.apk ├── legal │ ├── AudioBlocksSounds.txt │ ├── Exhibit A - LEGO Open Source License Agreement.txt │ └── LEGO Open Source License.pdf ├── media │ ├── PullRequest.PNG │ ├── chips.jpg │ ├── readme.md │ ├── stones.jpg │ ├── target_chips_A4.pdf │ ├── target_chips_USLetter.pdf │ ├── target_stones_A4.pdf │ └── target_stones_USLetter.pdf └── tutorial │ └── README.txt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libs ├── Analytics-release.aar ├── README.txt ├── Vuforia.jar ├── WirelessP2p-release.aar ├── arm64-v8a │ └── libVuforia.so ├── armeabi-v7a │ └── libVuforia.so ├── ftc.debug.keystore ├── tensorflow-lite-0.0.0-nightly.aar └── tfod-release.aar └── 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 | ![Pull Button](../doc/media/PullRequest.PNG) 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.usfirst.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/ftctechnh/ftc_app/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 forums. Build community support for it. The FTC Technology Team monitors the forums. 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 class files 13 | *.class 14 | 15 | # Generated files 16 | bin/ 17 | gen/ 18 | out/ 19 | # Uncomment the following line in case you need and you don't have the release build type files in your app 20 | # release/ 21 | 22 | # Gradle files 23 | .gradle/ 24 | build/ 25 | 26 | # Local configuration file (sdk path, etc) 27 | local.properties 28 | 29 | # Proguard folder generated by Eclipse 30 | proguard/ 31 | 32 | # Log Files 33 | *.log 34 | 35 | # Android Studio Navigation editor temp files 36 | .navigation/ 37 | 38 | # Android Studio captures folder 39 | captures/ 40 | 41 | # IntelliJ 42 | *.iml 43 | .idea/workspace.xml 44 | .idea/tasks.xml 45 | .idea/gradle.xml 46 | .idea/assetWizardSettings.xml 47 | .idea/dictionaries 48 | .idea/libraries 49 | # Android Studio 3 in .gitignore file. 50 | .idea/caches 51 | .idea/modules.xml 52 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 53 | .idea/navEditor.xml 54 | 55 | # Keystore files 56 | # Uncomment the following lines if you do not want to check your keystore files in. 57 | #*.jks 58 | #*.keystore 59 | 60 | # External native build folder generated in Android Studio 2.2 and later 61 | .externalNativeBuild 62 | .cxx/ 63 | 64 | # Google Services (e.g. APIs or Firebase) 65 | # google-services.json 66 | 67 | # Freeline 68 | freeline.py 69 | freeline/ 70 | freeline_project_description.json 71 | 72 | # fastlane 73 | fastlane/report.xml 74 | fastlane/Preview.html 75 | fastlane/screenshots 76 | fastlane/test_output 77 | fastlane/readme.md 78 | 79 | # Version control 80 | vcs.xml 81 | 82 | # lint 83 | lint/intermediates/ 84 | lint/generated/ 85 | lint/outputs/ 86 | lint/tmp/ 87 | # lint/reports/ 88 | 89 | .DS_Store 90 | .idea 91 | -------------------------------------------------------------------------------- /FtcRobotController/LICENSE: -------------------------------------------------------------------------------- 1 | License information 2 | 3 | ================================================================================ 4 | FtcDriverStation, FtcRobotController, FtcCommon, Hardware, RobotCore 5 | ModernRobotics, Analytics, and WirelessP2p have the following license: 6 | 7 | Copyright (c) 2014-2016 Qualcomm Technologies Inc 8 | 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without modification, 12 | are permitted (subject to the limitations in the disclaimer below) provided that 13 | the following conditions are met: 14 | 15 | Redistributions of source code must retain the above copyright notice, this list 16 | of conditions and the following disclaimer. 17 | 18 | Redistributions in binary form must reproduce the above copyright notice, this 19 | list of conditions and the following disclaimer in the documentation and/or 20 | other materials provided with the distribution. 21 | 22 | Neither the name of Qualcomm Technologies Inc nor the names of its contributors 23 | may be used to endorse or promote products derived from this software without 24 | specific prior written permission. 25 | 26 | Qualcomm Technologies Inc., will periodically collect anonymous information 27 | about the device this software is installed on such as the make, model, and 28 | software versions, but no information that identifies you. 29 | 30 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS 31 | LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 32 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 33 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 34 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 35 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 36 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 37 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 38 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 40 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | 42 | -------------------------------------------------------------------------------- /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 23 12 | targetSdkVersion 28 13 | buildConfigField "String", "BUILD_TIME", '"' + (new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.ROOT).format(new Date())) + '"' 14 | } 15 | 16 | compileSdkVersion 29 17 | 18 | compileOptions { 19 | sourceCompatibility JavaVersion.VERSION_1_7 20 | targetCompatibility JavaVersion.VERSION_1_7 21 | } 22 | } 23 | 24 | repositories { 25 | maven { url = "https://dl.bintray.com/first-tech-challenge/ftcsdk/" } 26 | 27 | flatDir { 28 | dirs '../libs' 29 | } 30 | } 31 | 32 | apply from: 'build.release.gradle' 33 | -------------------------------------------------------------------------------- /FtcRobotController/build.release.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation 'org.firstinspires.ftc:Inspection:6.1.1' 3 | implementation 'org.firstinspires.ftc:Blocks:6.1.1' 4 | implementation 'org.firstinspires.ftc:RobotCore:6.1.1' 5 | implementation 'org.firstinspires.ftc:RobotServer:6.1.1' 6 | implementation 'org.firstinspires.ftc:OnBotJava:6.1.1' 7 | implementation 'org.firstinspires.ftc:Hardware:6.1.1' 8 | implementation 'org.firstinspires.ftc:FtcCommon:6.1.1' 9 | implementation 'androidx.appcompat:appcompat:1.2.0' 10 | 11 | implementation 'com.acmerobotics.dashboard:dashboard:0.3.10' 12 | } 13 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 18 | 19 | 20 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 44 | 45 | 46 | 47 | 48 | 49 | 52 | 53 | 54 | 57 | 58 | 59 | 60 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/FTC_2016-17.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/assets/FTC_2016-17.dat -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/FTC_2016-17.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/RelicVuMark.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/assets/RelicVuMark.dat -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/RelicVuMark.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/RoverRuckus.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/assets/RoverRuckus.dat -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/RoverRuckus.tflite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/assets/RoverRuckus.tflite -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/RoverRuckus.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/Skystone.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/assets/Skystone.dat -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/Skystone.tflite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/assets/Skystone.tflite -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/Skystone.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/StonesAndChips.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/assets/StonesAndChips.dat -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/StonesAndChips.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/UltimateGoal.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/assets/UltimateGoal.dat -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/UltimateGoal.tflite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/assets/UltimateGoal.tflite -------------------------------------------------------------------------------- /FtcRobotController/src/main/assets/UltimateGoal.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptCompassCalibration.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.CompassSensor; 36 | import com.qualcomm.robotcore.util.ElapsedTime; 37 | 38 | /** 39 | * This file illustrates the concept of calibrating a MR Compass 40 | * It uses the common Pushbot hardware class to define the drive on the robot. 41 | * The code is structured as a LinearOpMode 42 | * 43 | * This code assumes there is a compass configured with the name "compass" 44 | * 45 | * This code will put the compass into calibration mode, wait three seconds and then attempt 46 | * to rotate two full turns clockwise. This will allow the compass to do a magnetic calibration. 47 | * 48 | * Once compete, the program will put the compass back into measurement mode and check to see if the 49 | * calibration was successful. 50 | * 51 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name. 52 | * Remove or comment out the @Disabled line to add this opmode to the Driver Station OpMode list 53 | */ 54 | 55 | @TeleOp(name="Concept: Compass Calibration", group="Concept") 56 | @Disabled 57 | public class ConceptCompassCalibration extends LinearOpMode { 58 | 59 | /* Declare OpMode members. */ 60 | HardwarePushbot robot = new HardwarePushbot(); // Use a Pushbot's hardware 61 | private ElapsedTime runtime = new ElapsedTime(); 62 | CompassSensor compass; 63 | 64 | final static double MOTOR_POWER = 0.2; // scale from 0 to 1 65 | static final long HOLD_TIME_MS = 3000; 66 | static final double CAL_TIME_SEC = 20; 67 | 68 | @Override 69 | public void runOpMode() { 70 | 71 | /* Initialize the drive system variables. 72 | * The init() method of the hardware class does all the work here 73 | */ 74 | robot.init(hardwareMap); 75 | 76 | // get a reference to our Compass Sensor object. 77 | compass = hardwareMap.get(CompassSensor.class, "compass"); 78 | 79 | // Send telemetry message to signify robot waiting; 80 | telemetry.addData("Status", "Ready to cal"); // 81 | telemetry.update(); 82 | 83 | // Wait for the game to start (driver presses PLAY) 84 | waitForStart(); 85 | 86 | // Set the compass to calibration mode 87 | compass.setMode(CompassSensor.CompassMode.CALIBRATION_MODE); 88 | telemetry.addData("Compass", "Compass in calibration mode"); 89 | telemetry.update(); 90 | 91 | sleep(HOLD_TIME_MS); // Just do a sleep while we switch modes 92 | 93 | // Start the robot rotating clockwise 94 | telemetry.addData("Compass", "Calibration mode. Turning the robot..."); 95 | telemetry.update(); 96 | robot.leftDrive.setPower(MOTOR_POWER); 97 | robot.rightDrive.setPower(-MOTOR_POWER); 98 | 99 | // run until time expires OR the driver presses STOP; 100 | runtime.reset(); 101 | while (opModeIsActive() && (runtime.time() < CAL_TIME_SEC)) { 102 | idle(); 103 | } 104 | 105 | // Stop all motors and turn off claibration 106 | robot.leftDrive.setPower(0); 107 | robot.rightDrive.setPower(0); 108 | compass.setMode(CompassSensor.CompassMode.MEASUREMENT_MODE); 109 | telemetry.addData("Compass", "Returning to measurement mode"); 110 | telemetry.update(); 111 | 112 | sleep(HOLD_TIME_MS); // Just do a sleep while we switch modes 113 | 114 | // Report whether the Calibration was successful or not. 115 | if (compass.calibrationFailed()) 116 | telemetry.addData("Compass", "Calibrate Failed. Try Again!"); 117 | else 118 | telemetry.addData("Compass", "Calibrate Passed."); 119 | telemetry.update(); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptDIMAsIndicator.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.DeviceInterfaceModule; 36 | import com.qualcomm.robotcore.util.ElapsedTime; 37 | 38 | /** 39 | * This OpMode illustrates using the Device Interface Module as a signalling device. 40 | * The code is structured as a LinearOpMode 41 | * 42 | * This code assumes a DIM name "dim". 43 | * 44 | * There are many examples where the robot might like to signal the driver, without requiring them 45 | * to look at the driver station. This might be something like a "ball in hopper" condition or a 46 | * "ready to shoot" condition. 47 | * 48 | * The DIM has two user settable indicator LEDs (one red one blue). These can be controlled 49 | * directly from your program. 50 | * 51 | * Use Android Studios to Copy this Class, and Paste it into your team's code folder with a new name. 52 | * Remove or comment out the @Disabled line to add this opmode to the Driver Station OpMode list 53 | */ 54 | @TeleOp(name = "Concept: DIM As Indicator", group = "Concept") 55 | @Disabled 56 | public class ConceptDIMAsIndicator extends LinearOpMode { 57 | 58 | static final int BLUE_LED = 0; // Blue LED channel on DIM 59 | static final int RED_LED = 1; // Red LED Channel on DIM 60 | 61 | // Create timer to toggle LEDs 62 | private ElapsedTime runtime = new ElapsedTime(); 63 | 64 | // Define class members 65 | DeviceInterfaceModule dim; 66 | 67 | @Override 68 | public void runOpMode() { 69 | 70 | // Connect to motor (Assume standard left wheel) 71 | // Change the text in quotes to match any motor name on your robot. 72 | dim = hardwareMap.get(DeviceInterfaceModule.class, "dim"); 73 | 74 | // Toggle LEDs while Waiting for the start button 75 | telemetry.addData(">", "Press Play to test LEDs." ); 76 | telemetry.update(); 77 | 78 | while (!isStarted()) { 79 | // Determine if we are on an odd or even second 80 | boolean even = (((int)(runtime.time()) & 0x01) == 0); 81 | dim.setLED(RED_LED, even); // Red for even 82 | dim.setLED(BLUE_LED, !even); // Blue for odd 83 | idle(); 84 | } 85 | 86 | // Running now 87 | telemetry.addData(">", "Press X for Blue, B for Red." ); 88 | telemetry.update(); 89 | 90 | // Now just use red and blue buttons to set red and blue LEDs 91 | while(opModeIsActive()){ 92 | dim.setLED(BLUE_LED, gamepad1.x); 93 | dim.setLED(RED_LED, gamepad1.b); 94 | idle(); 95 | } 96 | 97 | // Turn off LEDs; 98 | dim.setLED(BLUE_LED, false); 99 | dim.setLED(RED_LED, false); 100 | telemetry.addData(">", "Done"); 101 | telemetry.update(); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /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 | import java.text.SimpleDateFormat; 38 | import java.util.Date; 39 | 40 | /** 41 | * Demonstrates empty OpMode 42 | */ 43 | @TeleOp(name = "Concept: NullOp", group = "Concept") 44 | @Disabled 45 | public class ConceptNullOp extends OpMode { 46 | 47 | private ElapsedTime runtime = new ElapsedTime(); 48 | 49 | @Override 50 | public void init() { 51 | telemetry.addData("Status", "Initialized"); 52 | } 53 | 54 | /* 55 | * Code to run when the op mode is first enabled goes here 56 | * @see com.qualcomm.robotcore.eventloop.opmode.OpMode#start() 57 | */ 58 | @Override 59 | public void init_loop() { 60 | } 61 | 62 | /* 63 | * This method will be called ONCE when start is pressed 64 | * @see com.qualcomm.robotcore.eventloop.opmode.OpMode#loop() 65 | */ 66 | @Override 67 | public void start() { 68 | runtime.reset(); 69 | } 70 | 71 | /* 72 | * This method will be called repeatedly in a loop 73 | * @see com.qualcomm.robotcore.eventloop.opmode.OpMode#loop() 74 | */ 75 | @Override 76 | public void loop() { 77 | telemetry.addData("Status", "Run Time: " + runtime.toString()); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /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 pushbot. 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/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 | * 42 | * This OpMode executes a basic Tank Drive Teleop for a two wheeled robot using two REV SPARKminis. 43 | * To use this example, connect two REV SPARKminis into servo ports on the Expansion 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 Studios 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 the robot configuration 67 | // step (using the FTC Robot Controller app on the phone). 68 | leftDrive = hardwareMap.get(DcMotorSimple.class, "left_drive"); 69 | rightDrive = hardwareMap.get(DcMotorSimple.class, "right_drive"); 70 | 71 | // Most robots need the motor on one side to be reversed to drive forward 72 | // Reverse the motor that runs backwards when connected directly to the battery 73 | leftDrive.setDirection(DcMotorSimple.Direction.FORWARD); 74 | rightDrive.setDirection(DcMotorSimple.Direction.REVERSE); 75 | 76 | // Wait for the game to start (driver presses PLAY) 77 | waitForStart(); 78 | runtime.reset(); 79 | 80 | // run until the end of the match (driver presses STOP) 81 | while (opModeIsActive()) { 82 | 83 | // Setup a variable for each drive wheel to save power level for telemetry 84 | double leftPower; 85 | double rightPower; 86 | 87 | // Choose to drive using either Tank Mode, or POV Mode 88 | // Comment out the method that's not used. The default below is POV. 89 | 90 | // POV Mode uses left stick to go forward, and right stick to turn. 91 | // - This uses basic math to combine motions and is easier to drive straight. 92 | double drive = -gamepad1.left_stick_y; 93 | double turn = gamepad1.right_stick_x; 94 | leftPower = Range.clip(drive + turn, -1.0, 1.0) ; 95 | rightPower = Range.clip(drive - turn, -1.0, 1.0) ; 96 | 97 | // Tank Mode uses one stick to control each wheel. 98 | // - This requires no math, but it is hard to drive forward slowly and keep straight. 99 | // leftPower = -gamepad1.left_stick_y ; 100 | // rightPower = -gamepad1.right_stick_y ; 101 | 102 | // Send calculated power to wheels 103 | leftDrive.setPower(leftPower); 104 | rightDrive.setPower(rightPower); 105 | 106 | // Show the elapsed game time and wheel power. 107 | telemetry.addData("Status", "Run Time: " + runtime.toString()); 108 | telemetry.addData("Motors", "left (%.2f), right (%.2f)", leftPower, rightPower); 109 | telemetry.update(); 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /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 forwards 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 pushbot. 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 PushBot 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/HardwarePushbot.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.hardware.DcMotor; 33 | import com.qualcomm.robotcore.hardware.HardwareMap; 34 | import com.qualcomm.robotcore.hardware.Servo; 35 | import com.qualcomm.robotcore.util.ElapsedTime; 36 | 37 | /** 38 | * This is NOT an opmode. 39 | * 40 | * This class can be used to define all the specific hardware for a single robot. 41 | * In this case that robot is a Pushbot. 42 | * See PushbotTeleopTank_Iterative and others classes starting with "Pushbot" for usage examples. 43 | * 44 | * This hardware class assumes the following device names have been configured on the robot: 45 | * Note: All names are lower case and some have single spaces between words. 46 | * 47 | * Motor channel: Left drive motor: "left_drive" 48 | * Motor channel: Right drive motor: "right_drive" 49 | * Motor channel: Manipulator drive motor: "left_arm" 50 | * Servo channel: Servo to open left claw: "left_hand" 51 | * Servo channel: Servo to open right claw: "right_hand" 52 | */ 53 | public class HardwarePushbot 54 | { 55 | /* Public OpMode members. */ 56 | public DcMotor leftDrive = null; 57 | public DcMotor rightDrive = null; 58 | public DcMotor leftArm = null; 59 | public Servo leftClaw = null; 60 | public Servo rightClaw = null; 61 | 62 | public static final double MID_SERVO = 0.5 ; 63 | public static final double ARM_UP_POWER = 0.45 ; 64 | public static final double ARM_DOWN_POWER = -0.45 ; 65 | 66 | /* local OpMode members. */ 67 | HardwareMap hwMap = null; 68 | private ElapsedTime period = new ElapsedTime(); 69 | 70 | /* Constructor */ 71 | public HardwarePushbot(){ 72 | 73 | } 74 | 75 | /* Initialize standard Hardware interfaces */ 76 | public void init(HardwareMap ahwMap) { 77 | // Save reference to Hardware map 78 | hwMap = ahwMap; 79 | 80 | // Define and Initialize Motors 81 | leftDrive = hwMap.get(DcMotor.class, "left_drive"); 82 | rightDrive = hwMap.get(DcMotor.class, "right_drive"); 83 | leftArm = hwMap.get(DcMotor.class, "left_arm"); 84 | leftDrive.setDirection(DcMotor.Direction.FORWARD); // Set to REVERSE if using AndyMark motors 85 | rightDrive.setDirection(DcMotor.Direction.REVERSE);// Set to FORWARD if using AndyMark motors 86 | 87 | // Set all motors to zero power 88 | leftDrive.setPower(0); 89 | rightDrive.setPower(0); 90 | leftArm.setPower(0); 91 | 92 | // Set all motors to run without encoders. 93 | // May want to use RUN_USING_ENCODERS if encoders are installed. 94 | leftDrive.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER); 95 | rightDrive.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER); 96 | leftArm.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER); 97 | 98 | // Define and initialize ALL installed servos. 99 | leftClaw = hwMap.get(Servo.class, "left_hand"); 100 | rightClaw = hwMap.get(Servo.class, "right_hand"); 101 | leftClaw.setPosition(MID_SERVO); 102 | rightClaw.setPosition(MID_SERVO); 103 | } 104 | } 105 | 106 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/PushbotAutoDriveByTime_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.util.ElapsedTime; 36 | 37 | /** 38 | * This file illustrates the concept of driving a path based on time. 39 | * It uses the common Pushbot hardware class to define the drive on the robot. 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: PushbotAutoDriveByEncoder; 44 | * 45 | * The desired path in this example is: 46 | * - Drive forward for 3 seconds 47 | * - Spin right for 1.3 seconds 48 | * - Drive Backwards for 1 Second 49 | * - Stop and close the claw. 50 | * 51 | * The code is written in a simple form with no optimizations. 52 | * However, there are several ways that this type of sequence could be streamlined, 53 | * 54 | * Use Android Studios to Copy this Class, and Paste it into your team's code 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 | 58 | @Autonomous(name="Pushbot: Auto Drive By Time", group="Pushbot") 59 | @Disabled 60 | public class PushbotAutoDriveByTime_Linear extends LinearOpMode { 61 | 62 | /* Declare OpMode members. */ 63 | HardwarePushbot robot = new HardwarePushbot(); // Use a Pushbot's hardware 64 | private ElapsedTime runtime = new ElapsedTime(); 65 | 66 | 67 | static final double FORWARD_SPEED = 0.6; 68 | static final double TURN_SPEED = 0.5; 69 | 70 | @Override 71 | public void runOpMode() { 72 | 73 | /* 74 | * Initialize the drive system variables. 75 | * The init() method of the hardware class does all the work here 76 | */ 77 | robot.init(hardwareMap); 78 | 79 | // Send telemetry message to signify robot waiting; 80 | telemetry.addData("Status", "Ready to run"); // 81 | telemetry.update(); 82 | 83 | // Wait for the game to start (driver presses PLAY) 84 | waitForStart(); 85 | 86 | // Step through each leg of the path, ensuring that the Auto mode has not been stopped along the way 87 | 88 | // Step 1: Drive forward for 3 seconds 89 | robot.leftDrive.setPower(FORWARD_SPEED); 90 | robot.rightDrive.setPower(FORWARD_SPEED); 91 | runtime.reset(); 92 | while (opModeIsActive() && (runtime.seconds() < 3.0)) { 93 | telemetry.addData("Path", "Leg 1: %2.5f S Elapsed", runtime.seconds()); 94 | telemetry.update(); 95 | } 96 | 97 | // Step 2: Spin right for 1.3 seconds 98 | robot.leftDrive.setPower(TURN_SPEED); 99 | robot.rightDrive.setPower(-TURN_SPEED); 100 | runtime.reset(); 101 | while (opModeIsActive() && (runtime.seconds() < 1.3)) { 102 | telemetry.addData("Path", "Leg 2: %2.5f S Elapsed", runtime.seconds()); 103 | telemetry.update(); 104 | } 105 | 106 | // Step 3: Drive Backwards for 1 Second 107 | robot.leftDrive.setPower(-FORWARD_SPEED); 108 | robot.rightDrive.setPower(-FORWARD_SPEED); 109 | runtime.reset(); 110 | while (opModeIsActive() && (runtime.seconds() < 1.0)) { 111 | telemetry.addData("Path", "Leg 3: %2.5f S Elapsed", runtime.seconds()); 112 | telemetry.update(); 113 | } 114 | 115 | // Step 4: Stop and close the claw. 116 | robot.leftDrive.setPower(0); 117 | robot.rightDrive.setPower(0); 118 | robot.leftClaw.setPosition(1.0); 119 | robot.rightClaw.setPosition(0.0); 120 | 121 | telemetry.addData("Path", "Complete"); 122 | telemetry.update(); 123 | sleep(1000); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorDIO.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.DeviceInterfaceModule; 36 | import com.qualcomm.robotcore.hardware.DigitalChannel; 37 | 38 | /* 39 | * This is an example LinearOpMode that shows how to use the digital inputs and outputs on the 40 | * the Modern Robotics Device Interface Module. In addition, it shows how to use the Red and Blue LED 41 | * 42 | * This op mode assumes that there is a Device Interface Module attached, named 'dim'. 43 | * On this DIM there is a digital input named 'digin' and an output named 'digout' 44 | * 45 | * To fully exercise this sample, connect pin 3 of the digin connector to pin 3 of the digout. 46 | * Note: Pin 1 is indicated by the black stripe, so pin 3 is at the opposite end. 47 | * 48 | * The X button on the gamepad will be used to activate the digital output pin. 49 | * The Red/Blue LED will be used to indicate the state of the digital input pin. 50 | * Blue = false (0V), Red = true (5V) 51 | * If the two pins are linked, the gamepad will change the LED color. 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 | @TeleOp(name = "Sensor: DIM DIO", group = "Sensor") 57 | @Disabled 58 | public class SensorDIO extends LinearOpMode { 59 | 60 | final int BLUE_LED_CHANNEL = 0; 61 | final int RED_LED_CHANNEL = 1; 62 | 63 | @Override 64 | public void runOpMode() { 65 | 66 | boolean inputPin; // Input State 67 | boolean outputPin; // Output State 68 | DeviceInterfaceModule dim; // Device Object 69 | DigitalChannel digIn; // Device Object 70 | DigitalChannel digOut; // Device Object 71 | 72 | // get a reference to a Modern Robotics DIM, and IO channels. 73 | dim = hardwareMap.get(DeviceInterfaceModule.class, "dim"); // Use generic form of device mapping 74 | digIn = hardwareMap.get(DigitalChannel.class, "digin"); // Use generic form of device mapping 75 | digOut = hardwareMap.get(DigitalChannel.class, "digout"); // Use generic form of device mapping 76 | 77 | digIn.setMode(DigitalChannel.Mode.INPUT); // Set the direction of each channel 78 | digOut.setMode(DigitalChannel.Mode.OUTPUT); 79 | 80 | // wait for the start button to be pressed. 81 | telemetry.addData(">", "Press play, and then user X button to set DigOut"); 82 | telemetry.update(); 83 | waitForStart(); 84 | 85 | while (opModeIsActive()) { 86 | 87 | outputPin = gamepad1.x ; // Set the output pin based on x button 88 | digOut.setState(outputPin); 89 | inputPin = digIn.getState(); // Read the input pin 90 | 91 | // Display input pin state on LEDs 92 | if (inputPin) { 93 | dim.setLED(RED_LED_CHANNEL, true); 94 | dim.setLED(BLUE_LED_CHANNEL, false); 95 | } 96 | else { 97 | dim.setLED(RED_LED_CHANNEL, false); 98 | dim.setLED(BLUE_LED_CHANNEL, true); 99 | } 100 | 101 | telemetry.addData("Output", outputPin ); 102 | telemetry.addData("Input", inputPin ); 103 | telemetry.addData("LED", inputPin ? "Red" : "Blue" ); 104 | telemetry.update(); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorDigitalTouch.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.DigitalChannel; 36 | 37 | /* 38 | * This is an example LinearOpMode that shows how to use 39 | * a REV Robotics Touch Sensor. 40 | * 41 | * It assumes that the touch sensor is configured with a name of "sensor_digital". 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 | @TeleOp(name = "Sensor: Digital touch", group = "Sensor") 47 | @Disabled 48 | public class SensorDigitalTouch extends LinearOpMode { 49 | /** 50 | * The REV Robotics Touch Sensor 51 | * is treated as a digital channel. It is HIGH if the button is unpressed. 52 | * It pulls LOW if the button is pressed. 53 | * 54 | * Also, when you connect a REV Robotics Touch Sensor to the digital I/O port on the 55 | * Expansion Hub using a 4-wire JST cable, the second pin gets connected to the Touch Sensor. 56 | * The lower (first) pin stays unconnected.* 57 | */ 58 | 59 | DigitalChannel digitalTouch; // Hardware Device Object 60 | 61 | @Override 62 | public void runOpMode() { 63 | 64 | // get a reference to our digitalTouch object. 65 | digitalTouch = hardwareMap.get(DigitalChannel.class, "sensor_digital"); 66 | 67 | // set the digital channel to input. 68 | digitalTouch.setMode(DigitalChannel.Mode.INPUT); 69 | 70 | // wait for the start button to be pressed. 71 | waitForStart(); 72 | 73 | // while the op mode is active, loop and read the light levels. 74 | // Note we use opModeIsActive() as our loop condition because it is an interruptible method. 75 | while (opModeIsActive()) { 76 | 77 | // send the info back to driver station using telemetry function. 78 | // if the digital channel returns true it's HIGH and the button is unpressed. 79 | if (digitalTouch.getState() == true) { 80 | telemetry.addData("Digital Touch", "Is Not Pressed"); 81 | } else { 82 | telemetry.addData("Digital Touch", "Is Pressed"); 83 | } 84 | 85 | telemetry.update(); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/SensorMRIrSeeker.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.IrSeekerSensor; 36 | 37 | /* 38 | * This is an example LinearOpMode that shows how to use 39 | * the Modern Robotics ITR Seeker 40 | * 41 | * The op mode assumes that the IR Seeker 42 | * is configured with a name of "sensor_ir". 43 | * 44 | * Set the switch on the Modern Robotics IR beacon to 1200 at 180.
45 | * Turn on the IR beacon. 46 | * Make sure the side of the beacon with the LED on is facing the robot.
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 = "Sensor: MR IR Seeker", group = "Sensor") 52 | @Disabled 53 | public class SensorMRIrSeeker extends LinearOpMode { 54 | 55 | @Override 56 | public void runOpMode() { 57 | 58 | IrSeekerSensor irSeeker; // Hardware Device Object 59 | 60 | // get a reference to our GyroSensor object. 61 | irSeeker = hardwareMap.get(IrSeekerSensor.class, "sensor_ir"); 62 | 63 | // wait for the start button to be pressed. 64 | waitForStart(); 65 | 66 | while (opModeIsActive()) { 67 | 68 | // Ensure we have a IR signal 69 | if (irSeeker.signalDetected()) 70 | { 71 | // Display angle and strength 72 | telemetry.addData("Angle", irSeeker.getAngle()); 73 | telemetry.addData("Strength", irSeeker.getStrength()); 74 | } 75 | else 76 | { 77 | // Display loss of signal 78 | telemetry.addData("Seeker", "Signal Lost"); 79 | } 80 | 81 | telemetry.update(); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /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 is an example LinearOpMode that shows how to use 39 | * a Modern Robotics Optical Distance Sensor 40 | * It assumes that the ODS sensor is configured with a name of "sensor_ods". 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: MR ODS", group = "Sensor") 46 | @Disabled 47 | public class SensorMROpticalDistance extends LinearOpMode { 48 | 49 | OpticalDistanceSensor odsSensor; // Hardware Device Object 50 | 51 | @Override 52 | public void runOpMode() { 53 | 54 | // get a reference to our Light Sensor object. 55 | odsSensor = hardwareMap.get(OpticalDistanceSensor.class, "sensor_ods"); 56 | 57 | // wait for the start button to be pressed. 58 | waitForStart(); 59 | 60 | // while the op mode is active, loop and read the light levels. 61 | // Note we use opModeIsActive() as our loop condition because it is an interruptible method. 62 | while (opModeIsActive()) { 63 | 64 | // send the info back to driver station using telemetry function. 65 | telemetry.addData("Raw", odsSensor.getRawLightDetected()); 66 | telemetry.addData("Normal", odsSensor.getLightDetected()); 67 | 68 | telemetry.update(); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /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 | 37 | import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit; 38 | 39 | /** 40 | * {@link SensorMRRangeSensor} illustrates how to use the Modern Robotics 41 | * Range Sensor. 42 | * 43 | * The op mode assumes that the range sensor is configured with a name of "sensor_range". 44 | * 45 | * Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name. 46 | * Remove or comment out the @Disabled line to add this opmode to the Driver Station OpMode list 47 | * 48 | * @see MR Range Sensor 49 | */ 50 | @TeleOp(name = "Sensor: MR range sensor", group = "Sensor") 51 | @Disabled // comment out or remove this line to enable this opmode 52 | public class SensorMRRangeSensor extends LinearOpMode { 53 | 54 | ModernRoboticsI2cRangeSensor rangeSensor; 55 | 56 | @Override public void runOpMode() { 57 | 58 | // get a reference to our compass 59 | rangeSensor = hardwareMap.get(ModernRoboticsI2cRangeSensor.class, "sensor_range"); 60 | 61 | // wait for the start button to be pressed 62 | waitForStart(); 63 | 64 | while (opModeIsActive()) { 65 | telemetry.addData("raw ultrasonic", rangeSensor.rawUltrasonic()); 66 | telemetry.addData("raw optical", rangeSensor.rawOptical()); 67 | telemetry.addData("cm optical", "%.2f cm", rangeSensor.cmOptical()); 68 | telemetry.addData("cm", "%.2f cm", rangeSensor.getDistance(DistanceUnit.CM)); 69 | telemetry.update(); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /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.TeleOp; 37 | import com.qualcomm.robotcore.eventloop.opmode.Disabled; 38 | import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; 39 | import com.qualcomm.robotcore.hardware.DistanceSensor; 40 | 41 | import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit; 42 | 43 | /** 44 | * {@link SensorREV2mDistance} illustrates how to use the REV Robotics 45 | * Time-of-Flight Range Sensor. 46 | * 47 | * The op mode assumes that the range sensor is configured with a name of "sensor_range". 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 | * @see REV Robotics Web Page 53 | */ 54 | @TeleOp(name = "Sensor: REV2mDistance", group = "Sensor") 55 | @Disabled 56 | public class SensorREV2mDistance extends LinearOpMode { 57 | 58 | private DistanceSensor sensorRange; 59 | 60 | @Override 61 | public void runOpMode() { 62 | // you can use this as a regular DistanceSensor. 63 | sensorRange = hardwareMap.get(DistanceSensor.class, "sensor_range"); 64 | 65 | // you can also cast this to a Rev2mDistanceSensor if you want to use added 66 | // methods associated with the Rev2mDistanceSensor class. 67 | Rev2mDistanceSensor sensorTimeOfFlight = (Rev2mDistanceSensor)sensorRange; 68 | 69 | telemetry.addData(">>", "Press start to continue"); 70 | telemetry.update(); 71 | 72 | waitForStart(); 73 | while(opModeIsActive()) { 74 | // generic DistanceSensor methods. 75 | telemetry.addData("deviceName",sensorRange.getDeviceName() ); 76 | telemetry.addData("range", String.format("%.01f mm", sensorRange.getDistance(DistanceUnit.MM))); 77 | telemetry.addData("range", String.format("%.01f cm", sensorRange.getDistance(DistanceUnit.CM))); 78 | telemetry.addData("range", String.format("%.01f m", sensorRange.getDistance(DistanceUnit.METER))); 79 | telemetry.addData("range", String.format("%.01f in", sensorRange.getDistance(DistanceUnit.INCH))); 80 | 81 | // Rev2mDistanceSensor specific methods. 82 | telemetry.addData("ID", String.format("%x", sensorTimeOfFlight.getModelID())); 83 | telemetry.addData("did time out", Boolean.toString(sensorTimeOfFlight.didTimeoutOccur())); 84 | 85 | telemetry.update(); 86 | } 87 | } 88 | 89 | } -------------------------------------------------------------------------------- /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 | Full or partial Samples should be Copied from here, and then Pasted into 6 | the team's folder, using the Android Studio cut and paste commands. 7 | This automatically changes all file and class names to be consistent. 8 | 9 | ### Naming of Samples 10 | 11 | To gain a better understanding of how the samples are organized, and how to interpret the 12 | naming system, it will help to understand the conventions that were used during their creation. 13 | 14 | These conventions are described (in detail) in the sample_conventions.md file in this folder. 15 | 16 | To summarize: A range of different samples classes will reside in the java/external/samples. 17 | The class names will follow a naming convention which indicates the purpose of each class. 18 | The prefix of the name will be one of the following: 19 | 20 | Basic: This is a minimally functional OpMode used to illustrate the skeleton/structure 21 | of a particular style of OpMode. These are bare bones examples. 22 | 23 | Sensor: This is a Sample OpMode that shows how to use a specific sensor. 24 | It is not intended to drive a functioning robot, it is simply showing the minimal code 25 | required to read and display the sensor values. 26 | 27 | Hardware: This is NOT an OpMode, but a helper class that is used to describe 28 | one particular robot's hardware configuration: eg: For the K9 or Pushbot. 29 | Look at any Pushbot sample to see how this can be used in an OpMode. 30 | Teams can copy one of these to their team folder to create their own robot definition. 31 | 32 | Pushbot: This is a Sample OpMode that uses the Pushbot robot hardware as a base. 33 | It may be used to provide some standard baseline Pushbot OpModes, or 34 | to demonstrate how a particular sensor or concept can be used directly on the 35 | Pushbot chassis. 36 | 37 | Concept: This is a sample OpMode that illustrates performing a specific function or concept. 38 | These may be complex, but their operation should be explained clearly in the comments, 39 | or the comments should reference an external doc, guide or tutorial. 40 | Each OpMode should try to only demonstrate a single concept so they are easy to 41 | locate based on their name. These OpModes may not produce a drivable robot. 42 | 43 | Library: This is a class, or set of classes used to implement some strategy. 44 | These will typically NOT implement a full OpMode. Instead they will be included 45 | by an OpMode to provide some stand-alone capability. 46 | 47 | After the prefix, other conventions will apply: 48 | 49 | * Sensor class names are constructed as: Sensor - Company - Type 50 | * Hardware class names are constructed as: Hardware - Robot type 51 | * Pushbot class names are constructed as: Pushbot - Mode - Action - OpModetype 52 | * Concept class names are constructed as: Concept - Topic - OpModetype 53 | * Library class names are constructed as: Library - Topic - OpModetype 54 | 55 | -------------------------------------------------------------------------------- /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 | A range of different samples classes will reside in the java/external/samples folder. 9 | 10 | For ease of understanding, the class names will follow a naming convention which indicates 11 | the purpose of each class. The prefix of the name will be one of the following: 12 | 13 | Basic: This is a minimally functional OpMode used to illustrate the skeleton/structure 14 | of a particular style of OpMode. These are bare bones Tank Drive examples. 15 | 16 | Sensor: This is a Sample OpMode that shows how to use a specific sensor. 17 | It is not intended to drive a functioning robot, it is simply showing the minimal code 18 | required to read and display the sensor values. 19 | 20 | Hardware: This is not an actual OpMode, but a helper class that is used to describe 21 | one particular robot's hardware configuration: eg: For the K9 or Pushbot. 22 | Look at any Pushbot sample to see how this can be used in an OpMode. 23 | Teams can copy one of these to create their own robot definition. 24 | 25 | Pushbot: This is a Sample OpMode that uses the Pushbot robot hardware as a base. 26 | It may be used to provide some standard baseline Pushbot opmodes, or 27 | to demonstrate how a particular sensor or concept can be used directly on the 28 | Pushbot chassis. 29 | 30 | Concept: This is a sample OpMode that illustrates performing a specific function or concept. 31 | These may be complex, but their operation should be explained clearly in the comments, 32 | or the comments should reference an external doc, guide or tutorial. 33 | Each OpMode should try to only demonstrate a single concept so they are easy to 34 | locate based on their name. 35 | 36 | Library: This is a class, or set of classes used to implement some strategy. 37 | These will typically NOT implement a full opmode. Instead they will be included 38 | by an OpMode to provide some stand-alone capability. 39 | 40 | After the prefix, other conventions will apply: 41 | 42 | * Sensor class names should constructed as: Sensor - Company - Type 43 | * Hardware class names should be constructed as: Hardware - Robot type 44 | * Pushbot class names should be constructed as: Pushbot - Mode - Action - OpModetype 45 | * Concept class names should be constructed as: Concept - Topic - OpModetype 46 | * Library class names should be constructed as: Library - Topic - OpModetype 47 | 48 | ### Sample OpMode Content/Style 49 | 50 | Code is formatted as per the Google Style Guide: 51 | 52 | https://google.github.io/styleguide/javaguide.html 53 | 54 | With “Sensor” and “Hardware” samples, the code should demonstrate the essential function, 55 | and not be embellished with too much additional “clever” code. If a sensor has special 56 | addressing needs, or has a variety of modes or outputs, these should be demonstrated as 57 | simply as possible. 58 | 59 | Special programming methods, or robot control techniques should be reserved for “Concept” Samples, 60 | and where possible, Samples should strive to only demonstrate a single concept, 61 | eg: State machine coding, or a User Menu system, and not combine them into a single “all inclusive” 62 | sample. This will prevent an “all inclusive” Sample being deleted just because one part of it 63 | becomes obsolete. 64 | 65 | ### Device Configuration Names 66 | 67 | The following device names are used in the external samples 68 | 69 | ** Motors: 70 | left_drive 71 | right_drive 72 | left_arm 73 | 74 | ** Servos: 75 | left_hand 76 | right_hand 77 | arm 78 | claw 79 | 80 | ** Sensors: 81 | sensor_color 82 | sensor_ir 83 | sensor_light 84 | sensor_ods 85 | sensor_range 86 | sensor_touch 87 | sensor_color_distance 88 | sensor_digital 89 | digin 90 | digout 91 | 92 | ** Localization: 93 | compass 94 | gyro 95 | imu 96 | navx 97 | 98 | ### Device Object Names 99 | 100 | Device Object names should use the same words as the device’s configuration name, but they 101 | should be re-structured to be a suitable Java variable name. This should keep the same word order, 102 | but adopt the style of beginning with a lower case letter, and then each subsequent word 103 | starting with an upper case letter. 104 | 105 | Eg: from the examples above: tool, leftMotor, rightClawServo, rearLightSensor. 106 | 107 | Note: Sometimes it’s helpful to put the device type first, followed by the variant. 108 | eg: motorLeft and motorRight, but this should only be done if the same word order 109 | is used on the device configuration name. 110 | 111 | ### OpMode code Comments 112 | 113 | Sample comments should read like normal code comments, that is, as an explanation of what the 114 | sample code is doing. They should NOT be directives to the user, 115 | like: “insert your joystick code here” as these comments typically aren’t 116 | detailed enough to be useful. They also often get left in the code and become garbage. 117 | 118 | Instead, an example of the joystick code should be shown with a comment describing what it is doing. 119 | -------------------------------------------------------------------------------- /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 | import org.firstinspires.ftc.robotcontroller.external.samples.ConceptNullOp; 38 | 39 | /** 40 | * {@link FtcOpModeRegister} is responsible for registering opmodes for use in an FTC game. 41 | * @see #register(OpModeManager) 42 | */ 43 | public class FtcOpModeRegister implements OpModeRegister { 44 | 45 | /** 46 | * {@link #register(OpModeManager)} is called by the SDK game in order to register 47 | * OpMode classes or instances that will participate in an FTC game. 48 | * 49 | * There are two mechanisms by which an OpMode may be registered. 50 | * 51 | * 1) The preferred method is by means of class annotations in the OpMode itself. 52 | * See, for example the class annotations in {@link ConceptNullOp}. 53 | * 54 | * 2) The other, retired, method is to modify this {@link #register(OpModeManager)} 55 | * method to include explicit calls to OpModeManager.register(). 56 | * This method of modifying this file directly is discouraged, as it 57 | * makes updates to the SDK harder to integrate into your code. 58 | * 59 | * @param manager the object which contains methods for carrying out OpMode registrations 60 | * 61 | * @see com.qualcomm.robotcore.eventloop.opmode.TeleOp 62 | * @see com.qualcomm.robotcore.eventloop.opmode.Autonomous 63 | */ 64 | public void register(OpModeManager manager) { 65 | 66 | /** 67 | * Any manual OpMode class registrations should go here. 68 | */ 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /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-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /FtcRobotController/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /FtcRobotController/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /FtcRobotController/src/main/res/drawable-xhdpi/icon_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/res/drawable-xhdpi/icon_menu.png -------------------------------------------------------------------------------- /FtcRobotController/src/main/res/drawable-xhdpi/icon_robotcontroller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/res/drawable-xhdpi/icon_robotcontroller.png -------------------------------------------------------------------------------- /FtcRobotController/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /FtcRobotController/src/main/res/menu/ftc_robot_controller.xml: -------------------------------------------------------------------------------- 1 | 33 | 34 | 35 | 36 | 41 | 46 | 47 | 52 | 53 | 58 | 59 | 64 | 65 | 70 | 71 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/res/raw/gold.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/res/raw/gold.wav -------------------------------------------------------------------------------- /FtcRobotController/src/main/res/raw/silver.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/FtcRobotController/src/main/res/raw/silver.wav -------------------------------------------------------------------------------- /FtcRobotController/src/main/res/values-sw600dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 33 | 34 | 35 | 36 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/res/values-sw720dp-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 33 | 34 | 35 | 36 | 40 | 128dp 41 | 42 | 43 | -------------------------------------------------------------------------------- /FtcRobotController/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 33 | 34 | 35 | 38 | 64dp 39 | 40 | -------------------------------------------------------------------------------- /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 | @string/packageNameRobotController 69 | 70 | 71 | -------------------------------------------------------------------------------- /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 | 44 | 46 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Road Runner FTCLib Quickstart (CURRENTLY IN PRODUCTION) 2 | 3 | An example FTC project using [Road Runner](https://github.com/acmerobotics/road-runner) with a dependency for [FTCLib](https://www.github.com/FTCLib/FTCLib) to set up a command-based project. 4 | 5 | ## Installation 6 | 7 | For more detailed instructions on getting Road Runner setup in your own project, see the [Road Runner README](https://github.com/acmerobotics/road-runner#core). 8 | 9 | 1. Download or clone this repo with `git clone https://github.com/FTCLib/RoadRunner-FTCLib-Quickstart.git`. 10 | 11 | 1. Open the project in Android Studio and build `TeamCode` like any other `ftc_app` project. 12 | 13 | 1. If you have trouble with multidex, enable proguard by changing `useProguard` to `true` in `build.common.gradle`. 14 | 15 | ## Documentation 16 | 17 | Check out the new [online quickstart documentation](https://acme-robotics.gitbook.io/road-runner/quickstart/introduction). 18 | 19 | Unofficially, there is also [LearnRoadRunner](https://www.learnroadrunner.com/) made by Noah. It's a great guide for getting started with the quickstart! 20 | 21 | For documentation on command-based for FTCLib, check out [this link](https://docs.ftclib.org/ftclib/command-base/command-system) to the gitbook. 22 | -------------------------------------------------------------------------------- /TeamCode/LICENSE: -------------------------------------------------------------------------------- 1 | License information 2 | 3 | ================================================================================ 4 | TeamCode has the following license: 5 | 6 | MIT License 7 | 8 | Copyright (c) 2018 ACME Robotics 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. -------------------------------------------------------------------------------- /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 | 17 | repositories { 18 | maven { url = "https://dl.bintray.com/first-tech-challenge/ftcsdk/" } 19 | } 20 | 21 | dependencies { 22 | annotationProcessor files('lib/OpModeAnnotationProcessor.jar') 23 | implementation 'com.arcrobotics:ftclib:1.1.6' 24 | } -------------------------------------------------------------------------------- /TeamCode/build.release.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(':FtcRobotController') 3 | implementation 'org.firstinspires.ftc:RobotCore:6.1.1' 4 | implementation 'org.firstinspires.ftc:Hardware:6.1.1' 5 | implementation 'org.firstinspires.ftc:FtcCommon:6.1.1' 6 | implementation (name: 'tfod-release', ext:'aar') 7 | implementation (name: 'tensorflow-lite-0.0.0-nightly', ext:'aar') 8 | 9 | implementation 'org.apache.commons:commons-math3:3.6.1' 10 | 11 | implementation 'com.acmerobotics.roadrunner:core:0.5.3' 12 | implementation 'com.acmerobotics.dashboard:dashboard:0.3.10' 13 | } 14 | -------------------------------------------------------------------------------- /TeamCode/lib/OpModeAnnotationProcessor.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/TeamCode/lib/OpModeAnnotationProcessor.jar -------------------------------------------------------------------------------- /TeamCode/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Avoid touching the FTC SDK 2 | -keep class com.qualcomm.** {*;} 3 | -keep class org.firstinspires.** {*;} 4 | -keep class com.google.** {*;} 5 | -keep class com.vuforia.** {*;} 6 | -keep class org.tensorflow.** {*;} 7 | -keep class javax.** {*;} # this is apparently required 8 | 9 | -dontwarn com.qualcomm.** 10 | -dontwarn org.firstinspires.** 11 | -dontwarn com.vuforia.** 12 | -dontwarn com.sun.** 13 | -dontwarn org.tensorflow.** 14 | 15 | # Op modes 16 | -keep public class * extends com.qualcomm.robotcore.eventloop.opmode.OpMode 17 | 18 | # Kotlin 19 | -dontwarn kotlin.** 20 | 21 | # ACME libs 22 | # this keep is actually required for serialization 23 | -keep class com.acmerobotics.** {*;} 24 | -dontwarn com.acmerobotics.** 25 | 26 | # Other deps 27 | -dontwarn com.fasterxml.** 28 | -dontwarn org.yaml.** 29 | -dontwarn org.apache.** 30 | -dontwarn com.google.gson.** 31 | 32 | # Misc 33 | -dontnote ** -------------------------------------------------------------------------------- /TeamCode/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/MecanumDriveCommand.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.commands; 2 | 3 | import com.arcrobotics.ftclib.command.CommandBase; 4 | 5 | import org.firstinspires.ftc.teamcode.subsystems.MecanumDriveSubsystem; 6 | 7 | import java.util.function.DoubleSupplier; 8 | 9 | public class MecanumDriveCommand extends CommandBase { 10 | 11 | private final MecanumDriveSubsystem drive; 12 | private final DoubleSupplier leftY, leftX, rightX; 13 | 14 | public MecanumDriveCommand(MecanumDriveSubsystem drive, DoubleSupplier leftY, 15 | DoubleSupplier leftX, DoubleSupplier rightX) { 16 | this.drive = drive; 17 | this.leftX = leftX; 18 | this.leftY = leftY; 19 | this.rightX = rightX; 20 | 21 | addRequirements(drive); 22 | } 23 | 24 | @Override 25 | public void execute() { 26 | drive.drive(leftY.getAsDouble(), leftX.getAsDouble(), rightX.getAsDouble()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/RunCommand.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.commands; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.arcrobotics.ftclib.command.CommandBase; 6 | import com.arcrobotics.ftclib.command.Subsystem; 7 | 8 | public class RunCommand extends CommandBase { 9 | 10 | protected final Runnable m_toRun; 11 | 12 | /** 13 | * Creates a new RunCommand. The Runnable will be run continuously until the command 14 | * ends. Does not run when disabled. 15 | * 16 | * @param toRun the Runnable to run 17 | * @param requirements the subsystems to require 18 | */ 19 | public RunCommand(@NonNull Runnable toRun, Subsystem... requirements) { 20 | m_toRun = toRun; 21 | addRequirements(requirements); 22 | } 23 | 24 | @Override 25 | public void execute() { 26 | m_toRun.run(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/TrajectoryFollowerCommand.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.commands; 2 | 3 | import com.acmerobotics.roadrunner.trajectory.Trajectory; 4 | import com.arcrobotics.ftclib.command.CommandBase; 5 | 6 | import org.firstinspires.ftc.teamcode.subsystems.MecanumDriveSubsystem; 7 | 8 | public class TrajectoryFollowerCommand extends CommandBase { 9 | 10 | private final MecanumDriveSubsystem drive; 11 | private final Trajectory trajectory; 12 | 13 | public TrajectoryFollowerCommand(MecanumDriveSubsystem drive, Trajectory trajectory) { 14 | this.drive = drive; 15 | this.trajectory = trajectory; 16 | 17 | addRequirements(drive); 18 | } 19 | 20 | @Override 21 | public void initialize() { 22 | drive.followTrajectory(trajectory); 23 | } 24 | 25 | @Override 26 | public void execute() { 27 | drive.update(); 28 | } 29 | 30 | @Override 31 | public void end(boolean interrupted) { 32 | if (interrupted) { 33 | drive.stop(); 34 | } 35 | } 36 | 37 | @Override 38 | public boolean isFinished() { 39 | return Thread.currentThread().isInterrupted() || !drive.isBusy(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/commands/TurnCommand.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.commands; 2 | 3 | import com.arcrobotics.ftclib.command.CommandBase; 4 | 5 | import org.firstinspires.ftc.teamcode.subsystems.MecanumDriveSubsystem; 6 | 7 | public class TurnCommand extends CommandBase { 8 | 9 | private final MecanumDriveSubsystem drive; 10 | private final double angle; 11 | 12 | public TurnCommand(MecanumDriveSubsystem drive, double angle) { 13 | this.drive = drive; 14 | this.angle = angle; 15 | 16 | addRequirements(drive); 17 | } 18 | 19 | @Override 20 | public void initialize() { 21 | drive.turn(angle); 22 | } 23 | 24 | @Override 25 | public void execute() { 26 | drive.update(); 27 | } 28 | 29 | @Override 30 | public void end(boolean interrupted) { 31 | if (interrupted) { 32 | drive.stop(); 33 | } 34 | } 35 | 36 | @Override 37 | public boolean isFinished() { 38 | return Thread.currentThread().isInterrupted() || !drive.isBusy(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/DriveConstants.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.drive; 2 | 3 | import com.acmerobotics.dashboard.config.Config; 4 | import com.qualcomm.robotcore.hardware.PIDFCoefficients; 5 | 6 | /* 7 | * Constants shared between multiple drive types. 8 | * 9 | * TODO: Tune or adjust the following constants to fit your robot. Note that the non-final 10 | * fields may also be edited through the dashboard (connect to the robot's WiFi network and 11 | * navigate to https://192.168.49.1:8080/dash). Make sure to save the values here after you 12 | * adjust them in the dashboard; **config variable changes don't persist between app restarts**. 13 | * 14 | * These are not the only parameters; some are located in the localizer classes, drive base classes, 15 | * and op modes themselves. 16 | */ 17 | @Config 18 | public class DriveConstants { 19 | 20 | /* 21 | * These are motor constants that should be listed online for your motors. 22 | */ 23 | public static final double TICKS_PER_REV = 1; 24 | public static final double MAX_RPM = 1; 25 | 26 | /* 27 | * Set RUN_USING_ENCODER to true to enable built-in hub velocity control using drive encoders. 28 | * Set this flag to false if drive encoders are not present and an alternative localization 29 | * method is in use (e.g., tracking wheels). 30 | * 31 | * If using the built-in motor velocity PID, update MOTOR_VELO_PID with the tuned coefficients 32 | * from DriveVelocityPIDTuner. 33 | */ 34 | public static final boolean RUN_USING_ENCODER = true; 35 | public static PIDFCoefficients MOTOR_VELO_PID = new PIDFCoefficients(0, 0, 0, 36 | getMotorVelocityF(MAX_RPM / 60 * TICKS_PER_REV)); 37 | 38 | /* 39 | * These are physical constants that can be determined from your robot (including the track 40 | * width; it will be tune empirically later although a rough estimate is important). Users are 41 | * free to chose whichever linear distance unit they would like so long as it is consistently 42 | * used. The default values were selected with inches in mind. Road runner uses radians for 43 | * angular distances although most angular parameters are wrapped in Math.toRadians() for 44 | * convenience. Make sure to exclude any gear ratio included in MOTOR_CONFIG from GEAR_RATIO. 45 | */ 46 | public static double WHEEL_RADIUS = 2; // in 47 | public static double GEAR_RATIO = 1; // output (wheel) speed / input (motor) speed 48 | public static double TRACK_WIDTH = 1; // in 49 | 50 | /* 51 | * These are the feedforward parameters used to model the drive motor behavior. If you are using 52 | * the built-in velocity PID, *these values are fine as is*. However, if you do not have drive 53 | * motor encoders or have elected not to use them for velocity control, these values should be 54 | * empirically tuned. 55 | */ 56 | public static double kV = 1.0 / rpmToVelocity(MAX_RPM); 57 | public static double kA = 0; 58 | public static double kStatic = 0; 59 | 60 | /* 61 | * These values are used to generate the trajectories for you robot. To ensure proper operation, 62 | * the constraints should never exceed ~80% of the robot's actual capabilities. While Road 63 | * Runner is designed to enable faster autonomous motion, it is a good idea for testing to start 64 | * small and gradually increase them later after everything is working. All distance units are 65 | * inches. 66 | */ 67 | public static double MAX_VEL = 30; 68 | public static double MAX_ACCEL = 30; 69 | public static double MAX_ANG_VEL = Math.toRadians(180); 70 | public static double MAX_ANG_ACCEL = Math.toRadians(180); 71 | 72 | 73 | public static double encoderTicksToInches(double ticks) { 74 | return WHEEL_RADIUS * 2 * Math.PI * GEAR_RATIO * ticks / TICKS_PER_REV; 75 | } 76 | 77 | public static double rpmToVelocity(double rpm) { 78 | return rpm * GEAR_RATIO * 2 * Math.PI * WHEEL_RADIUS / 60.0; 79 | } 80 | 81 | public static double getMotorVelocityF(double ticksPerSecond) { 82 | // see https://docs.google.com/document/d/1tyWrXDfMidwYyP_5H4mZyVgaEswhOC35gvdmP-V-5hA/edit#heading=h.61g9ixenznbx 83 | return 32767 / ticksPerSecond; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/StandardTrackingWheelLocalizer.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.drive; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.acmerobotics.dashboard.config.Config; 6 | import com.acmerobotics.roadrunner.geometry.Pose2d; 7 | import com.acmerobotics.roadrunner.localization.ThreeTrackingWheelLocalizer; 8 | import com.qualcomm.robotcore.hardware.DcMotorEx; 9 | import com.qualcomm.robotcore.hardware.HardwareMap; 10 | 11 | import org.firstinspires.ftc.teamcode.util.Encoder; 12 | 13 | import java.util.Arrays; 14 | import java.util.List; 15 | 16 | /* 17 | * Sample tracking wheel localizer implementation assuming the standard configuration: 18 | * 19 | * /--------------\ 20 | * | ____ | 21 | * | ---- | 22 | * | || || | 23 | * | || || | 24 | * | | 25 | * | | 26 | * \--------------/ 27 | * 28 | */ 29 | @Config 30 | public class StandardTrackingWheelLocalizer extends ThreeTrackingWheelLocalizer { 31 | public static double TICKS_PER_REV = 0; 32 | public static double WHEEL_RADIUS = 2; // in 33 | public static double GEAR_RATIO = 1; // output (wheel) speed / input (encoder) speed 34 | 35 | public static double LATERAL_DISTANCE = 10; // in; distance between the left and right wheels 36 | public static double FORWARD_OFFSET = 4; // in; offset of the lateral wheel 37 | 38 | private Encoder leftEncoder, rightEncoder, frontEncoder; 39 | 40 | public StandardTrackingWheelLocalizer(HardwareMap hardwareMap) { 41 | super(Arrays.asList( 42 | new Pose2d(0, LATERAL_DISTANCE / 2, 0), // left 43 | new Pose2d(0, -LATERAL_DISTANCE / 2, 0), // right 44 | new Pose2d(FORWARD_OFFSET, 0, Math.toRadians(90)) // front 45 | )); 46 | 47 | leftEncoder = new Encoder(hardwareMap.get(DcMotorEx.class, "leftEncoder")); 48 | rightEncoder = new Encoder(hardwareMap.get(DcMotorEx.class, "rightEncoder")); 49 | frontEncoder = new Encoder(hardwareMap.get(DcMotorEx.class, "frontEncoder")); 50 | 51 | // TODO: reverse any encoders using Encoder.setDirection(Encoder.Direction.REVERSE) 52 | } 53 | 54 | public static double encoderTicksToInches(double ticks) { 55 | return WHEEL_RADIUS * 2 * Math.PI * GEAR_RATIO * ticks / TICKS_PER_REV; 56 | } 57 | 58 | @NonNull 59 | @Override 60 | public List getWheelPositions() { 61 | return Arrays.asList( 62 | encoderTicksToInches(leftEncoder.getCurrentPosition()), 63 | encoderTicksToInches(rightEncoder.getCurrentPosition()), 64 | encoderTicksToInches(frontEncoder.getCurrentPosition()) 65 | ); 66 | } 67 | 68 | @NonNull 69 | @Override 70 | public List getWheelVelocities() { 71 | // TODO: If your encoder velocity can exceed 32767 counts / second (such as the REV Through Bore and other 72 | // competing magnetic encoders), change Encoder.getRawVelocity() to Encoder.getCorrectedVelocity() to enable a 73 | // compensation method 74 | 75 | return Arrays.asList( 76 | encoderTicksToInches(leftEncoder.getRawVelocity()), 77 | encoderTicksToInches(rightEncoder.getRawVelocity()), 78 | encoderTicksToInches(frontEncoder.getRawVelocity()) 79 | ); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/opmode/BackAndForth.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.drive.opmode; 2 | 3 | import com.acmerobotics.dashboard.config.Config; 4 | import com.acmerobotics.roadrunner.geometry.Pose2d; 5 | import com.acmerobotics.roadrunner.trajectory.Trajectory; 6 | import com.arcrobotics.ftclib.command.CommandOpMode; 7 | import com.arcrobotics.ftclib.command.SequentialCommandGroup; 8 | import com.qualcomm.robotcore.eventloop.opmode.Autonomous; 9 | 10 | import org.firstinspires.ftc.teamcode.commands.RunCommand; 11 | import org.firstinspires.ftc.teamcode.commands.TrajectoryFollowerCommand; 12 | import org.firstinspires.ftc.teamcode.drive.SampleMecanumDrive; 13 | import org.firstinspires.ftc.teamcode.subsystems.MecanumDriveSubsystem; 14 | 15 | /** 16 | * Op mode for preliminary tuning of the follower PID coefficients (located in the drive base 17 | * classes). The robot drives back and forth in a straight line indefinitely. Utilization of the 18 | * dashboard is recommended for this tuning routine. To access the dashboard, connect your computer 19 | * to the RC's WiFi network. In your browser, navigate to https://192.168.49.1:8080/dash if you're 20 | * using the RC phone or https://192.168.43.1:8080/dash if you are using the Control Hub. Once 21 | * you've successfully connected, start the program, and your robot will begin moving forward and 22 | * backward. You should observe the target position (green) and your pose estimate (blue) and adjust 23 | * your follower PID coefficients such that you follow the target position as accurately as possible. 24 | * If you are using SampleMecanumDrive, you should be tuning TRANSLATIONAL_PID and HEADING_PID. 25 | * If you are using SampleTankDrive, you should be tuning AXIAL_PID, CROSS_TRACK_PID, and HEADING_PID. 26 | * These coefficients can be tuned live in dashboard. 27 | * 28 | * This opmode is designed as a convenient, coarse tuning for the follower PID coefficients. It 29 | * is recommended that you use the FollowerPIDTuner opmode for further fine tuning. 30 | * 31 | * NOTE: this has been refactored to use FTCLib's command-based 32 | */ 33 | @Config 34 | @Autonomous(group = "drive") 35 | public class BackAndForth extends CommandOpMode { 36 | 37 | public static double DISTANCE = 50; 38 | 39 | private MecanumDriveSubsystem drive; 40 | private TrajectoryFollowerCommand forwardFollower, backwardFollower; 41 | 42 | @Override 43 | public void initialize() { 44 | drive = new MecanumDriveSubsystem(new SampleMecanumDrive(hardwareMap), false); 45 | Trajectory forwardTrajectory = drive.trajectoryBuilder(new Pose2d()) 46 | .forward(DISTANCE) 47 | .build(); 48 | forwardFollower = new TrajectoryFollowerCommand(drive, forwardTrajectory); 49 | backwardFollower = new TrajectoryFollowerCommand(drive, 50 | drive.trajectoryBuilder(forwardTrajectory.end()) 51 | .back(DISTANCE) 52 | .build() 53 | ); 54 | SequentialCommandGroup backAndForthCommand = new SequentialCommandGroup(forwardFollower, backwardFollower); 55 | schedule(new RunCommand(() -> { 56 | if (backAndForthCommand.isFinished() || !backAndForthCommand.isScheduled()) { 57 | backAndForthCommand.schedule(); 58 | } 59 | })); 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/opmode/FieldCentricTest.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.drive.opmode; 2 | 3 | import com.acmerobotics.dashboard.config.Config; 4 | import com.arcrobotics.ftclib.command.CommandOpMode; 5 | import com.arcrobotics.ftclib.gamepad.GamepadEx; 6 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp; 7 | 8 | import org.firstinspires.ftc.teamcode.commands.MecanumDriveCommand; 9 | import org.firstinspires.ftc.teamcode.commands.RunCommand; 10 | import org.firstinspires.ftc.teamcode.drive.SampleMecanumDrive; 11 | import org.firstinspires.ftc.teamcode.subsystems.MecanumDriveSubsystem; 12 | 13 | /** 14 | * This is an additional test made specifically for FTCLib's quickstart. 15 | * It tests the field-centric mode of the {@link MecanumDriveSubsystem}. 16 | * The robot should always drive in the direction in which the left stick is 17 | * being pushed. This should be run after your {@link LocalizationTest} 18 | * to ensure proper tuning for the localization's heading estimate. 19 | * 20 | * @author Jackson 21 | */ 22 | @Config 23 | @TeleOp 24 | public class FieldCentricTest extends CommandOpMode { 25 | 26 | private GamepadEx gamepad; 27 | private MecanumDriveSubsystem drive; 28 | 29 | @Override 30 | public void initialize() { 31 | gamepad = new GamepadEx(gamepad1); 32 | 33 | drive = new MecanumDriveSubsystem(new SampleMecanumDrive(hardwareMap), true); 34 | 35 | register(drive); 36 | drive.setDefaultCommand(new MecanumDriveCommand( 37 | drive, () -> -gamepad.getLeftY(), gamepad::getLeftX, gamepad::getRightX 38 | )); 39 | 40 | schedule(new RunCommand(() -> { 41 | drive.update(); 42 | telemetry.addData("Heading", drive.getPoseEstimate().getHeading()); 43 | telemetry.update(); 44 | })); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/opmode/FollowerPIDTuner.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.drive.opmode; 2 | 3 | import com.acmerobotics.dashboard.config.Config; 4 | import com.acmerobotics.roadrunner.geometry.Pose2d; 5 | import com.acmerobotics.roadrunner.trajectory.Trajectory; 6 | import com.arcrobotics.ftclib.command.Command; 7 | import com.arcrobotics.ftclib.command.CommandOpMode; 8 | import com.arcrobotics.ftclib.command.SequentialCommandGroup; 9 | import com.qualcomm.robotcore.eventloop.opmode.Autonomous; 10 | 11 | import org.firstinspires.ftc.teamcode.commands.RunCommand; 12 | import org.firstinspires.ftc.teamcode.commands.TrajectoryFollowerCommand; 13 | import org.firstinspires.ftc.teamcode.commands.TurnCommand; 14 | import org.firstinspires.ftc.teamcode.drive.SampleMecanumDrive; 15 | import org.firstinspires.ftc.teamcode.subsystems.MecanumDriveSubsystem; 16 | 17 | /** 18 | * Op mode for preliminary tuning of the follower PID coefficients (located in the drive base 19 | * classes). The robot drives in a DISTANCE-by-DISTANCE square indefinitely. Utilization of the 20 | * dashboard is recommended for this tuning routine. To access the dashboard, connect your computer 21 | * to the RC's WiFi network. In your browser, navigate to https://192.168.49.1:8080/dash if you're 22 | * using the RC phone or https://192.168.43.1:8080/dash if you are using the Control Hub. Once 23 | * you've successfully connected, start the program, and your robot will begin driving in a square. 24 | * You should observe the target position (green) and your pose estimate (blue) and adjust your 25 | * follower PID coefficients such that you follow the target position as accurately as possible. 26 | * If you are using SampleMecanumDrive, you should be tuning TRANSLATIONAL_PID and HEADING_PID. 27 | * If you are using SampleTankDrive, you should be tuning AXIAL_PID, CROSS_TRACK_PID, and HEADING_PID. 28 | * These coefficients can be tuned live in dashboard. 29 | * 30 | * NOTE: this has been refactored to use FTCLib's command-based 31 | */ 32 | @Config 33 | @Autonomous(group = "drive") 34 | public class FollowerPIDTuner extends CommandOpMode { 35 | 36 | public static double DISTANCE = 48; // in 37 | 38 | private MecanumDriveSubsystem drive; 39 | private TrajectoryFollowerCommand followerCommand; 40 | private Command trajGroup; 41 | private TurnCommand turnCommand; 42 | private Pose2d startPose; 43 | 44 | @Override 45 | public void initialize() { 46 | drive = new MecanumDriveSubsystem(new SampleMecanumDrive(hardwareMap), false); 47 | 48 | startPose = new Pose2d(-DISTANCE / 2, -DISTANCE / 2, 0); 49 | 50 | drive.setPoseEstimate(startPose); 51 | 52 | schedule(new RunCommand(() -> { 53 | if (trajGroup == null || trajGroup.isFinished() || !trajGroup.isScheduled()) { 54 | Trajectory traj = drive.trajectoryBuilder(startPose) 55 | .forward(DISTANCE) 56 | .build(); 57 | followerCommand = new TrajectoryFollowerCommand(drive, traj); 58 | turnCommand = new TurnCommand(drive, Math.toRadians(90)); 59 | trajGroup = new SequentialCommandGroup(followerCommand, turnCommand) 60 | .whenFinished(() -> startPose = traj.end().plus(new Pose2d(0, 0, Math.toRadians(90)))); 61 | trajGroup.schedule(); 62 | } 63 | })); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/opmode/LocalizationTest.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.drive.opmode; 2 | 3 | import com.acmerobotics.roadrunner.geometry.Pose2d; 4 | import com.arcrobotics.ftclib.command.CommandOpMode; 5 | import com.arcrobotics.ftclib.command.PerpetualCommand; 6 | import com.arcrobotics.ftclib.gamepad.GamepadEx; 7 | import com.qualcomm.robotcore.eventloop.opmode.TeleOp; 8 | 9 | import org.firstinspires.ftc.teamcode.commands.MecanumDriveCommand; 10 | import org.firstinspires.ftc.teamcode.commands.RunCommand; 11 | import org.firstinspires.ftc.teamcode.drive.SampleMecanumDrive; 12 | import org.firstinspires.ftc.teamcode.subsystems.MecanumDriveSubsystem; 13 | 14 | /** 15 | * This is a simple teleop routine for testing localization. Drive the robot around like a normal 16 | * teleop routine and make sure the robot's estimated pose matches the robot's actual pose (slight 17 | * errors are not out of the ordinary, especially with sudden drive motions). The goal of this 18 | * exercise is to ascertain whether the localizer has been configured properly (note: the pure 19 | * encoder localizer heading may be significantly off if the track width has not been tuned). 20 | * 21 | * NOTE: this has been refactored to use FTCLib's command-based 22 | */ 23 | @TeleOp(group = "drive") 24 | public class LocalizationTest extends CommandOpMode { 25 | 26 | private MecanumDriveSubsystem drive; 27 | private MecanumDriveCommand driveCommand; 28 | private GamepadEx gamepad; 29 | 30 | @Override 31 | public void initialize() { 32 | drive = new MecanumDriveSubsystem(new SampleMecanumDrive(hardwareMap), false); 33 | 34 | gamepad = new GamepadEx(gamepad1); 35 | 36 | schedule(new RunCommand(() -> { 37 | drive.update(); 38 | Pose2d poseEstimate = drive.getPoseEstimate(); 39 | telemetry.addData("x", poseEstimate.getX()); 40 | telemetry.addData("y", poseEstimate.getY()); 41 | telemetry.addData("heading", poseEstimate.getHeading()); 42 | telemetry.update(); 43 | })); 44 | 45 | driveCommand = new MecanumDriveCommand( 46 | drive, () -> -gamepad.getLeftY(), 47 | gamepad::getLeftX, gamepad::getRightX 48 | ); 49 | 50 | schedule(driveCommand); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/opmode/MaxVelocityTuner.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.drive.opmode; 2 | 3 | import com.acmerobotics.dashboard.config.Config; 4 | import com.acmerobotics.roadrunner.geometry.Pose2d; 5 | import com.arcrobotics.ftclib.command.CommandOpMode; 6 | import com.arcrobotics.ftclib.command.InstantCommand; 7 | import com.arcrobotics.ftclib.command.WaitUntilCommand; 8 | import com.qualcomm.robotcore.eventloop.opmode.Autonomous; 9 | import com.qualcomm.robotcore.hardware.VoltageSensor; 10 | import com.qualcomm.robotcore.util.ElapsedTime; 11 | 12 | import org.firstinspires.ftc.teamcode.commands.RunCommand; 13 | import org.firstinspires.ftc.teamcode.drive.DriveConstants; 14 | import org.firstinspires.ftc.teamcode.drive.SampleMecanumDrive; 15 | import org.firstinspires.ftc.teamcode.subsystems.MecanumDriveSubsystem; 16 | 17 | import java.util.Objects; 18 | 19 | /** 20 | * This routine is designed to calculate the maximum velocity your bot can achieve under load. It 21 | * will also calculate the effective kF value for your velocity PID. 22 | *

23 | * Upon pressing start, your bot will run at max power for RUNTIME seconds. 24 | *

25 | * Further fine tuning of kF may be desired. 26 | * 27 | * NOTE: this has been refactored to use FTCLib's command-based 28 | */ 29 | @Config 30 | @Autonomous(group = "drive") 31 | public class MaxVelocityTuner extends CommandOpMode { 32 | 33 | public static double RUNTIME = 2.0; 34 | 35 | private ElapsedTime timer = new ElapsedTime(); 36 | private double maxVelocity = 0.0; 37 | 38 | private VoltageSensor batteryVoltageSensor; 39 | 40 | private MecanumDriveSubsystem drive; 41 | 42 | @Override 43 | public void initialize() { 44 | drive = new MecanumDriveSubsystem(new SampleMecanumDrive(hardwareMap), false); 45 | batteryVoltageSensor = hardwareMap.voltageSensor.iterator().next(); 46 | 47 | telemetry.addLine("Your bot will go at full speed for " + RUNTIME + " seconds."); 48 | telemetry.addLine("Please ensure you have enough space cleared."); 49 | telemetry.addLine(""); 50 | telemetry.addLine("Press start when ready."); 51 | telemetry.update(); 52 | 53 | schedule(new WaitUntilCommand(this::isStarted) 54 | .whenFinished(() -> { 55 | telemetry.clearAll(); 56 | telemetry.update(); 57 | 58 | drive.setDrivePower(new Pose2d(1, 0, 0)); 59 | timer.reset(); 60 | }) 61 | ); 62 | 63 | RunCommand runCommand = new RunCommand(() -> { 64 | drive.update(); 65 | 66 | Pose2d poseVelo = Objects.requireNonNull( 67 | drive.getPoseVelocity(), 68 | "poseVelocity() must not be null. " + 69 | "Ensure that the getWheelVelocities() method has been overridden in your localizer." 70 | ); 71 | 72 | maxVelocity = Math.max(poseVelo.vec().norm(), maxVelocity); 73 | }); 74 | 75 | schedule(new WaitUntilCommand(() -> timer.seconds() >= RUNTIME) 76 | .deadlineWith(runCommand) 77 | .whenFinished(() -> { 78 | drive.setDrivePower(new Pose2d()); 79 | 80 | double effectiveKf = DriveConstants.getMotorVelocityF(veloInchesToTicks(maxVelocity)); 81 | 82 | telemetry.addData("Max Velocity", maxVelocity); 83 | telemetry.addData("Voltage Compensated kF", effectiveKf * batteryVoltageSensor.getVoltage() / 12); 84 | telemetry.update(); 85 | }) 86 | ); 87 | } 88 | 89 | private double veloInchesToTicks(double inchesPerSec) { 90 | return inchesPerSec / (2 * Math.PI * DriveConstants.WHEEL_RADIUS) / DriveConstants.GEAR_RATIO * DriveConstants.TICKS_PER_REV; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/opmode/SplineTest.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.drive.opmode; 2 | 3 | import com.acmerobotics.roadrunner.geometry.Pose2d; 4 | import com.acmerobotics.roadrunner.geometry.Vector2d; 5 | import com.acmerobotics.roadrunner.trajectory.Trajectory; 6 | import com.arcrobotics.ftclib.command.CommandOpMode; 7 | import com.arcrobotics.ftclib.command.WaitCommand; 8 | import com.arcrobotics.ftclib.command.WaitUntilCommand; 9 | import com.qualcomm.robotcore.eventloop.opmode.Autonomous; 10 | 11 | import org.firstinspires.ftc.teamcode.commands.TrajectoryFollowerCommand; 12 | import org.firstinspires.ftc.teamcode.drive.SampleMecanumDrive; 13 | import org.firstinspires.ftc.teamcode.subsystems.MecanumDriveSubsystem; 14 | 15 | /** 16 | * This is an example of a more complex path to really test the tuning. 17 | * 18 | * NOTE: this has been refactored to use FTCLib's command-based 19 | */ 20 | @Autonomous(group = "drive") 21 | public class SplineTest extends CommandOpMode { 22 | 23 | private MecanumDriveSubsystem drive; 24 | private TrajectoryFollowerCommand splineFollower; 25 | 26 | @Override 27 | public void initialize() { 28 | drive = new MecanumDriveSubsystem(new SampleMecanumDrive(hardwareMap), false); 29 | Trajectory traj = drive.trajectoryBuilder(new Pose2d()) 30 | .splineTo(new Vector2d(30, 30), 0) 31 | .build(); 32 | splineFollower = new TrajectoryFollowerCommand(drive, traj); 33 | schedule(new WaitUntilCommand(this::isStarted).andThen( 34 | splineFollower.andThen(new WaitCommand(2000), 35 | new TrajectoryFollowerCommand(drive, 36 | drive.trajectoryBuilder(traj.end(), true) 37 | .splineTo(new Vector2d(0, 0), Math.toRadians(180)) 38 | .build() 39 | )) 40 | )); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/opmode/StrafeTest.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.drive.opmode; 2 | 3 | import com.acmerobotics.dashboard.config.Config; 4 | import com.acmerobotics.roadrunner.geometry.Pose2d; 5 | import com.arcrobotics.ftclib.command.CommandOpMode; 6 | import com.arcrobotics.ftclib.command.WaitUntilCommand; 7 | import com.qualcomm.robotcore.eventloop.opmode.Autonomous; 8 | 9 | import org.firstinspires.ftc.teamcode.commands.TrajectoryFollowerCommand; 10 | import org.firstinspires.ftc.teamcode.drive.SampleMecanumDrive; 11 | import org.firstinspires.ftc.teamcode.subsystems.MecanumDriveSubsystem; 12 | 13 | /** 14 | * This is a simple routine to test translational drive capabilities. 15 | * 16 | * NOTE: this has been refactored to use FTCLib's command-based 17 | */ 18 | @Config 19 | @Autonomous(group = "drive") 20 | public class StrafeTest extends CommandOpMode { 21 | 22 | public static double DISTANCE = 60; // in 23 | 24 | private MecanumDriveSubsystem drive; 25 | private TrajectoryFollowerCommand strafeFollower; 26 | 27 | @Override 28 | public void initialize() { 29 | drive = new MecanumDriveSubsystem(new SampleMecanumDrive(hardwareMap), false); 30 | strafeFollower = new TrajectoryFollowerCommand(drive, 31 | drive.trajectoryBuilder(new Pose2d()) 32 | .strafeRight(DISTANCE) 33 | .build() 34 | ); 35 | schedule(new WaitUntilCommand(this::isStarted).andThen(strafeFollower.whenFinished(() -> { 36 | Pose2d poseEstimate = drive.getPoseEstimate(); 37 | telemetry.addData("finalX", poseEstimate.getX()); 38 | telemetry.addData("finalY", poseEstimate.getY()); 39 | telemetry.addData("finalHeading", poseEstimate.getHeading()); 40 | telemetry.update(); 41 | }))); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/opmode/StraightTest.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.drive.opmode; 2 | 3 | import com.acmerobotics.dashboard.config.Config; 4 | import com.acmerobotics.roadrunner.geometry.Pose2d; 5 | import com.arcrobotics.ftclib.command.CommandOpMode; 6 | import com.arcrobotics.ftclib.command.WaitUntilCommand; 7 | import com.qualcomm.robotcore.eventloop.opmode.Autonomous; 8 | 9 | import org.firstinspires.ftc.teamcode.commands.TrajectoryFollowerCommand; 10 | import org.firstinspires.ftc.teamcode.drive.SampleMecanumDrive; 11 | import org.firstinspires.ftc.teamcode.subsystems.MecanumDriveSubsystem; 12 | 13 | /** 14 | * This is a simple routine to test translational drive capabilities. 15 | * 16 | * NOTE: this has been refactored to use FTCLib's command-based 17 | */ 18 | @Config 19 | @Autonomous(group = "drive") 20 | public class StraightTest extends CommandOpMode { 21 | 22 | public static double DISTANCE = 60; // in 23 | 24 | private MecanumDriveSubsystem drive; 25 | private TrajectoryFollowerCommand straightFollower; 26 | 27 | @Override 28 | public void initialize() { 29 | drive = new MecanumDriveSubsystem(new SampleMecanumDrive(hardwareMap), false); 30 | straightFollower = new TrajectoryFollowerCommand(drive, 31 | drive.trajectoryBuilder(new Pose2d()) 32 | .forward(DISTANCE) 33 | .build() 34 | ); 35 | schedule(new WaitUntilCommand(this::isStarted).andThen(straightFollower.whenFinished(() -> { 36 | Pose2d poseEstimate = drive.getPoseEstimate(); 37 | telemetry.addData("finalX", poseEstimate.getX()); 38 | telemetry.addData("finalY", poseEstimate.getY()); 39 | telemetry.addData("finalHeading", poseEstimate.getHeading()); 40 | telemetry.update(); 41 | }))); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/opmode/TrackWidthTuner.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.drive.opmode; 2 | 3 | import com.acmerobotics.dashboard.FtcDashboard; 4 | import com.acmerobotics.dashboard.config.Config; 5 | import com.acmerobotics.dashboard.telemetry.MultipleTelemetry; 6 | import com.acmerobotics.roadrunner.geometry.Pose2d; 7 | import com.acmerobotics.roadrunner.util.Angle; 8 | import com.arcrobotics.ftclib.command.CommandOpMode; 9 | import com.arcrobotics.ftclib.command.InstantCommand; 10 | import com.arcrobotics.ftclib.command.SequentialCommandGroup; 11 | import com.arcrobotics.ftclib.command.WaitUntilCommand; 12 | import com.qualcomm.robotcore.eventloop.opmode.Autonomous; 13 | import com.qualcomm.robotcore.util.MovingStatistics; 14 | 15 | import org.firstinspires.ftc.robotcore.internal.system.Misc; 16 | import org.firstinspires.ftc.teamcode.commands.RunCommand; 17 | import org.firstinspires.ftc.teamcode.commands.TurnCommand; 18 | import org.firstinspires.ftc.teamcode.drive.DriveConstants; 19 | import org.firstinspires.ftc.teamcode.drive.SampleMecanumDrive; 20 | import org.firstinspires.ftc.teamcode.subsystems.MecanumDriveSubsystem; 21 | 22 | /** 23 | * This routine determines the effective track width. The procedure works by executing a point turn 24 | * with a given angle and measuring the difference between that angle and the actual angle (as 25 | * indicated by an external IMU/gyro, track wheels, or some other localizer). The quotient 26 | * given angle / actual angle gives a multiplicative adjustment to the estimated track width 27 | * (effective track width = estimated track width * given angle / actual angle). The routine repeats 28 | * this procedure a few times and averages the values for additional accuracy. Note: a relatively 29 | * accurate track width estimate is important or else the angular constraints will be thrown off. 30 | * 31 | * NOTE: this has been refactored to use FTCLib's command-based 32 | */ 33 | @Config 34 | @Autonomous(group = "drive") 35 | public class TrackWidthTuner extends CommandOpMode { 36 | 37 | public static double ANGLE = 180; // deg 38 | public static int NUM_TRIALS = 5; 39 | public static int DELAY = 1000; // ms 40 | 41 | private MecanumDriveSubsystem drive; 42 | private MovingStatistics trackWidthStats; 43 | private TurnCommand turnCommand; 44 | private double headingAccumulator, lastHeading; 45 | private int trial; 46 | 47 | @Override 48 | public void initialize() { 49 | telemetry = new MultipleTelemetry(telemetry, FtcDashboard.getInstance().getTelemetry()); 50 | 51 | drive = new MecanumDriveSubsystem(new SampleMecanumDrive(hardwareMap), false); 52 | // TODO: if you haven't already, set the localizer to something that doesn't depend on 53 | // drive encoders for computing the heading 54 | 55 | turnCommand = new TurnCommand(drive, Math.toRadians(ANGLE)); 56 | 57 | telemetry.addLine("Press play to begin the track width tuner routine"); 58 | telemetry.addLine("Make sure your robot has enough clearance to turn smoothly"); 59 | telemetry.update(); 60 | 61 | SequentialCommandGroup setupCommand = new SequentialCommandGroup( 62 | new WaitUntilCommand(this::isStarted), 63 | new InstantCommand(() -> { 64 | telemetry.clearAll(); 65 | telemetry.addLine("Running..."); 66 | telemetry.update(); 67 | 68 | trackWidthStats = new MovingStatistics(NUM_TRIALS); 69 | trial = 0; 70 | } 71 | )); 72 | 73 | InstantCommand finishCommand = new InstantCommand(() -> { 74 | telemetry.clearAll(); 75 | telemetry.addLine("Tuning complete"); 76 | telemetry.addLine(Misc.formatInvariant("Effective track width = %.2f (SE = %.3f)", 77 | trackWidthStats.getMean(), 78 | trackWidthStats.getStandardDeviation() / Math.sqrt(NUM_TRIALS))); 79 | telemetry.update(); 80 | }); 81 | 82 | RunCommand tuneCommand = new RunCommand(() -> { 83 | if (trial < NUM_TRIALS && (turnCommand == null || !turnCommand.isScheduled())) { 84 | if (headingAccumulator != 0) { 85 | double trackWidth = DriveConstants.TRACK_WIDTH * Math.toRadians(ANGLE) / headingAccumulator; 86 | trackWidthStats.add(trackWidth); 87 | } 88 | 89 | sleep(DELAY); 90 | 91 | trial++; 92 | 93 | drive.setPoseEstimate(new Pose2d()); 94 | 95 | // it is important to handle heading wraparounds 96 | headingAccumulator = 0; 97 | lastHeading = 0; 98 | 99 | turnCommand = new TurnCommand(drive, Math.toRadians(ANGLE)); 100 | turnCommand.schedule(); 101 | } else { 102 | double heading = drive.getPoseEstimate().getHeading(); 103 | headingAccumulator += Angle.norm(heading - lastHeading); 104 | lastHeading = heading; 105 | } 106 | }); 107 | 108 | schedule(setupCommand.andThen( 109 | new WaitUntilCommand(() -> trial == NUM_TRIALS) 110 | .deadlineWith(tuneCommand) 111 | .whenFinished(turnCommand::cancel), 112 | finishCommand 113 | )); 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/opmode/TurnTest.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.drive.opmode; 2 | 3 | import com.acmerobotics.dashboard.config.Config; 4 | import com.acmerobotics.roadrunner.geometry.Pose2d; 5 | import com.arcrobotics.ftclib.command.CommandOpMode; 6 | import com.qualcomm.robotcore.eventloop.opmode.Autonomous; 7 | 8 | import org.firstinspires.ftc.teamcode.commands.TurnCommand; 9 | import org.firstinspires.ftc.teamcode.drive.SampleMecanumDrive; 10 | import org.firstinspires.ftc.teamcode.subsystems.MecanumDriveSubsystem; 11 | 12 | /** 13 | * This is a simple routine to test turning capabilities. 14 | * 15 | * NOTE: this has been refactored to use FTCLib's command-based 16 | */ 17 | @Config 18 | @Autonomous(group = "drive") 19 | public class TurnTest extends CommandOpMode { 20 | 21 | public static double ANGLE = 90; // deg 22 | 23 | private MecanumDriveSubsystem drive; 24 | private TurnCommand turnCommand; 25 | 26 | @Override 27 | public void initialize() { 28 | drive = new MecanumDriveSubsystem(new SampleMecanumDrive(hardwareMap), false); 29 | turnCommand = new TurnCommand(drive, Math.toRadians(ANGLE)); 30 | schedule(turnCommand.whenFinished(() -> { 31 | Pose2d poseEstimate = drive.getPoseEstimate(); 32 | telemetry.addData("finalX", poseEstimate.getX()); 33 | telemetry.addData("finalY", poseEstimate.getY()); 34 | telemetry.addData("finalHeading", poseEstimate.getHeading()); 35 | telemetry.update(); 36 | })); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/MecanumDriveSubsystem.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.subsystems; 2 | 3 | import com.acmerobotics.roadrunner.geometry.Pose2d; 4 | import com.acmerobotics.roadrunner.geometry.Vector2d; 5 | import com.acmerobotics.roadrunner.localization.Localizer; 6 | import com.acmerobotics.roadrunner.trajectory.Trajectory; 7 | import com.acmerobotics.roadrunner.trajectory.TrajectoryBuilder; 8 | import com.arcrobotics.ftclib.command.SubsystemBase; 9 | import com.qualcomm.robotcore.hardware.DcMotor; 10 | import com.qualcomm.robotcore.hardware.PIDFCoefficients; 11 | 12 | import org.firstinspires.ftc.teamcode.drive.SampleMecanumDrive; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * A subsystem that uses the {@link SampleMecanumDrive} class. 18 | * This periodically calls {@link SampleMecanumDrive#update()} which runs the internal 19 | * state machine for the mecanum drive. All movement/following is async to fit the paradigm. 20 | */ 21 | public class MecanumDriveSubsystem extends SubsystemBase { 22 | 23 | private final SampleMecanumDrive drive; 24 | private final boolean fieldCentric; 25 | 26 | public MecanumDriveSubsystem(SampleMecanumDrive drive, boolean isFieldCentric) { 27 | this.drive = drive; 28 | fieldCentric = isFieldCentric; 29 | } 30 | 31 | public void setMode(DcMotor.RunMode mode) { 32 | drive.setMode(mode); 33 | } 34 | 35 | public void setPIDFCoefficients(DcMotor.RunMode mode, PIDFCoefficients coefficients) { 36 | drive.setPIDFCoefficients(mode, coefficients); 37 | } 38 | 39 | public void setPoseEstimate(Pose2d pose) { 40 | drive.setPoseEstimate(pose); 41 | } 42 | 43 | public void update() { 44 | drive.update(); 45 | } 46 | 47 | public void updatePoseEstimate() { 48 | drive.updatePoseEstimate(); 49 | } 50 | 51 | public void drive(double leftY, double leftX, double rightX) { 52 | Pose2d poseEstimate = getPoseEstimate(); 53 | 54 | Vector2d input = new Vector2d(-leftY, -leftX).rotated( 55 | fieldCentric ? -poseEstimate.getHeading() : 0 56 | ); 57 | 58 | drive.setWeightedDrivePower( 59 | new Pose2d( 60 | input.getX(), 61 | input.getY(), 62 | -rightX 63 | ) 64 | ); 65 | } 66 | 67 | public void setDrivePower(Pose2d drivePower) { 68 | drive.setDrivePower(drivePower); 69 | } 70 | 71 | public Pose2d getPoseEstimate() { 72 | return drive.getPoseEstimate(); 73 | } 74 | 75 | public TrajectoryBuilder trajectoryBuilder(Pose2d startPose) { 76 | return drive.trajectoryBuilder(startPose); 77 | } 78 | 79 | public TrajectoryBuilder trajectoryBuilder(Pose2d startPose, boolean reversed) { 80 | return drive.trajectoryBuilder(startPose, reversed); 81 | } 82 | 83 | public TrajectoryBuilder trajectoryBuilder(Pose2d startPose, double startHeading) { 84 | return drive.trajectoryBuilder(startPose, startHeading); 85 | } 86 | 87 | public void followTrajectory(Trajectory trajectory) { 88 | drive.followTrajectoryAsync(trajectory); 89 | } 90 | 91 | public boolean isBusy() { 92 | return drive.isBusy(); 93 | } 94 | 95 | public void turn(double radians) { 96 | drive.turnAsync(radians); 97 | } 98 | 99 | public List getWheelVelocities() { 100 | return drive.getWheelVelocities(); 101 | } 102 | 103 | public void stop() { 104 | drive(0, 0, 0); 105 | } 106 | 107 | public Pose2d getPoseVelocity() { 108 | return drive.getPoseVelocity(); 109 | } 110 | 111 | public Localizer getLocalizer() { 112 | return drive.getLocalizer(); 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/AssetsTrajectoryManager.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.util; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | import com.acmerobotics.roadrunner.trajectory.Trajectory; 6 | import com.acmerobotics.roadrunner.trajectory.TrajectoryBuilder; 7 | import com.acmerobotics.roadrunner.trajectory.config.TrajectoryConfig; 8 | import com.acmerobotics.roadrunner.trajectory.config.TrajectoryConfigManager; 9 | import com.acmerobotics.roadrunner.trajectory.config.TrajectoryGroupConfig; 10 | 11 | import org.firstinspires.ftc.robotcore.internal.system.AppUtil; 12 | 13 | import java.io.IOException; 14 | import java.io.InputStream; 15 | 16 | /** 17 | * Set of utilities for loading trajectories from assets (the plugin save location). 18 | */ 19 | public class AssetsTrajectoryManager { 20 | 21 | /** 22 | * Loads the group config. 23 | */ 24 | public static @Nullable 25 | TrajectoryGroupConfig loadGroupConfig() { 26 | try { 27 | InputStream inputStream = AppUtil.getDefContext().getAssets().open( 28 | "trajectory/" + TrajectoryConfigManager.GROUP_FILENAME); 29 | return TrajectoryConfigManager.loadGroupConfig(inputStream); 30 | } catch (IOException e) { 31 | return null; 32 | } 33 | } 34 | 35 | /** 36 | * Loads a trajectory config with the given name. 37 | */ 38 | public static @Nullable TrajectoryConfig loadConfig(String name) { 39 | try { 40 | InputStream inputStream = AppUtil.getDefContext().getAssets().open( 41 | "trajectory/" + name + ".yaml"); 42 | return TrajectoryConfigManager.loadConfig(inputStream); 43 | } catch (IOException e) { 44 | return null; 45 | } 46 | } 47 | 48 | /** 49 | * Loads a trajectory builder with the given name. 50 | */ 51 | public static @Nullable TrajectoryBuilder loadBuilder(String name) { 52 | TrajectoryGroupConfig groupConfig = loadGroupConfig(); 53 | TrajectoryConfig config = loadConfig(name); 54 | if (groupConfig == null || config == null) { 55 | return null; 56 | } 57 | return config.toTrajectoryBuilder(groupConfig); 58 | } 59 | 60 | /** 61 | * Loads a trajectory with the given name. 62 | */ 63 | public static @Nullable Trajectory load(String name) { 64 | TrajectoryBuilder builder = loadBuilder(name); 65 | if (builder == null) { 66 | return null; 67 | } 68 | return builder.build(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/AxesSigns.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.util; 2 | 3 | /** 4 | * IMU axes signs in the order XYZ (after remapping). 5 | */ 6 | public enum AxesSigns { 7 | PPP(0b000), 8 | PPN(0b001), 9 | PNP(0b010), 10 | PNN(0b011), 11 | NPP(0b100), 12 | NPN(0b101), 13 | NNP(0b110), 14 | NNN(0b111); 15 | 16 | public final int bVal; 17 | 18 | AxesSigns(int bVal) { 19 | this.bVal = bVal; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/BNO055IMUUtil.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.util; 2 | 3 | import com.qualcomm.hardware.bosch.BNO055IMU; 4 | 5 | import org.firstinspires.ftc.robotcore.external.navigation.AxesOrder; 6 | 7 | /** 8 | * Various utility functions for the BNO055 IMU. 9 | */ 10 | public class BNO055IMUUtil { 11 | /** 12 | * Remap BNO055 IMU axes and signs. For reference, the default order is {@link AxesOrder#ZYX}. 13 | * Call after {@link BNO055IMU#initialize(BNO055IMU.Parameters)}. Although this isn't 14 | * mentioned in the datasheet, the axes order appears to affect the onboard sensor fusion. 15 | * 16 | * Adapted from this post. 17 | * 18 | * @param imu IMU 19 | * @param order axes order 20 | * @param signs axes signs 21 | */ 22 | public static void remapAxes(BNO055IMU imu, AxesOrder order, AxesSigns signs) { 23 | try { 24 | // the indices correspond with the 2-bit encodings specified in the datasheet 25 | int[] indices = order.indices(); 26 | int axisMapConfig = 0; 27 | axisMapConfig |= (indices[0] << 4); 28 | axisMapConfig |= (indices[1] << 2); 29 | axisMapConfig |= (indices[2] << 0); 30 | 31 | // the BNO055 driver flips the first orientation vector so we also flip here 32 | int axisMapSign = signs.bVal ^ (0b100 >> indices[0]); 33 | 34 | // Enter CONFIG mode 35 | imu.write8(BNO055IMU.Register.OPR_MODE, BNO055IMU.SensorMode.CONFIG.bVal & 0x0F); 36 | 37 | Thread.sleep(100); 38 | 39 | // Write the AXIS_MAP_CONFIG register 40 | imu.write8(BNO055IMU.Register.AXIS_MAP_CONFIG, axisMapConfig & 0x3F); 41 | 42 | // Write the AXIS_MAP_SIGN register 43 | imu.write8(BNO055IMU.Register.AXIS_MAP_SIGN, axisMapSign & 0x07); 44 | 45 | // Switch back to the previous mode 46 | imu.write8(BNO055IMU.Register.OPR_MODE, imu.getParameters().mode.bVal & 0x0F); 47 | 48 | Thread.sleep(100); 49 | } catch (InterruptedException e) { 50 | Thread.currentThread().interrupt(); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/DashboardUtil.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.util; 2 | 3 | import com.acmerobotics.dashboard.canvas.Canvas; 4 | import com.acmerobotics.roadrunner.geometry.Pose2d; 5 | import com.acmerobotics.roadrunner.geometry.Vector2d; 6 | import com.acmerobotics.roadrunner.path.Path; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Set of helper functions for drawing Road Runner paths and trajectories on dashboard canvases. 12 | */ 13 | public class DashboardUtil { 14 | private static final double DEFAULT_RESOLUTION = 2.0; // distance units; presumed inches 15 | private static final double ROBOT_RADIUS = 9; // in 16 | 17 | 18 | public static void drawPoseHistory(Canvas canvas, List poseHistory) { 19 | double[] xPoints = new double[poseHistory.size()]; 20 | double[] yPoints = new double[poseHistory.size()]; 21 | for (int i = 0; i < poseHistory.size(); i++) { 22 | Pose2d pose = poseHistory.get(i); 23 | xPoints[i] = pose.getX(); 24 | yPoints[i] = pose.getY(); 25 | } 26 | canvas.strokePolyline(xPoints, yPoints); 27 | } 28 | 29 | public static void drawSampledPath(Canvas canvas, Path path, double resolution) { 30 | int samples = (int) Math.ceil(path.length() / resolution); 31 | double[] xPoints = new double[samples]; 32 | double[] yPoints = new double[samples]; 33 | double dx = path.length() / (samples - 1); 34 | for (int i = 0; i < samples; i++) { 35 | double displacement = i * dx; 36 | Pose2d pose = path.get(displacement); 37 | xPoints[i] = pose.getX(); 38 | yPoints[i] = pose.getY(); 39 | } 40 | canvas.strokePolyline(xPoints, yPoints); 41 | } 42 | 43 | public static void drawSampledPath(Canvas canvas, Path path) { 44 | drawSampledPath(canvas, path, DEFAULT_RESOLUTION); 45 | } 46 | 47 | public static void drawRobot(Canvas canvas, Pose2d pose) { 48 | canvas.strokeCircle(pose.getX(), pose.getY(), ROBOT_RADIUS); 49 | Vector2d v = pose.headingVec().times(ROBOT_RADIUS); 50 | double x1 = pose.getX() + v.getX() / 2, y1 = pose.getY() + v.getY() / 2; 51 | double x2 = pose.getX() + v.getX(), y2 = pose.getY() + v.getY(); 52 | canvas.strokeLine(x1, y1, x2, y2); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/Encoder.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.util; 2 | 3 | import com.acmerobotics.roadrunner.util.NanoClock; 4 | import com.qualcomm.robotcore.hardware.DcMotorEx; 5 | 6 | /** 7 | * Wraps a motor instance to provide corrected velocity counts and allow reversing without changing the corresponding 8 | * slot's motor direction 9 | */ 10 | public class Encoder { 11 | private final static int CPS_STEP = 0x10000; 12 | 13 | private static double inverseOverflow(double input, double estimate) { 14 | double real = input; 15 | while (Math.abs(estimate - real) > CPS_STEP / 2.0) { 16 | real += Math.signum(estimate - real) * CPS_STEP; 17 | } 18 | return real; 19 | } 20 | 21 | public enum Direction { 22 | FORWARD(1), 23 | REVERSE(-1); 24 | 25 | private int multiplier; 26 | 27 | Direction(int multiplier) { 28 | this.multiplier = multiplier; 29 | } 30 | 31 | public int getMultiplier() { 32 | return multiplier; 33 | } 34 | } 35 | 36 | private DcMotorEx motor; 37 | private NanoClock clock; 38 | 39 | private Direction direction; 40 | 41 | private int lastPosition; 42 | private double velocityEstimate; 43 | private double lastUpdateTime; 44 | 45 | public Encoder(DcMotorEx motor, NanoClock clock) { 46 | this.motor = motor; 47 | this.clock = clock; 48 | 49 | this.direction = Direction.FORWARD; 50 | 51 | this.lastPosition = 0; 52 | this.velocityEstimate = 0.0; 53 | this.lastUpdateTime = clock.seconds(); 54 | } 55 | 56 | public Encoder(DcMotorEx motor) { 57 | this(motor, NanoClock.system()); 58 | } 59 | 60 | public Direction getDirection() { 61 | return direction; 62 | } 63 | 64 | /** 65 | * Allows you to set the direction of the counts and velocity without modifying the motor's direction state 66 | * @param direction either reverse or forward depending on if encoder counts should be negated 67 | */ 68 | public void setDirection(Direction direction) { 69 | this.direction = direction; 70 | } 71 | 72 | public int getCurrentPosition() { 73 | int multiplier = direction.getMultiplier(); 74 | int currentPosition = motor.getCurrentPosition() * multiplier; 75 | if (currentPosition != lastPosition) { 76 | double currentTime = clock.seconds(); 77 | double dt = currentTime - lastUpdateTime; 78 | velocityEstimate = (currentPosition - lastPosition) / dt; 79 | lastPosition = currentPosition; 80 | lastUpdateTime = currentTime; 81 | } 82 | return currentPosition; 83 | } 84 | 85 | public double getRawVelocity() { 86 | int multiplier = direction.getMultiplier(); 87 | return motor.getVelocity() * multiplier; 88 | } 89 | 90 | public double getCorrectedVelocity() { 91 | return inverseOverflow(getRawVelocity(), velocityEstimate); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/LoggingUtil.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.util; 2 | 3 | import org.firstinspires.ftc.robotcore.internal.system.AppUtil; 4 | 5 | import java.io.File; 6 | import java.util.ArrayList; 7 | import java.util.Collections; 8 | import java.util.List; 9 | 10 | /** 11 | * Utility functions for log files. 12 | */ 13 | public class LoggingUtil { 14 | public static final File ROAD_RUNNER_FOLDER = 15 | new File(AppUtil.ROOT_FOLDER + "/RoadRunner/"); 16 | 17 | private static final long LOG_QUOTA = 25 * 1024 * 1024; // 25MB log quota for now 18 | 19 | private static void buildLogList(List logFiles, File dir) { 20 | for (File file : dir.listFiles()) { 21 | if (file.isDirectory()) { 22 | buildLogList(logFiles, file); 23 | } else { 24 | logFiles.add(file); 25 | } 26 | } 27 | } 28 | 29 | private static void pruneLogsIfNecessary() { 30 | List logFiles = new ArrayList<>(); 31 | buildLogList(logFiles, ROAD_RUNNER_FOLDER); 32 | Collections.sort(logFiles, (lhs, rhs) -> 33 | Long.compare(lhs.lastModified(), rhs.lastModified())); 34 | 35 | long dirSize = 0; 36 | for (File file: logFiles) { 37 | dirSize += file.length(); 38 | } 39 | 40 | while (dirSize > LOG_QUOTA) { 41 | if (logFiles.size() == 0) break; 42 | File fileToRemove = logFiles.remove(0); 43 | dirSize -= fileToRemove.length(); 44 | //noinspection ResultOfMethodCallIgnored 45 | fileToRemove.delete(); 46 | } 47 | } 48 | 49 | /** 50 | * Obtain a log file with the provided name 51 | */ 52 | public static File getLogFile(String name) { 53 | //noinspection ResultOfMethodCallIgnored 54 | ROAD_RUNNER_FOLDER.mkdirs(); 55 | 56 | pruneLogsIfNecessary(); 57 | 58 | return new File(ROAD_RUNNER_FOLDER, name); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/LynxModuleUtil.java: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.util; 2 | 3 | import com.qualcomm.hardware.lynx.LynxModule; 4 | import com.qualcomm.robotcore.hardware.HardwareMap; 5 | 6 | import org.firstinspires.ftc.robotcore.internal.system.Misc; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | /** 12 | * Collection of utilites for interacting with Lynx modules. 13 | */ 14 | public class LynxModuleUtil { 15 | 16 | private static final LynxFirmwareVersion MIN_VERSION = new LynxFirmwareVersion(1, 8, 2); 17 | 18 | /** 19 | * Parsed representation of a Lynx module firmware version. 20 | */ 21 | public static class LynxFirmwareVersion implements Comparable { 22 | public final int major; 23 | public final int minor; 24 | public final int eng; 25 | 26 | public LynxFirmwareVersion(int major, int minor, int eng) { 27 | this.major = major; 28 | this.minor = minor; 29 | this.eng = eng; 30 | } 31 | 32 | @Override 33 | public boolean equals(Object other) { 34 | if (other instanceof LynxFirmwareVersion) { 35 | LynxFirmwareVersion otherVersion = (LynxFirmwareVersion) other; 36 | return major == otherVersion.major && minor == otherVersion.minor && 37 | eng == otherVersion.eng; 38 | } else { 39 | return false; 40 | } 41 | } 42 | 43 | @Override 44 | public int compareTo(LynxFirmwareVersion other) { 45 | int majorComp = Integer.compare(major, other.major); 46 | if (majorComp == 0) { 47 | int minorComp = Integer.compare(minor, other.minor); 48 | if (minorComp == 0) { 49 | return Integer.compare(eng, other.eng); 50 | } else { 51 | return minorComp; 52 | } 53 | } else { 54 | return majorComp; 55 | } 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | return Misc.formatInvariant("%d.%d.%d", major, minor, eng); 61 | } 62 | } 63 | 64 | /** 65 | * Retrieve and parse Lynx module firmware version. 66 | * @param module Lynx module 67 | * @return parsed firmware version 68 | */ 69 | public static LynxFirmwareVersion getFirmwareVersion(LynxModule module) { 70 | String versionString = module.getNullableFirmwareVersionString(); 71 | if (versionString == null) { 72 | return null; 73 | } 74 | 75 | String[] parts = versionString.split("[ :,]+"); 76 | try { 77 | // note: for now, we ignore the hardware entry 78 | return new LynxFirmwareVersion( 79 | Integer.parseInt(parts[3]), 80 | Integer.parseInt(parts[5]), 81 | Integer.parseInt(parts[7]) 82 | ); 83 | } catch (NumberFormatException e) { 84 | return null; 85 | } 86 | } 87 | 88 | /** 89 | * Exception indicating an outdated Lynx firmware version. 90 | */ 91 | public static class LynxFirmwareVersionException extends RuntimeException { 92 | public LynxFirmwareVersionException(String detailMessage) { 93 | super(detailMessage); 94 | } 95 | } 96 | 97 | /** 98 | * Ensure all of the Lynx modules attached to the robot satisfy the minimum requirement. 99 | * @param hardwareMap hardware map containing Lynx modules 100 | */ 101 | public static void ensureMinimumFirmwareVersion(HardwareMap hardwareMap) { 102 | Map outdatedModules = new HashMap<>(); 103 | for (LynxModule module : hardwareMap.getAll(LynxModule.class)) { 104 | LynxFirmwareVersion version = getFirmwareVersion(module); 105 | if (version == null || version.compareTo(MIN_VERSION) < 0) { 106 | for (String name : hardwareMap.getNamesOf(module)) { 107 | outdatedModules.put(name, version); 108 | } 109 | } 110 | } 111 | if (outdatedModules.size() > 0) { 112 | StringBuilder msgBuilder = new StringBuilder(); 113 | msgBuilder.append("One or more of the attached Lynx modules has outdated firmware\n"); 114 | msgBuilder.append(Misc.formatInvariant("Mandatory minimum firmware version: %s\n", 115 | MIN_VERSION.toString())); 116 | for (Map.Entry entry : outdatedModules.entrySet()) { 117 | msgBuilder.append(Misc.formatInvariant( 118 | "\t%s: %s\n", entry.getKey(), 119 | entry.getValue() == null ? "Unknown" : entry.getValue().toString())); 120 | } 121 | throw new LynxFirmwareVersionException(msgBuilder.toString()); 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /TeamCode/src/main/java/org/firstinspires/ftc/teamcode/util/Pose2dUtil.kt: -------------------------------------------------------------------------------- 1 | package org.firstinspires.ftc.teamcode.util 2 | 3 | import com.acmerobotics.roadrunner.geometry.Pose2d 4 | import com.arcrobotics.ftclib.geometry.Rotation2d 5 | import com.arcrobotics.ftclib.kinematics.wpilibkinematics.ChassisSpeeds 6 | 7 | fun com.arcrobotics.ftclib.geometry.Pose2d.toRR(): Pose2d = Pose2d(this.translation.y, this.translation.x, this.heading) 8 | 9 | fun Pose2d.toFTCLib(): com.arcrobotics.ftclib.geometry.Pose2d = com.arcrobotics.ftclib.geometry.Pose2d(-this.x, -this.y, Rotation2d(this.heading)) 10 | 11 | val com.arcrobotics.ftclib.geometry.Pose2d.x: Double 12 | get() = this.translation.x 13 | 14 | val com.arcrobotics.ftclib.geometry.Pose2d.y: Double 15 | get() = this.translation.y 16 | 17 | val com.arcrobotics.ftclib.geometry.Pose2d.rotationDeg: Double 18 | get() = this.rotation.degrees 19 | 20 | val com.arcrobotics.ftclib.geometry.Pose2d.rotationRad: Double 21 | get() = this.rotation.radians 22 | 23 | fun ChassisSpeeds.toRRPose2d(): Pose2d = Pose2d(this.vxMetersPerSecond, this.vyMetersPerSecond, this.omegaRadiansPerSecond) -------------------------------------------------------------------------------- /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 | def useProguard = false 23 | 24 | android { 25 | 26 | compileSdkVersion 29 27 | 28 | signingConfigs { 29 | debug { 30 | keyAlias 'androiddebugkey' 31 | keyPassword 'android' 32 | storeFile rootProject.file('libs/ftc.debug.keystore') 33 | storePassword 'android' 34 | } 35 | } 36 | 37 | aaptOptions { 38 | noCompress "tflite" 39 | } 40 | 41 | defaultConfig { 42 | signingConfig signingConfigs.debug 43 | applicationId 'com.qualcomm.ftcrobotcontroller' 44 | minSdkVersion 24 45 | targetSdkVersion 28 46 | multiDexEnabled !useProguard 47 | 48 | /** 49 | * We keep the versionCode and versionName of robot controller applications in sync with 50 | * the master information published in the AndroidManifest.xml file of the FtcRobotController 51 | * module. This helps avoid confusion that might arise from having multiple versions of 52 | * a robot controller app simultaneously installed on a robot controller device. 53 | * 54 | * We accomplish this with the help of a funky little Groovy script that maintains that 55 | * correspondence automatically. 56 | * 57 | * @see Configure Your Build 58 | * @see Versioning Your App 59 | */ 60 | def manifestFile = project(':FtcRobotController').file('src/main/AndroidManifest.xml'); 61 | def manifestText = manifestFile.getText() 62 | // 63 | def vCodePattern = Pattern.compile("versionCode=\"(\\d+(\\.\\d+)*)\"") 64 | def matcher = vCodePattern.matcher(manifestText) 65 | matcher.find() 66 | def vCode = Integer.parseInt(matcher.group(1)) 67 | // 68 | def vNamePattern = Pattern.compile("versionName=\"(.*)\"") 69 | matcher = vNamePattern.matcher(manifestText); 70 | matcher.find() 71 | def vName = matcher.group(1) 72 | // 73 | versionCode vCode 74 | versionName vName 75 | } 76 | 77 | // Advanced user code might just want to use Vuforia directly, so we set up the libs as needed 78 | // http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.BuildType.html 79 | buildTypes { 80 | release { 81 | // Disable debugging for release versions so it can be uploaded to Google Play. 82 | //debuggable true 83 | ndk { 84 | abiFilters "armeabi-v7a", "arm64-v8a" 85 | } 86 | 87 | if (useProguard) { 88 | minifyEnabled true 89 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 90 | 'proguard-rules.pro' 91 | println(getProguardFiles()) 92 | } 93 | } 94 | debug { 95 | debuggable true 96 | jniDebuggable true 97 | renderscriptDebuggable true 98 | ndk { 99 | abiFilters "armeabi-v7a", "arm64-v8a" 100 | } 101 | 102 | if (useProguard) { 103 | minifyEnabled true 104 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 105 | 'proguard-rules.pro' 106 | println(getProguardFiles()) 107 | } 108 | } 109 | } 110 | 111 | compileOptions { 112 | sourceCompatibility JavaVersion.VERSION_1_8 113 | targetCompatibility JavaVersion.VERSION_1_8 114 | } 115 | 116 | sourceSets.main { 117 | jni.srcDirs = [] 118 | jniLibs.srcDir rootProject.file('libs') 119 | } 120 | } 121 | 122 | repositories { 123 | flatDir { 124 | dirs rootProject.file('libs') 125 | } 126 | } 127 | apply from: 'build.release.gradle' 128 | -------------------------------------------------------------------------------- /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 | buildscript { 7 | repositories { 8 | google() 9 | jcenter() 10 | } 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:4.0.1' 13 | } 14 | } 15 | 16 | // This is now required because aapt2 has to be downloaded from the 17 | // google() repository beginning with version 3.2 of the Android Gradle Plugin 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /doc/apk/FtcDriverStation-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/doc/apk/FtcDriverStation-release.apk -------------------------------------------------------------------------------- /doc/apk/FtcRobotController-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/doc/apk/FtcRobotController-release.apk -------------------------------------------------------------------------------- /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/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/doc/legal/LEGO Open Source License.pdf -------------------------------------------------------------------------------- /doc/media/PullRequest.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/doc/media/PullRequest.PNG -------------------------------------------------------------------------------- /doc/media/chips.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/doc/media/chips.jpg -------------------------------------------------------------------------------- /doc/media/readme.md: -------------------------------------------------------------------------------- 1 | ## Vuforia Localizer Sample Image Targets 2 | 3 | The files in this folder are the printable images that correspond to the sample 4 | trackable data sets that have been included with integration of Vuforia to the 5 | FTC SDK. See the ConceptVuforiaNavigation.java OpMode for details. 6 | -------------------------------------------------------------------------------- /doc/media/stones.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/doc/media/stones.jpg -------------------------------------------------------------------------------- /doc/media/target_chips_A4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/doc/media/target_chips_A4.pdf -------------------------------------------------------------------------------- /doc/media/target_chips_USLetter.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/doc/media/target_chips_USLetter.pdf -------------------------------------------------------------------------------- /doc/media/target_stones_A4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/doc/media/target_stones_A4.pdf -------------------------------------------------------------------------------- /doc/media/target_stones_USLetter.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/doc/media/target_stones_USLetter.pdf -------------------------------------------------------------------------------- /doc/tutorial/README.txt: -------------------------------------------------------------------------------- 1 | What happened to the FTC Software Development Tutorials??? 2 | 3 | In an effort to save space and reduce download time, the older (and outdated) tutorial documents (FTCTraining_Manual.pdf, FTC_FieldCoordinateSystemDefinition.pdf, FTC_NextGenGuide.pdf, and FTC_ZTE_ChannelChange.pdf) have been removed. 4 | 5 | You can find the releveant PDF files attached to the "Releases" page of the GitHub repository: 6 | 7 | https://github.com/ftctechnh/ftc_app/releases 8 | -------------------------------------------------------------------------------- /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 | # Automatically convert third-party libraries to use AndroidX 7 | android.enableJetifier=true 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jul 24 14:30:03 PDT 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip 7 | -------------------------------------------------------------------------------- /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/Analytics-release.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/libs/Analytics-release.aar -------------------------------------------------------------------------------- /libs/README.txt: -------------------------------------------------------------------------------- 1 | Location of external libs 2 | -------------------------------------------------------------------------------- /libs/Vuforia.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/libs/Vuforia.jar -------------------------------------------------------------------------------- /libs/WirelessP2p-release.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/libs/WirelessP2p-release.aar -------------------------------------------------------------------------------- /libs/arm64-v8a/libVuforia.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/libs/arm64-v8a/libVuforia.so -------------------------------------------------------------------------------- /libs/armeabi-v7a/libVuforia.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/libs/armeabi-v7a/libVuforia.so -------------------------------------------------------------------------------- /libs/ftc.debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/libs/ftc.debug.keystore -------------------------------------------------------------------------------- /libs/tensorflow-lite-0.0.0-nightly.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/libs/tensorflow-lite-0.0.0-nightly.aar -------------------------------------------------------------------------------- /libs/tfod-release.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FTCLib/RoadRunner-FTCLib-Quickstart/7490585daf79ef9da1858472619ff7185ad60c7b/libs/tfod-release.aar -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':FtcRobotController' 2 | include ':TeamCode' 3 | --------------------------------------------------------------------------------