Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

Commit

Permalink
Update to 6.2, fix #13
Browse files Browse the repository at this point in the history
  • Loading branch information
9p4 committed Mar 28, 2021
1 parent aacf76c commit 4e40045
Show file tree
Hide file tree
Showing 17 changed files with 144 additions and 83 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,3 @@ lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/

VuForiaKey.java
10 changes: 10 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion FtcRobotController/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ repositories {
}
}

apply from: 'build.release.gradle'
apply from: '../build.dependencies.gradle'
12 changes: 0 additions & 12 deletions FtcRobotController/build.release.gradle

This file was deleted.

4 changes: 2 additions & 2 deletions FtcRobotController/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.qualcomm.ftcrobotcontroller"
android:versionCode="39"
android:versionName="6.1">
android:versionCode="40"
android:versionName="6.2">

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@

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
Expand Down Expand Up @@ -89,10 +88,6 @@
@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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -207,55 +203,46 @@ 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)));

//
// 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.

// 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 ;
}
// 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.

// 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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ public boolean onMenuItemClick(MenuItem item) {
}

FtcAboutActivity.setBuildTimeFromBuildConfig(BuildConfig.BUILD_TIME);

// check to see if there is a preferred Wi-Fi to use.
checkPreferredChannel();

FtcDashboard.start();
}

Expand All @@ -404,17 +408,6 @@ protected void onStart() {
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) {
Expand Down Expand Up @@ -662,7 +655,9 @@ protected void onActivityResult(int request, int result, Intent intent) {
// 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();
}
}

Expand Down
5 changes: 4 additions & 1 deletion TeamCode/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

// Include common definitions from above.
apply from: '../build.common.gradle'
apply from: '../build.dependencies.gradle'

repositories {
google()
Expand All @@ -23,6 +24,8 @@ dependencies {
annotationProcessor files('lib/OpModeAnnotationProcessor.jar')
compileOnly 'org.projectlombok:lombok:1.18.16'
annotationProcessor 'org.projectlombok:lombok:1.18.16'
implementation 'com.acmerobotics.roadrunner:core:0.5.3'
implementation 'org.apache.commons:commons-math3:3.6.1'
}

buildscript {
Expand All @@ -40,4 +43,4 @@ buildscript {
android {
defaultConfig {
}
}
}
11 changes: 0 additions & 11 deletions TeamCode/build.release.gradle

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ public static void initVuforia(String webcamName) {
/*
* Configure Vuforia by creating a Parameter object, and passing it to the Vuforia engine.
*/
VuforiaLocalizer.Parameters parameters = new VuforiaLocalizer.Parameters(R.id.cameraMonitorViewId);
int cameraMonitorViewId = Robot.linearOpMode.hardwareMap.appContext.getResources().getIdentifier("cameraMonitorViewId", "id", Robot.linearOpMode.hardwareMap.appContext.getPackageName());
VuforiaLocalizer.Parameters parameters = new VuforiaLocalizer.Parameters(cameraMonitorViewId);

parameters.vuforiaLicenseKey = VUFORIA_KEY;
parameters.cameraName = Robot.sensor.getWebcam(webcamName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ private void initVuforia() {
/*
* Configure Vuforia by creating a Parameter object, and passing it to the Vuforia engine.
*/
VuforiaLocalizer.Parameters parameters = new VuforiaLocalizer.Parameters(R.id.cameraMonitorViewId);
int cameraMonitorViewId = Robot.linearOpMode.hardwareMap.appContext.getResources().getIdentifier("cameraMonitorViewId", "id", Robot.linearOpMode.hardwareMap.appContext.getPackageName());
VuforiaLocalizer.Parameters parameters = new VuforiaLocalizer.Parameters(cameraMonitorViewId);

parameters.vuforiaLicenseKey = VUFORIA_KEY;
parameters.cameraName = Robot.sensor.getWebcam(Naming.WEBCAM_0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public void runOpMode() throws InterruptedException {
// gives Vuforia more time to exit before the watchdog notices
msStuckDetectStop = 2500;

VuforiaLocalizer.Parameters vuforiaParams = new VuforiaLocalizer.Parameters(R.id.cameraMonitorViewId);
int cameraMonitorViewId = Robot.linearOpMode.hardwareMap.appContext.getResources().getIdentifier("cameraMonitorViewId", "id", Robot.linearOpMode.hardwareMap.appContext.getPackageName());
VuforiaLocalizer.Parameters vuforiaParams = new VuforiaLocalizer.Parameters(cameraMonitorViewId);

vuforiaParams.cameraName = Robot.sensor.getWebcam(Naming.WEBCAM_0);
vuforiaParams.vuforiaLicenseKey = VUFORIA_LICENSE_KEY;
vuforiaParams.cameraDirection = VuforiaLocalizer.CameraDirection.BACK;
Expand Down
21 changes: 17 additions & 4 deletions build.common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -82,8 +97,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"
}
Expand Down Expand Up @@ -114,5 +129,3 @@ repositories {
dirs rootProject.file('libs')
}
}
apply from: 'build.release.gradle'
apply plugin: 'kotlin-android'
25 changes: 25 additions & 0 deletions build.dependencies.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

repositories {
mavenCentral()
google() // Needed for androidx
jcenter() // Needed for tensorflow-lite
flatDir {
dirs rootProject.file('libs')
}
maven { url = 'https://maven.brott.dev/' }
}

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'
implementation 'com.acmerobotics.dashboard:dashboard:0.4.1'
}

Loading

0 comments on commit 4e40045

Please sign in to comment.