From 6e7dfbfb8b725343f9d4fc6a92ed17618f8fea44 Mon Sep 17 00:00:00 2001 From: Cal Kestis Date: Thu, 18 Feb 2021 08:03:59 -0800 Subject: [PATCH] FtcRobotController v6.2 --- FtcRobotController/build.gradle | 10 +--- FtcRobotController/build.release.gradle | 10 ---- .../src/main/AndroidManifest.xml | 4 +- ...ptVuforiaUltimateGoalNavigationWebcam.java | 51 +++++++------------ .../external/samples/readme.md | 9 ++-- .../internal/FtcRobotControllerActivity.java | 16 ++---- README.md | 43 ++++++++++++++-- TeamCode/build.gradle | 8 ++- TeamCode/build.release.gradle | 8 --- build.common.gradle | 22 ++++++-- build.dependencies.gradle | 23 +++++++++ build.gradle | 46 +++++++++++++++++ 12 files changed, 162 insertions(+), 88 deletions(-) delete mode 100644 FtcRobotController/build.release.gradle delete mode 100644 TeamCode/build.release.gradle create mode 100644 build.dependencies.gradle diff --git a/FtcRobotController/build.gradle b/FtcRobotController/build.gradle index 1ec0503..fe500c4 100644 --- a/FtcRobotController/build.gradle +++ b/FtcRobotController/build.gradle @@ -21,12 +21,4 @@ android { } } -repositories { - maven { url = "https://dl.bintray.com/first-tech-challenge/ftcsdk/" } - - flatDir { - dirs '../libs' - } -} - -apply from: 'build.release.gradle' +apply from: '../build.dependencies.gradle' diff --git a/FtcRobotController/build.release.gradle b/FtcRobotController/build.release.gradle deleted file mode 100644 index 8857869..0000000 --- a/FtcRobotController/build.release.gradle +++ /dev/null @@ -1,10 +0,0 @@ -dependencies { - implementation 'org.firstinspires.ftc:Inspection:6.1.1' - implementation 'org.firstinspires.ftc:Blocks:6.1.1' - implementation 'org.firstinspires.ftc:RobotCore:6.1.1' - implementation 'org.firstinspires.ftc:RobotServer:6.1.1' - implementation 'org.firstinspires.ftc:OnBotJava:6.1.1' - implementation 'org.firstinspires.ftc:Hardware:6.1.1' - implementation 'org.firstinspires.ftc:FtcCommon:6.1.1' - implementation 'androidx.appcompat:appcompat:1.2.0' -} diff --git a/FtcRobotController/src/main/AndroidManifest.xml b/FtcRobotController/src/main/AndroidManifest.xml index cb1e8d2..10e9f96 100644 --- a/FtcRobotController/src/main/AndroidManifest.xml +++ b/FtcRobotController/src/main/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="40" + android:versionName="6.2"> diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptVuforiaUltimateGoalNavigationWebcam.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptVuforiaUltimateGoalNavigationWebcam.java index 8021ba9..3497b8b 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptVuforiaUltimateGoalNavigationWebcam.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/ConceptVuforiaUltimateGoalNavigationWebcam.java @@ -48,9 +48,8 @@ import java.util.List; import static org.firstinspires.ftc.robotcore.external.navigation.AngleUnit.DEGREES; import static org.firstinspires.ftc.robotcore.external.navigation.AxesOrder.XYZ; -import static org.firstinspires.ftc.robotcore.external.navigation.AxesOrder.YZX; +import static org.firstinspires.ftc.robotcore.external.navigation.AxesOrder.XZY; import static org.firstinspires.ftc.robotcore.external.navigation.AxesReference.EXTRINSIC; -import static org.firstinspires.ftc.robotcore.external.navigation.VuforiaLocalizer.CameraDirection.BACK; /** * This 2020-2021 OpMode illustrates the basics of using the Vuforia localizer to determine @@ -89,10 +88,6 @@ import static org.firstinspires.ftc.robotcore.external.navigation.VuforiaLocaliz @Disabled public class ConceptVuforiaUltimateGoalNavigationWebcam extends LinearOpMode { - // IMPORTANT: If you are using a USB WebCam, you must select CAMERA_CHOICE = BACK; and PHONE_IS_PORTRAIT = false; - private static final VuforiaLocalizer.CameraDirection CAMERA_CHOICE = BACK; - private static final boolean PHONE_IS_PORTRAIT = false ; - /* * IMPORTANT: You need to obtain your own license key to use Vuforia. The string below with which * 'parameters.vuforiaLicenseKey' is initialized is for illustration only, and will not function. @@ -140,8 +135,9 @@ public class ConceptVuforiaUltimateGoalNavigationWebcam extends LinearOpMode { /* * Configure Vuforia by creating a Parameter object, and passing it to the Vuforia engine. - * We can pass Vuforia the handle to a camera preview resource (on the RC phone); + * We can pass Vuforia the handle to a camera preview resource (on the RC screen); * If no camera monitor is desired, use the parameter-less constructor instead (commented out below). + * Note: A preview window is required if you want to view the camera stream on the Driver Station Phone. */ int cameraMonitorViewId = hardwareMap.appContext.getResources().getIdentifier("cameraMonitorViewId", "id", hardwareMap.appContext.getPackageName()); VuforiaLocalizer.Parameters parameters = new VuforiaLocalizer.Parameters(cameraMonitorViewId); @@ -207,12 +203,12 @@ public class ConceptVuforiaUltimateGoalNavigationWebcam extends LinearOpMode { .multiplied(Orientation.getRotationMatrix(EXTRINSIC, XYZ, DEGREES, 90, 0, 0))); frontWallTarget.setLocation(OpenGLMatrix .translation(-halfField, 0, mmTargetHeight) - .multiplied(Orientation.getRotationMatrix(EXTRINSIC, XYZ, DEGREES, 90, 0 , 90))); + .multiplied(Orientation.getRotationMatrix(EXTRINSIC, XYZ, DEGREES, 90, 0, 90))); // The tower goal targets are located a quarter field length from the ends of the back perimeter wall. blueTowerGoalTarget.setLocation(OpenGLMatrix .translation(halfField, quadField, mmTargetHeight) - .multiplied(Orientation.getRotationMatrix(EXTRINSIC, XYZ, DEGREES, 90, 0 , -90))); + .multiplied(Orientation.getRotationMatrix(EXTRINSIC, XYZ, DEGREES, 90, 0, -90))); redTowerGoalTarget.setLocation(OpenGLMatrix .translation(halfField, -quadField, mmTargetHeight) .multiplied(Orientation.getRotationMatrix(EXTRINSIC, XYZ, DEGREES, 90, 0, -90))); @@ -220,42 +216,33 @@ public class ConceptVuforiaUltimateGoalNavigationWebcam extends LinearOpMode { // // Create a transformation matrix describing where the phone is on the robot. // - // NOTE !!!! It's very important that you turn OFF your phone's Auto-Screen-Rotation option. - // Lock it into Portrait for these numbers to work. - // // Info: The coordinate frame for the robot looks the same as the field. // The robot's "forward" direction is facing out along X axis, with the LEFT side facing out along the Y axis. // Z is UP on the robot. This equates to a bearing angle of Zero degrees. // - // The phone starts out lying flat, with the screen facing Up and with the physical top of the phone - // pointing to the LEFT side of the Robot. - // The two examples below assume that the camera is facing forward out the front of the robot. + // For a WebCam, the default starting orientation of the camera is looking UP (pointing in the Z direction), + // with the wide (horizontal) axis of the camera aligned with the X axis, and + // the Narrow (vertical) axis of the camera aligned with the Y axis + // + // But, this example assumes that the camera is actually facing forward out the front of the robot. + // So, the "default" camera position requires two rotations to get it oriented correctly. + // 1) First it must be rotated +90 degrees around the X axis to get it horizontal (it's now facing out the right side of the robot) + // 2) Next it must be be rotated +90 degrees (counter-clockwise) around the Z axis to face forward. + // + // Finally the camera can be translated to its actual mounting position on the robot. + // In this example, it is centered (left to right), but 4" forward of the middle of the robot, and 8" above ground level. - // We need to rotate the camera around it's long axis to bring the correct camera forward. - if (CAMERA_CHOICE == BACK) { - phoneYRotate = -90; - } else { - phoneYRotate = 90; - } - - // Rotate the phone vertical about the X axis if it's in portrait mode - if (PHONE_IS_PORTRAIT) { - phoneXRotate = 90 ; - } - - // Next, translate the camera lens to where it is on the robot. - // In this example, it is centered (left to right), but forward of the middle of the robot, and above ground level. final float CAMERA_FORWARD_DISPLACEMENT = 4.0f * mmPerInch; // eg: Camera is 4 Inches in front of robot-center final float CAMERA_VERTICAL_DISPLACEMENT = 8.0f * mmPerInch; // eg: Camera is 8 Inches above ground final float CAMERA_LEFT_DISPLACEMENT = 0; // eg: Camera is ON the robot's center line - OpenGLMatrix robotFromCamera = OpenGLMatrix + OpenGLMatrix cameraLocationOnRobot = OpenGLMatrix .translation(CAMERA_FORWARD_DISPLACEMENT, CAMERA_LEFT_DISPLACEMENT, CAMERA_VERTICAL_DISPLACEMENT) - .multiplied(Orientation.getRotationMatrix(EXTRINSIC, YZX, DEGREES, phoneYRotate, phoneZRotate, phoneXRotate)); + .multiplied(Orientation.getRotationMatrix(EXTRINSIC, XZY, DEGREES, 90, 90, 0)); /** Let all the trackable listeners know where the phone is. */ for (VuforiaTrackable trackable : allTrackables) { - ((VuforiaTrackableDefaultListener) trackable.getListener()).setPhoneInformation(robotFromCamera, parameters.cameraDirection); + ((VuforiaTrackableDefaultListener) trackable.getListener()).setCameraLocationOnRobot(parameters.cameraName, cameraLocationOnRobot); } // WARNING: diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/readme.md b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/readme.md index 5b66c4f..1808cd3 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/readme.md +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/readme.md @@ -2,9 +2,12 @@ ## Caution No Team-specific code should be placed or modified in this ``.../samples`` folder. -Full or partial Samples should be Copied from here, and then Pasted into -the team's folder, using the Android Studio cut and paste commands. -This automatically changes all file and class names to be consistent. +Samples should be Copied from here, and then Pasted into the team's +[/TeamCode/src/main/java/org/firstinspires/ftc/teamcode](../../../../../../../../../../TeamCode/src/main/java/org/firstinspires/ftc/teamcode) + folder, using the Android Studio cut and paste commands. This automatically changes all file and +class names to be consistent. From there, the sample can be modified to suit the team's needs. + +For more detailed instructions see the /teamcode readme. ### Naming of Samples diff --git a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/FtcRobotControllerActivity.java b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/FtcRobotControllerActivity.java index 7957ef2..e3b9f56 100644 --- a/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/FtcRobotControllerActivity.java +++ b/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/internal/FtcRobotControllerActivity.java @@ -380,6 +380,9 @@ public class FtcRobotControllerActivity extends Activity } FtcAboutActivity.setBuildTimeFromBuildConfig(BuildConfig.BUILD_TIME); + + // check to see if there is a preferred Wi-Fi to use. + checkPreferredChannel(); } protected UpdateUI createUpdateUI() { @@ -401,17 +404,6 @@ public class FtcRobotControllerActivity extends Activity super.onStart(); RobotLog.vv(TAG, "onStart()"); - // If we're start()ing after a stop(), then shut the old robot down so - // we can refresh it with new state (e.g., with new hw configurations) - shutdownRobot(); - - updateUIAndRequestRobotSetup(); - - cfgFileMgr.getActiveConfigAndUpdateUI(); - - // check to see if there is a preferred Wi-Fi to use. - checkPreferredChannel(); - entireScreenLayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { @@ -657,7 +649,9 @@ public class FtcRobotControllerActivity extends Activity // was some historical confusion about launch codes here, so we err safely if (request == RequestCode.CONFIGURE_ROBOT_CONTROLLER.ordinal() || request == RequestCode.SETTINGS_ROBOT_CONTROLLER.ordinal()) { // We always do a refresh, whether it was a cancel or an OK, for robustness + shutdownRobot(); cfgFileMgr.getActiveConfigAndUpdateUI(); + updateUIAndRequestRobotSetup(); } } diff --git a/README.md b/README.md index e8e0564..d763e41 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ If you are an Android Studio programmer, there are several ways to download this * You can also download the project folder (as a .zip or .tar.gz archive file) from the Downloads subsection of the [Releases](https://github.com/FIRST-Tech-Challenge/FtcRobotController/releases) page for this repository. +* The Releases page also contains prebuilt APKs. + Once you have downloaded and uncompressed (if needed) your folder, you can use Android Studio to import the folder ("Import project (Eclipse ADT, Gradle, etc.)"). ## Getting Help @@ -40,18 +42,49 @@ The Javadoc reference documentation for the FTC SDK is now available online. Cl       [FTC Javadoc Documentation](https://first-tech-challenge.github.io/FtcRobotController) -Documentation for the FTC SDK is also included with this repository. There is a subfolder called "doc" which contains several subfolders: - - * The folder "apk" contains the .apk files for the FTC Driver Station and FTC Robot Controller apps. - * The folder "javadoc" contains the JavaDoc user documentation for the FTC SDK. - ### Online User Forum For technical questions regarding the Control System or the FTC SDK, please visit the FTC Technology forum:       [FTC Technology Forum](https://ftcforum.firstinspires.org/forum/ftc-technology) +### Sample OpModes +This project contains a large selection of Sample OpModes (robot code examples) which can be cut and pasted into your /teamcode folder to be used as-is, or modified to suit your team's needs. + +Samples Folder:    [/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples](FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples) + +The readme.md file located in the [/TeamCode/src/main/java/org/firstinspires/ftc/teamcode](TeamCode/src/main/java/org/firstinspires/ftc/teamcode) folder contains an explanation of the sample naming convention, and instructions on how to copy them to your own project space. + # Release Information +## Version 6.2 (20210218-074821) + +### Enhancements +* Attempts to automatically fix the condition where a Control Hub's internal Expansion Hub is not + working by re-flashing its firmware +* Makes various improvements to the WiFi Direct pairing screen, especially in landscape mode +* Makes the Robot Controller service no longer be categorically restarted when the main activity is brought to foreground + * (e.g. the service is no longer restarted simply by viewing the Self Inspect screen and pressing the back button) + * It is still restarted if the Settings menu or Configure Robot menu is opened + + +### Bug fixes +* Fixes [FtcRobotController issue #71](https://github.com/FIRST-Tech-Challenge/FtcRobotController/issues/71) + Cannot open OpModes in v6.1 Blocks offline editor +* Fixes [FtcRobotController issue #79](https://github.com/FIRST-Tech-Challenge/FtcRobotController/issues/79) + 6.1 causes a soft reboot on the Motorola E5 Play +* Fixes issue where the Control Hub OS's watchdog would restart the Robot Controller app if + the Control Hub was not able to communicate with its internal Expansion Hub +* Fixes certain I2C devices not showing up in the appropriate `HardwareMap` fields (such as `hardwareMap.colorSensor`) +* Fixes issue where performing a WiFi factory reset on the Control Hub would not set the WiFi band to 2.4 GHz +* Fixes issue where OnBotJava might fail to create a new file if the option to "Setup Code for Configured Hardware" was selected +* Fixes issue where performing certain operations after an Op Mode crashes would temporarily break Control/Expansion Hub communication +* Fixes issue where a Control Hub with a configured USB-connected Expansion Hub would not work if the Expansion Hub was missing at startup +* Fixes potential issues caused by having mismatched Control/Expansion Hub firmware versions +* Fixes [ftc_app issue 673](https://github.com/ftctechnh/ftc_app/issues/673) Latest matchlog is being deleted instead of old ones by RobotLog +* Fixes ConceptVuforiaUltimateGoalNavigationWebcam sample opmode by correctly orienting camera on robot. +* Fixes issue where logcat would be spammed with InterruptedExceptions when stop is requested from the Driver Station (this behavior was accidentally introduced in v5.3). This change has no impact on functionality. +* Fixes issue where the blocks editor fails to load if the name of any TeleOp opmode contains an apostrophe. + ## Version 6.1 (20201209-113742) * Makes the scan button on the configuration screen update the list of Expansion Hubs connected via RS-485 * Fixes [SkyStone issue #143](https://github.com/FIRST-Tech-Challenge/SkyStone/issues/143) diff --git a/TeamCode/build.gradle b/TeamCode/build.gradle index d487070..bf12070 100644 --- a/TeamCode/build.gradle +++ b/TeamCode/build.gradle @@ -13,11 +13,9 @@ // Include common definitions from above. apply from: '../build.common.gradle' - -repositories { - maven { url = "https://dl.bintray.com/first-tech-challenge/ftcsdk/" } -} +apply from: '../build.dependencies.gradle' dependencies { + implementation project(':FtcRobotController') annotationProcessor files('lib/OpModeAnnotationProcessor.jar') -} \ No newline at end of file +} diff --git a/TeamCode/build.release.gradle b/TeamCode/build.release.gradle deleted file mode 100644 index f95f756..0000000 --- a/TeamCode/build.release.gradle +++ /dev/null @@ -1,8 +0,0 @@ -dependencies { - implementation project(':FtcRobotController') - implementation 'org.firstinspires.ftc:RobotCore:6.1.1' - implementation 'org.firstinspires.ftc:Hardware:6.1.1' - implementation 'org.firstinspires.ftc:FtcCommon:6.1.1' - implementation (name: 'tfod-release', ext:'aar') - implementation (name: 'tensorflow-lite-0.0.0-nightly', ext:'aar') -} diff --git a/build.common.gradle b/build.common.gradle index 690926d..54d067e 100644 --- a/build.common.gradle +++ b/build.common.gradle @@ -24,6 +24,21 @@ android { compileSdkVersion 29 signingConfigs { + release { + def apkStoreFile = System.getenv("APK_SIGNING_STORE_FILE") + if (apkStoreFile != null) { + keyAlias System.getenv("APK_SIGNING_KEY_ALIAS") + keyPassword System.getenv("APK_SIGNING_KEY_PASSWORD") + storeFile file(System.getenv("APK_SIGNING_STORE_FILE")) + storePassword System.getenv("APK_SIGNING_STORE_PASSWORD") + } else { + keyAlias 'androiddebugkey' + keyPassword 'android' + storeFile rootProject.file('libs/ftc.debug.keystore') + storePassword 'android' + } + } + debug { keyAlias 'androiddebugkey' keyPassword 'android' @@ -75,8 +90,8 @@ android { // http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.BuildType.html buildTypes { release { - // Disable debugging for release versions so it can be uploaded to Google Play. - //debuggable true + signingConfig signingConfigs.release + ndk { abiFilters "armeabi-v7a", "arm64-v8a" } @@ -100,6 +115,7 @@ android { jni.srcDirs = [] jniLibs.srcDir rootProject.file('libs') } + ndkVersion '21.3.6528147' } repositories { @@ -107,4 +123,4 @@ repositories { dirs rootProject.file('libs') } } -apply from: 'build.release.gradle' + diff --git a/build.dependencies.gradle b/build.dependencies.gradle new file mode 100644 index 0000000..52ab674 --- /dev/null +++ b/build.dependencies.gradle @@ -0,0 +1,23 @@ + +repositories { + mavenCentral() + google() // Needed for androidx + jcenter() // Needed for tensorflow-lite + flatDir { + dirs rootProject.file('libs') + } +} + +dependencies { + implementation 'org.firstinspires.ftc:Inspection:6.2.1' + implementation 'org.firstinspires.ftc:Blocks:6.2.1' + implementation 'org.firstinspires.ftc:RobotCore:6.2.1' + implementation 'org.firstinspires.ftc:RobotServer:6.2.1' + implementation 'org.firstinspires.ftc:OnBotJava:6.2.1' + implementation 'org.firstinspires.ftc:Hardware:6.2.1' + implementation 'org.firstinspires.ftc:FtcCommon:6.2.1' + implementation 'org.firstinspires.ftc:tfod:1.0.2' + implementation 'org.tensorflow:tensorflow-lite:1.10.0' + implementation 'androidx.appcompat:appcompat:1.2.0' +} + diff --git a/build.gradle b/build.gradle index 473aaa6..87f0507 100644 --- a/build.gradle +++ b/build.gradle @@ -3,8 +3,14 @@ * * It is extraordinarily rare that you will ever need to edit this file. */ + +configurations { + doc { transitive false } +} + buildscript { repositories { + mavenCentral() google() jcenter() } @@ -17,7 +23,47 @@ buildscript { // google() repository beginning with version 3.2 of the Android Gradle Plugin allprojects { repositories { + mavenCentral() google() jcenter() } } + +repositories { + mavenCentral() + + flatDir { + dirs '../libs' + } +} + +dependencies { + doc 'org.firstinspires.ftc:Hardware:6.2.0' + doc 'org.firstinspires.ftc:RobotCore:6.2.0' + doc 'org.firstinspires.ftc:FtcCommon:6.2.0' + doc 'org.firstinspires.ftc:OnBotJava:6.2.0' + doc 'org.firstinspires.ftc:Inspection:6.2.0' +} + +task extractJavadoc { + doLast { + def componentIds = configurations.doc.incoming.resolutionResult.allDependencies.collect { it.selected.id } + + def result = dependencies.createArtifactResolutionQuery() + .forComponents(componentIds) + .withArtifacts(JvmLibrary, SourcesArtifact, JavadocArtifact) + .execute() + + for (component in result.resolvedComponents) { + component.getArtifacts(JavadocArtifact).each { artifact -> + def version = artifact.identifier.componentIdentifier.version + def libName = artifact.identifier.componentIdentifier.moduleIdentifier.name + copy { + from zipTree(artifact.file) + into "docs/$version/$libName/" + } + } + } + } +} +