Skip to content

Commit

Permalink
Created library module and directed dependencies to Maven repo
Browse files Browse the repository at this point in the history
  • Loading branch information
magneticflux- committed Oct 13, 2017
1 parent 5d318f5 commit 90c3677
Show file tree
Hide file tree
Showing 224 changed files with 130 additions and 139 deletions.
107 changes: 11 additions & 96 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,101 +1,16 @@
import java.util.regex.Pattern

//
// build.gradle in TeamCode
//
// Most of the definitions for building your module reside in a common, shared
// file 'build.common.gradle'. Being factored in this way makes it easier to
// integrate updates to the FTC into your code. If you really need to customize
// the build definitions, you can place those customizations in this file, but
// please think carefully as to whether such customizations are really necessary
// before doing so.

// Custom definitions may go here

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

apply plugin: 'com.android.library'

android {

compileSdkVersion 23
buildToolsVersion '25.0.3'

signingConfigs {
debug {
keyAlias 'androiddebugkey'
keyPassword 'android'
storeFile file('../libs/ftc.debug.keystore')
storePassword 'android'
}
/**
* Top-level build file for ftc_app project.
*
* It is extraordinarily rare that you will ever need to edit this file.
*/
buildscript {
repositories {
jcenter()
}

defaultConfig {
minSdkVersion 19
targetSdkVersion 19

/**
* We keep the versionCode and versionName of robot controller applications in sync with
* the master information published in the AndroidManifest.xml file of the FtcRobotController
* module. This helps avoid confusion that might arise from having multiple versions of
* a robot controller app simultaneously installed on a robot controller device.
*
* We accomplish this with the help of a funky little Groovy script that maintains that
* correspondence automatically.
*
* @see <a href="http://developer.android.com/tools/building/configuring-gradle.html">Configure Your Build</a>
* @see <a href="http://developer.android.com/tools/publishing/versioning.html">Versioning Your App</a>
*/
def manifestFile = file('../FtcRobotController/src/main/AndroidManifest.xml');
def manifestText = manifestFile.getText()
//
def vCodePattern = Pattern.compile("versionCode=\"(\\d+(\\.\\d+)*)\"")
def matcher = vCodePattern.matcher(manifestText)
matcher.find()
def vCode = Integer.parseInt(matcher.group(1))
//
def vNamePattern = Pattern.compile("versionName=\"(.*)\"")
matcher = vNamePattern.matcher(manifestText);
matcher.find()
def vName = matcher.group(1)
//
versionCode vCode
versionName vName
}

// Advanced user code might just want to use Vuforia directly, so we set up the libs as needed
buildTypes {
release {
debuggable true
ndk {
abiFilters "armeabi-v7a"
}
}
debug {
debuggable true
ndk {
abiFilters "armeabi-v7a"
}
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir "../libs"
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}

repositories {
flatDir {
dirs '../libs'
}
jcenter()
}

apply from: 'build.release.gradle'
16 changes: 0 additions & 16 deletions build.release.gradle

This file was deleted.

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
77 changes: 77 additions & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// build.gradle in TeamCode
//
// Most of the definitions for building your module reside in a common, shared
// file 'build.common.gradle'. Being factored in this way makes it easier to
// integrate updates to the FTC into your code. If you really need to customize
// the build definitions, you can place those customizations in this file, but
// please think carefully as to whether such customizations are really necessary
// before doing so.

// Custom definitions may go here

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

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

group = 'com.github.Pattonville-Robotics'

android {

compileSdkVersion 26
buildToolsVersion '26.0.2'

signingConfigs {
debug {
keyAlias 'androiddebugkey'
keyPassword 'android'
storeFile file('../libs/ftc.debug.keystore')
storePassword 'android'
}
}

defaultConfig {
minSdkVersion 19
targetSdkVersion 26
}

// Advanced user code might just want to use Vuforia directly, so we set up the libs as needed
buildTypes {
release {
debuggable true
ndk {
abiFilters "armeabi-v7a"
}
}
debug {
debuggable true
ndk {
abiFilters "armeabi-v7a"
}
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir "../libs"
}
}

repositories {
flatDir {
dirs '../libs'
}
jcenter()
maven {
url "https://raw.githubusercontent.com/Pattonville-Robotics/ftc-lib-repo/mvn-repo/"
}
}

apply from: 'build.release.gradle'
15 changes: 15 additions & 0 deletions library/build.release.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
dependencies {
compile 'org.first.ftc:inspection:3.4'
compile 'org.first.ftc:blocks:3.4'
compile 'org.first.ftc:robotcore:3.4'
compile 'org.first.ftc:hardware:3.4'
compile 'org.first.ftc:ftc-common:3.4'
compile 'org.first.ftc:analytics:3.4'
compile 'org.first.ftc:wireless-p2p:3.4'

// https://mvnrepository.com/artifact/org.apache.commons/commons-math3
compile group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'

// https://mvnrepository.com/artifact/com.annimon/stream
compile group: 'com.annimon', name: 'stream', version: '1.1.8'
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ are permitted (subject to the limitations in the disclaimer below) provided that
*/
package org.pattonvillerobotics.commoncode.opmodes;

import com.qualcomm.ftcrobotcontroller.R;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
Expand All @@ -58,34 +57,34 @@ are permitted (subject to the limitations in the disclaimer below) provided that
* This OpMode illustrates the basics of using the Vuforia localizer to determine
* positioning and orientation of robot on the FTC field.
* The code is structured as a LinearOpMode
*
* <p>
* Vuforia uses the phone's camera to inspect it's surroundings, and attempt to locate target images.
*
* <p>
* When images are located, Vuforia is able to determine the position and orientation of the
* image relative to the camera. This sample code than combines that information with a
* knowledge of where the target images are on the field, to determine the location of the camera.
*
* <p>
* This example assumes a "diamond" field configuration where the red and blue alliance stations
* are adjacent on the corner of the field furthest from the audience.
* From the Audience perspective, the Red driver station is on the right.
* The two vision target are located on the two walls closest to the audience, facing in.
* The Stones are on the RED side of the field, and the Chips are on the Blue side.
*
* <p>
* A final calculation then uses the location of the camera on the robot to determine the
* robot's location and orientation on the field.
*
* @see VuforiaLocalizer
* @see VuforiaTrackableDefaultListener
* see ftc_app/doc/tutorial/FTC_FieldCoordinateSystemDefinition.pdf
*
* <p>
* Use Android Studio to Copy this Class, and Paste it into your team's code folder with a new name.
* Remove or comment out the @Disabled line to add this opmode to the Driver Station OpMode list.
*
* <p>
* IMPORTANT: In order to use this OpMode, you need to obtain your own Vuforia license key as
* is explained below.
*/

@TeleOp(name="Modified Vuforia Navigation", group ="Concept")
@TeleOp(name = "Modified Vuforia Navigation", group = "Concept")
@Disabled
public class ConceptVuforiaNavigation extends LinearOpMode {

Expand All @@ -99,7 +98,8 @@ public class ConceptVuforiaNavigation extends LinearOpMode {
*/
VuforiaLocalizer vuforia;

@Override public void runOpMode() throws InterruptedException {
@Override
public void runOpMode() throws InterruptedException {
/**
* Start up Vuforia, telling it the id of the view that we wish to use as the parent for
* the camera monitor feedback; if no camera monitor feedback is desired, use the parameterless
Expand All @@ -123,7 +123,7 @@ public class ConceptVuforiaNavigation extends LinearOpMode {
* and paste it in to your code as the value of the 'vuforiaLicenseKey' field of the
* {@link Parameters} instance with which you initialize Vuforia.
*/
VuforiaLocalizer.Parameters parameters = new VuforiaLocalizer.Parameters(R.id.cameraMonitorViewId);
VuforiaLocalizer.Parameters parameters = new VuforiaLocalizer.Parameters(/*R.id.cameraMonitorViewId*/-1);
parameters.vuforiaLicenseKey = "AclLpHb/////AAAAGa41kVT84EtWtYJZW0bIHf9DHg5EHVYWCqExQMx6bbuBtjFeYdvzZLExJiXnT31qDi3WI3QQnOXH8pLZ4cmb39d1w0Oi7aCwy35ODjMvG5qX+e2+3v0l3r1hPpM8P7KPTkRPIl+CGYEBvoNkVbGGjalCW7N9eFDV/T5CN/RQvZjonX/uBPKkEd8ciqK8vWgfy9aPEipAoyr997DDagnMQJ0ajpwKn/SAfaVPA4osBZ5euFf07/3IUnpLEMdMKfoIH6QYLVgwbPuVtUiJWM6flzWaAw5IIhy0XXWwI0nGXrzVjPwZlN3El4Su73ADK36qqOax/pNxD4oYBrlpfYiaFaX0Q+BNro09weXQEoz/Mfgm";
parameters.cameraDirection = VuforiaLocalizer.CameraDirection.BACK;
this.vuforia = ClassFactory.createVuforiaLocalizer(parameters);
Expand All @@ -140,7 +140,7 @@ public class ConceptVuforiaNavigation extends LinearOpMode {
VuforiaTrackable redTarget = stonesAndChips.get(0);
redTarget.setName("RedTarget"); // Stones

VuforiaTrackable blueTarget = stonesAndChips.get(1);
VuforiaTrackable blueTarget = stonesAndChips.get(1);
blueTarget.setName("BlueTarget"); // Chips

/** For convenience, gather together all the trackable objects in one easily-iterable collection */
Expand All @@ -154,9 +154,9 @@ public class ConceptVuforiaNavigation extends LinearOpMode {
* You don't *have to* use mm here, but the units here and the units used in the XML
* target configuration files *must* correspond for the math to work out correctly.
*/
float mmPerInch = 25.4f;
float mmBotWidth = 18 * mmPerInch; // ... or whatever is right for your robot
float mmFTCFieldWidth = (12*12 - 2) * mmPerInch; // the FTC field is ~11'10" center-to-center of the glass panels
float mmPerInch = 25.4f;
float mmBotWidth = 18 * mmPerInch; // ... or whatever is right for your robot
float mmFTCFieldWidth = (12 * 12 - 2) * mmPerInch; // the FTC field is ~11'10" center-to-center of the glass panels

/**
* In order for localization to work, we need to tell the system where each target we
Expand Down Expand Up @@ -275,8 +275,8 @@ public class ConceptVuforiaNavigation extends LinearOpMode {
* listener is a {@link VuforiaTrackableDefaultListener} and can so safely cast because
* we have not ourselves installed a listener of a different type.
*/
((VuforiaTrackableDefaultListener)redTarget.getListener()).setPhoneInformation(phoneLocationOnRobot, parameters.cameraDirection);
((VuforiaTrackableDefaultListener)blueTarget.getListener()).setPhoneInformation(phoneLocationOnRobot, parameters.cameraDirection);
((VuforiaTrackableDefaultListener) redTarget.getListener()).setPhoneInformation(phoneLocationOnRobot, parameters.cameraDirection);
((VuforiaTrackableDefaultListener) blueTarget.getListener()).setPhoneInformation(phoneLocationOnRobot, parameters.cameraDirection);

/**
* A brief tutorial: here's how all the math is going to work:
Expand Down Expand Up @@ -313,9 +313,9 @@ public class ConceptVuforiaNavigation extends LinearOpMode {
* the last time that call was made, or if the trackable is not currently visible.
* getRobotLocation() will return null if the trackable is not currently visible.
*/
telemetry.addData(trackable.getName(), ((VuforiaTrackableDefaultListener)trackable.getListener()).isVisible() ? "Visible" : "Not Visible"); //
telemetry.addData(trackable.getName(), ((VuforiaTrackableDefaultListener) trackable.getListener()).isVisible() ? "Visible" : "Not Visible"); //

OpenGLMatrix robotLocationTransform = ((VuforiaTrackableDefaultListener)trackable.getListener()).getUpdatedRobotLocation();
OpenGLMatrix robotLocationTransform = ((VuforiaTrackableDefaultListener) trackable.getListener()).getUpdatedRobotLocation();
if (robotLocationTransform != null) {
lastLocation = robotLocationTransform;
}
Expand All @@ -339,10 +339,10 @@ public class ConceptVuforiaNavigation extends LinearOpMode {
// if to the right by more than half inch, tell it to go left
if (right > 0.5) {
telemetry.addData("Go", "left");
// if to the left by more than half inch, tell it to go right
// if to the left by more than half inch, tell it to go right
} else if (right < -0.5) {
telemetry.addData("Go", "right");
// on track
// on track
} else {
telemetry.addData("Go", "straight");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;

import org.firstinspires.ftc.robotcore.external.Telemetry;
import org.pattonvillerobotics.commoncode.R;
import org.pattonvillerobotics.commoncode.robotclasses.vuforia.VuforiaNavigation;
import org.pattonvillerobotics.commoncode.robotclasses.vuforia.VuforiaParameters;

@TeleOp(name="VuforiaTest", group=OpModeGroups.TESTING)
@TeleOp(name = "VuforiaTest", group = OpModeGroups.TESTING)
public class VuforiaTest extends LinearOpMode {

private VuforiaNavigation vuforia;

@Override
public void runOpMode() throws InterruptedException {
vuforia = new VuforiaNavigation(new VuforiaParameters.Builder()
.cameraMonitorViewId(R.id.cameraMonitorViewId)
.licenseKey("AclLpHb/////AAAAGa41kVT84EtWtYJZW0bIHf9DHg5EHVYWCqExQMx6bbuBtjFeYdvzZLExJiXnT31qDi3WI3QQnOXH8pLZ4cmb39d1w0Oi7aCwy35ODjMvG5qX+e2+3v0l3r1hPpM8P7KPTkRPIl+CGYEBvoNkVbGGjalCW7N9eFDV/T5CN/RQvZjonX/uBPKkEd8ciqK8vWgfy9aPEipAoyr997DDagnMQJ0ajpwKn/SAfaVPA4osBZ5euFf07/3IUnpLEMdMKfoIH6QYLVgwbPuVtUiJWM6flzWaAw5IIhy0XXWwI0nGXrzVjPwZlN3El4Su73ADK36qqOax/pNxD4oYBrlpfYiaFaX0Q+BNro09weXQEoz/Mfgm")
.build());
.cameraMonitorViewId(/*R.id.cameraMonitorViewId*/-1)
.licenseKey("AclLpHb/////AAAAGa41kVT84EtWtYJZW0bIHf9DHg5EHVYWCqExQMx6bbuBtjFeYdvzZLExJiXnT31qDi3WI3QQnOXH8pLZ4cmb39d1w0Oi7aCwy35ODjMvG5qX+e2+3v0l3r1hPpM8P7KPTkRPIl+CGYEBvoNkVbGGjalCW7N9eFDV/T5CN/RQvZjonX/uBPKkEd8ciqK8vWgfy9aPEipAoyr997DDagnMQJ0ajpwKn/SAfaVPA4osBZ5euFf07/3IUnpLEMdMKfoIH6QYLVgwbPuVtUiJWM6flzWaAw5IIhy0XXWwI0nGXrzVjPwZlN3El4Su73ADK36qqOax/pNxD4oYBrlpfYiaFaX0Q+BNro09weXQEoz/Mfgm")
.build());

Telemetry.Item vuforiaX = telemetry.addData("Robot X", "0").setRetained(true);
Telemetry.Item vuforiaY = telemetry.addData("Robot Y", "0").setRetained(true);
Expand All @@ -31,7 +30,7 @@ public void runOpMode() throws InterruptedException {
vuforia.activateTracking();
waitForStart();

while(opModeIsActive()) {
while (opModeIsActive()) {
vuforia.getVisibleTrackableLocation();

currentRelic.setValue(vuforia.getCurrentVisibleRelic());
Expand Down
Loading

0 comments on commit 90c3677

Please sign in to comment.