diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..755c411c06 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "FtcDashboard"] + path = FtcDashboard + url = https://github.com/acmerobotics/ftc-dashboard diff --git a/FtcDashboard b/FtcDashboard new file mode 160000 index 0000000000..e520044c7d --- /dev/null +++ b/FtcDashboard @@ -0,0 +1 @@ +Subproject commit e520044c7dd70dc21b1e52d9c5c8781771ea05f5 diff --git a/FtcRobotController/build.gradle b/FtcRobotController/build.gradle index b73fbe4f1a..4c676186c9 100644 --- a/FtcRobotController/build.gradle +++ b/FtcRobotController/build.gradle @@ -2,7 +2,6 @@ // build.gradle in FtcRobotController // apply plugin: 'com.android.library' - android { defaultConfig { @@ -18,11 +17,13 @@ android { targetCompatibility JavaVersion.VERSION_1_7 } } - repositories { flatDir { dirs '../libs' } } - apply from: 'build.release.gradle' + +dependencies { + implementation project(':FtcDashboard') +} \ No newline at end of file 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 4ec32fa431..0b7cf223d2 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 @@ -56,6 +56,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE import android.widget.LinearLayout; import android.widget.TextView; +import com.acmerobotics.dashboard.RobotDashboard; import com.google.blocks.ftcrobotcontroller.BlocksActivity; import com.google.blocks.ftcrobotcontroller.ProgrammingModeActivity; import com.google.blocks.ftcrobotcontroller.ProgrammingModeControllerImpl; @@ -305,6 +306,8 @@ public void onClick(View v) { ServiceController.startService(FtcRobotControllerWatchdogService.class); bindToService(); logPackageVersions(); + + RobotDashboard.start(); } protected UpdateUI createUpdateUI() { @@ -384,6 +387,8 @@ protected void onDestroy() { preferencesHelper.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener); RobotLog.cancelWriteLogcatToDisk(); + + RobotDashboard.stop(); } protected void bindToService() { @@ -582,6 +587,8 @@ private void requestRobotSetup() { controllerService.setupRobot(eventLoop, idleLoop); passReceivedUsbAttachmentsToEventLoop(); + + RobotDashboard.attachEventLoop(eventLoop); } protected OpModeRegister createOpModeRegister() { diff --git a/TeamCode/build.gradle b/TeamCode/build.gradle index 301ff64946..d95a595f03 100644 --- a/TeamCode/build.gradle +++ b/TeamCode/build.gradle @@ -7,9 +7,9 @@ // 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' +dependencies { + implementation project(':FtcDashboard') +} \ No newline at end of file diff --git a/TeamCode/build.release.gradle b/TeamCode/build.release.gradle index 17567abc8c..44644c4b4d 100644 --- a/TeamCode/build.release.gradle +++ b/TeamCode/build.release.gradle @@ -1,3 +1,8 @@ +repositories { + jcenter() + mavenLocal() +} + dependencies { compile project(':FtcRobotController') compile (name: 'RobotCore-release', ext: 'aar') @@ -5,4 +10,6 @@ dependencies { compile (name: 'FtcCommon-release', ext: 'aar') compile (name:'Analytics-release', ext:'aar') compile (name:'WirelessP2p-release', ext:'aar') -} + + compile 'com.acmerobotics.splinelib:core:0.1-SNAPSHOT' +} \ No newline at end of file diff --git a/TeamCode/src/main/assets/trajectory/test.yaml b/TeamCode/src/main/assets/trajectory/test.yaml new file mode 100644 index 0000000000..4dd3ac5387 --- /dev/null +++ b/TeamCode/src/main/assets/trajectory/test.yaml @@ -0,0 +1,13 @@ +--- +poses: +- x: 0.0 + y: 0.0 + heading: 0.0 +- x: 20.0 + y: 40.0 + heading: 0.0 +constraints: + maximumVelocity: 25.0 + maximumAcceleration: 40.0 + maximumAngularVelocity: 3.141592653589793 + maximumAngularAcceleration: 6.283185307179586 diff --git a/TeamCode/src/main/java/com/acmerobotics/splinelib/AssetsTrajectoryLoader.java b/TeamCode/src/main/java/com/acmerobotics/splinelib/AssetsTrajectoryLoader.java new file mode 100644 index 0000000000..636b7c65d4 --- /dev/null +++ b/TeamCode/src/main/java/com/acmerobotics/splinelib/AssetsTrajectoryLoader.java @@ -0,0 +1,29 @@ +package com.acmerobotics.splinelib; + +import com.acmerobotics.splinelib.trajectory.Trajectory; +import com.acmerobotics.splinelib.trajectory.TrajectoryConfig; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.fasterxml.jackson.module.kotlin.KotlinModule; + +import org.firstinspires.ftc.robotcore.internal.system.AppUtil; + +import java.io.IOException; +import java.io.InputStream; + +public class AssetsTrajectoryLoader { + private static final ObjectMapper MAPPER = new ObjectMapper(new YAMLFactory()); + + static { + MAPPER.registerModule(new KotlinModule((512))); + } + + public static TrajectoryConfig loadConfig(String name) throws IOException { + InputStream inputStream = AppUtil.getDefContext().getAssets().open("trajectory/" + name + ".yaml"); + return MAPPER.readValue(inputStream, TrajectoryConfig.class); + } + + public static Trajectory load(String name) throws IOException { + return loadConfig(name).toTrajectory(); + } +} diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/TestOpMode.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/TestOpMode.java new file mode 100644 index 0000000000..42c3120b5e --- /dev/null +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/TestOpMode.java @@ -0,0 +1,22 @@ +package org.firstinspires.ftc.teamcode; + +import com.acmerobotics.splinelib.AssetsTrajectoryLoader; +import com.acmerobotics.splinelib.trajectory.Trajectory; +import com.qualcomm.robotcore.eventloop.opmode.Autonomous; +import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; + +import java.io.IOException; + +@Autonomous +public class TestOpMode extends LinearOpMode { + + @Override + public void runOpMode() throws InterruptedException { + try { + Trajectory trajectory = AssetsTrajectoryLoader.load("test"); + System.out.println(trajectory.duration()); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/readme.md b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/readme.md deleted file mode 100644 index 2f7e3a4aa5..0000000000 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/readme.md +++ /dev/null @@ -1,121 +0,0 @@ -## TeamCode Module - -Welcome! - -This module, TeamCode, is the place where you will write/paste the code for your team's -robot controller App. This module is currently empty (a clean slate) but the -process for adding OpModes is straightforward. - -## Creating your own OpModes - -The easiest way to create your own OpMode is to copy a Sample OpMode and make it your own. - -Sample opmodes exist in the FtcRobotController module. -To locate these samples, find the FtcRobotController module in the "Project/Android" tab. - -Expand the following tree elements: - FtcRobotController / java / org.firstinspires.ftc.robotcontroller / external / samples - -A range of different samples classes can be seen in this folder. -The class names follow a naming convention which indicates the purpose of each class. -The full description of this convention is found in the samples/sample_convention.md file. - -A brief synopsis of the naming convention is given here: -The prefix of the name will be one of the following: - -* Basic: This is a minimally functional OpMode used to illustrate the skeleton/structure - of a particular style of OpMode. These are bare bones examples. -* Sensor: This is a Sample OpMode that shows how to use a specific sensor. - It is not intended as a functioning robot, it is simply showing the minimal code - required to read and display the sensor values. -* Hardware: This is not an actual OpMode, but a helper class that is used to describe - one particular robot's hardware devices: eg: for a Pushbot. Look at any - Pushbot sample to see how this can be used in an OpMode. - Teams can copy one of these to create their own robot definition. -* Pushbot: This is a Sample OpMode that uses the Pushbot robot structure as a base. -* Concept: This is a sample OpMode that illustrates performing a specific function or concept. - These may be complex, but their operation should be explained clearly in the comments, - or the header should reference an external doc, guide or tutorial. -* Library: This is a class, or set of classes used to implement some strategy. - These will typically NOT implement a full OpMode. Instead they will be included - by an OpMode to provide some stand-alone capability. - -Once you are familiar with the range of samples available, you can choose one to be the -basis for your own robot. In all cases, the desired sample(s) needs to be copied into -your TeamCode module to be used. - -This is done inside Android Studio directly, using the following steps: - - 1) Locate the desired sample class in the Project/Android tree. - - 2) Right click on the sample class and select "Copy" - - 3) Expand the TeamCode / java folder - - 4) Right click on the org.firstinspires.ftc.teamcode folder and select "Paste" - - 5) You will be prompted for a class name for the copy. - Choose something meaningful based on the purpose of this class. - Start with a capital letter, and remember that there may be more similar classes later. - -Once your copy has been created, you should prepare it for use on your robot. -This is done by adjusting the OpMode's name, and enabling it to be displayed on the -Driver Station's OpMode list. - -Each OpMode sample class begins with several lines of code like the ones shown below: - -``` - @TeleOp(name="Template: Linear OpMode", group="Linear Opmode") - @Disabled -``` - -The name that will appear on the driver station's "opmode list" is defined by the code: - ``name="Template: Linear OpMode"`` -You can change what appears between the quotes to better describe your opmode. -The "group=" portion of the code can be used to help organize your list of OpModes. - -As shown, the current OpMode will NOT appear on the driver station's OpMode list because of the - ``@Disabled`` annotation which has been included. -This line can simply be deleted , or commented out, to make the OpMode visible. - - - -## ADVANCED Multi-Team App management: Cloning the TeamCode Module - -In some situations, you have multiple teams in your club and you want them to all share -a common code organization, with each being able to *see* the others code but each having -their own team module with their own code that they maintain themselves. - -In this situation, you might wish to clone the TeamCode module, once for each of these teams. -Each of the clones would then appear along side each other in the Android Studio module list, -together with the FtcRobotController module (and the original TeamCode module). - -Selective Team phones can then be programmed by selecting the desired Module from the pulldown list -prior to clicking to the green Run arrow. - -Warning: This is not for the inexperienced Software developer. -You will need to be comfortable with File manipulations and managing Android Studio Modules. -These changes are performed OUTSIDE of Android Studios, so close Android Studios before you do this. - -Also.. Make a full project backup before you start this :) - -To clone TeamCode, do the following: - -Note: Some names start with "Team" and others start with "team". This is intentional. - -1) Using your operating system file management tools, copy the whole "TeamCode" - folder to a sibling folder with a corresponding new name, eg: "Team0417". - -2) In the new Team0417 folder, delete the TeamCode.iml file. - -3) the new Team0417 folder, rename the "src/main/java/org/firstinspires/ftc/teamcode" folder - to a matching name with a lowercase 'team' eg: "team0417". - -4) In the new Team0417/src/main folder, edit the "AndroidManifest.xml" file, change the line that contains - package="org.firstinspires.ftc.teamcode" - to be - package="org.firstinspires.ftc.team0417" - -5) Add: include ':Team0417' to the "/settings.gradle" file. - -6) Open up Android Studios and clean out any old files by using the menu to "Build/Clean Project"" \ No newline at end of file diff --git a/build.common.gradle b/build.common.gradle index 7972001e97..108a39b6ae 100644 --- a/build.common.gradle +++ b/build.common.gradle @@ -21,7 +21,7 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 23 + compileSdkVersion 27 buildToolsVersion '25.0.3' signingConfigs { @@ -35,8 +35,8 @@ android { defaultConfig { applicationId 'com.qualcomm.ftcrobotcontroller' - minSdkVersion 19 - targetSdkVersion 19 + minSdkVersion 21 + targetSdkVersion 27 /** * We keep the versionCode and versionName of robot controller applications in sync with @@ -85,8 +85,8 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 } sourceSets.main { diff --git a/build.gradle b/build.gradle index a267db58fc..c4c4ebffa1 100644 --- a/build.gradle +++ b/build.gradle @@ -6,10 +6,27 @@ buildscript { repositories { jcenter() + maven { + url 'https://maven.google.com/' + name 'Google' + } } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' + classpath 'com.android.tools.build:gradle:3.1.3' } } + +repositories { + maven { + url 'https://maven.google.com/' + name 'Google' + } +} + +allprojects { + repositories { + jcenter() + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000000..899c9f99f3 --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +org.gradle.jvmargs=-Xmx2048m diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index eda15e1bb9..1865d8850f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ -#Thu Jun 01 08:33:11 PDT 2017 +#Sun Jul 29 18:03:48 PDT 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip - +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/settings.gradle b/settings.gradle index 9e2cfb3b4b..c68b0cd135 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,3 @@ include ':FtcRobotController' include ':TeamCode' +include ':FtcDashboard' \ No newline at end of file