-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
349 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
apply from: '../moduleFlavors.gradle' | ||
android { | ||
compileSdkVersion 28 | ||
buildToolsVersion '28.0.3' | ||
|
||
defaultConfig { | ||
minSdkVersion 19 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
repositories { | ||
flatDir { | ||
dirs '../libs' | ||
} | ||
} | ||
dependencies { | ||
// implementation project(path: ':openCVLibrary3') | ||
// implementation (name: 'RobotCore-release', ext: 'aar') | ||
|
||
implementation project(':FtcRobotController') | ||
|
||
|
||
//THESE 2 | ||
api 'org.openftc:easyopencv:1.3.2' | ||
api 'org.openftc:opencv-repackaged:4.1.0-B' | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
|
||
package="org.futurerobotics.bluejay"> | ||
|
||
<application android:allowBackup="true" android:label="@string/app_name" | ||
android:supportsRtl="true"> | ||
|
||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
//package localizers; | ||
// | ||
//import com.qualcomm.robotcore.eventloop.opmode.OpMode; | ||
//import org.firstinspires.ftc.robotcore.external.navigation.*; | ||
// | ||
//public class IMU implements deltaLocalizer { | ||
// BNO055IMU imu; | ||
// OpMode opmode; | ||
// | ||
// Orientation lastAngle = new Orientation(); | ||
// Position lastPos = new Position(); | ||
// | ||
// double deltaAngle; | ||
// Position deltaPos; | ||
// | ||
// volatile boolean activated = false; | ||
// | ||
// public IMU(OpMode opMode) { | ||
// | ||
// this.opmode = opMode; | ||
// | ||
// BNO055IMU.Parameters parameters = new BNO055IMU.Parameters(); | ||
// | ||
// parameters.mode = BNO055IMU.SensorMode.IMU; | ||
// parameters.angleUnit = BNO055IMU.AngleUnit.DEGREES; | ||
// parameters.accelUnit = BNO055IMU.AccelUnit.METERS_PERSEC_PERSEC; | ||
// parameters.loggingEnabled = false; | ||
// | ||
// //TODO assumption that that thing is named "imu" | ||
// imu = opmode.hardwareMap.get(BNO055IMU.class, "imu"); | ||
// | ||
// imu.initialize(parameters); | ||
// | ||
// //watchdog | ||
// long start = System.currentTimeMillis(); | ||
// //make sure the imu gyro is calibrated before continuing. | ||
// while (!imu.isGyroCalibrated()) { | ||
// if (System.currentTimeMillis() - start > 500) { | ||
// opmode.telemetry.addData("IMU", "watchdig quit"); | ||
// opmode.telemetry.update(); | ||
// | ||
// break; | ||
// } | ||
// | ||
// //wait | ||
// opmode.telemetry.addData("IMU", ("Loading" + Math.random())); | ||
// opmode.telemetry.update(); | ||
// } | ||
// | ||
// opmode.telemetry.addData("IMU", "startup done"); | ||
// opmode.telemetry.update(); | ||
// } | ||
// | ||
// public void start() { | ||
// resetAngle(); | ||
// } | ||
// | ||
// /** | ||
// * Resets the cumulative angle tracking to zero. | ||
// */ | ||
// private void resetAngle() { | ||
// lastAngle = imu.getAngularOrientation(AxesReference.INTRINSIC, AxesOrder.ZYX, AngleUnit.DEGREES); | ||
// lastPos = imu.getPosition(); | ||
// | ||
// deltaAngle = 0; | ||
// deltaPos = new Position(); | ||
// } | ||
// | ||
// public void stop() { | ||
// } | ||
// | ||
// /** | ||
// * call this as fast as you can! | ||
// * return difference in orientation to when you last called it | ||
// * (x,y) is currently broken. But it isn't accurate so you should never use it | ||
// * | ||
// * @return defaults to mm for position x and y | ||
// */ | ||
// public PoseOrientation getDeltaPosition() { | ||
// updatePos(); | ||
// return new PoseOrientation(deltaPos.x, deltaPos.y, deltaAngle); | ||
// } | ||
// | ||
// /** | ||
// * Based on the last time we called get angle, take the smallest possible rotation difference | ||
// * trig angles | ||
// */ | ||
// private void updatePos() { | ||
// //z axis is the one we want | ||
// | ||
// Orientation angle = imu.getAngularOrientation(AxesReference.INTRINSIC, AxesOrder.ZYX, AngleUnit.DEGREES); | ||
// Position pos = imu.getPosition(); | ||
// | ||
// //=========ANGLE============= | ||
// double deltaAngle = angle.firstAngle - lastAngle.firstAngle; | ||
// | ||
// if (deltaAngle < -180) | ||
// deltaAngle += 360; | ||
// | ||
// else if (deltaAngle > 180) | ||
// deltaAngle -= 360; | ||
// | ||
// this.deltaAngle = deltaAngle; | ||
// | ||
// lastAngle = angle; | ||
// //========POSITION========== | ||
// opmode.telemetry.addData("imu raw read", pos.x); | ||
// | ||
// deltaPos.x = pos.x - lastPos.x; | ||
// deltaPos.y = pos.y - lastPos.y; | ||
// | ||
// lastPos = pos; | ||
// } | ||
// | ||
// public void printposition(PoseOrientation toprint) { | ||
// if (toprint != null) { | ||
// opmode.telemetry.addData("IMU-Position (mm) (rot)", toprint.x + " " + toprint.y + " " + toprint.rot); | ||
// } else { | ||
// opmode.telemetry.addData("IMU", "offline"); | ||
// } | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package localizers; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class LocalizationManager { | ||
List<deltaLocalizer> delta = new ArrayList<>(); | ||
List<Localizer> absolute = new ArrayList<>(); | ||
|
||
PoseOrientation lastknowpos = new PoseOrientation(0, 0, 0); | ||
|
||
volatile boolean activated = false; | ||
|
||
Thread run = new Thread() { | ||
@Override | ||
public void run() { | ||
while (activated) { | ||
lastknowpos = getPosition(); | ||
} | ||
} | ||
}; | ||
|
||
/** | ||
* Gives a position based on the best combined guess of all localizers given to this class | ||
* Priority is as follows: absolute localizers first, first added to last added | ||
* relative localizers next, first added to last added | ||
*/ | ||
public PoseOrientation getPosition() { | ||
|
||
for (Localizer loc : absolute) { | ||
PoseOrientation o; | ||
if ((o = loc.getPosition()) != null) { | ||
lastknowpos = o; | ||
return o; | ||
} | ||
} | ||
|
||
for (deltaLocalizer loc : delta) { | ||
PoseOrientation o; | ||
if ((o = loc.getDeltaPosition()) != null) { | ||
lastknowpos.x += o.x; | ||
lastknowpos.y += o.y; | ||
lastknowpos.rot += o.rot; | ||
return o; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public void start() { | ||
activated = true; | ||
run.start(); | ||
} | ||
|
||
public void stop() { | ||
activated = false; | ||
} | ||
|
||
public void addLocalizer(deltaLocalizer l) { | ||
delta.add(l); | ||
} | ||
|
||
public void addLocalizer(Localizer l) { | ||
absolute.add(l); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package localizers; | ||
|
||
|
||
public interface Localizer { | ||
PoseOrientation getPosition(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package localizers; | ||
|
||
/** | ||
* Units in mm and degrees. | ||
*/ | ||
public class PoseOrientation { | ||
public double x; | ||
public double y; | ||
public double rot; | ||
|
||
public PoseOrientation(double x, double y, double rot) { | ||
this.x = x; | ||
this.y = y; | ||
this.rot = rot; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package localizers; | ||
|
||
public interface deltaLocalizer { | ||
PoseOrientation getDeltaPosition(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package util; | ||
|
||
import android.os.Environment; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
|
||
public class FileReadUtil { | ||
public static String readFromSD(){ | ||
File sdcard = Environment.getExternalStorageDirectory(); | ||
|
||
//Get the text file | ||
File file= new File(sdcard,"Vuforia Key.txt"); | ||
|
||
//Read text from file | ||
StringBuilder text = new StringBuilder(); | ||
|
||
try { | ||
BufferedReader br = new BufferedReader(new FileReader(file)); | ||
String line; | ||
|
||
while ((line = br.readLine()) != null) { | ||
text.append(line); | ||
text.append('\n'); | ||
} | ||
br.close(); | ||
} | ||
catch (IOException e) { | ||
} | ||
|
||
return text.toString(); | ||
} | ||
|
||
} |
Oops, something went wrong.