fdfddfd
This commit is contained in:
parent
12f912bfa0
commit
3b33d797cb
59
build.gradle
59
build.gradle
|
@ -1,28 +1,15 @@
|
||||||
buildscript {
|
apply plugin: "com.android.library"
|
||||||
ext.kotlin_version = '1.9.0'
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
google()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'com.android.tools.build:gradle:8.2.2'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'maven-publish'
|
|
||||||
apply plugin: 'com.android.library'
|
|
||||||
|
|
||||||
group = 'com.github.tearabite'
|
|
||||||
|
|
||||||
|
version = "release-SNAPSHOT"
|
||||||
android {
|
android {
|
||||||
namespace = 'com.tearabite.ftctearabits'
|
//
|
||||||
compileSdkVersion 29
|
namespace = 'com.tearabite.ielib'
|
||||||
|
compileSdkVersion 28
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 24
|
minSdkVersion 24
|
||||||
//noinspection ExpiredTargetSdkVersion
|
//noinspection ExpiredTargetSdkVersion
|
||||||
targetSdkVersion 28
|
targetSdkVersion 26
|
||||||
multiDexEnabled true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
@ -30,36 +17,44 @@ android {
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
release { }
|
|
||||||
debug { }
|
|
||||||
}
|
|
||||||
testOptions {
|
testOptions {
|
||||||
unitTests.all {
|
unitTests.all {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lintOptions {
|
||||||
|
abortOnError false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
maven { url = 'https://maven.brott.dev/' }
|
||||||
url = 'https://maven.brott.dev/'
|
|
||||||
}
|
}
|
||||||
google()
|
|
||||||
|
ext {
|
||||||
|
dashboard_version = "0.5.6"
|
||||||
|
min_sdk_version = "9.1.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.firstinspires.ftc:RobotCore:9.1.0'
|
api "org.firstinspires.ftc:RobotCore:$min_sdk_version"
|
||||||
implementation 'org.firstinspires.ftc:Vision:9.1.0'
|
api "org.firstinspires.ftc:Hardware:$min_sdk_version"
|
||||||
|
api "org.firstinspires.ftc:RobotServer:$min_sdk_version"
|
||||||
implementation 'com.acmerobotics.roadrunner:core:1.0.0-beta6'
|
api "org.firstinspires.ftc:FtcCommon:$min_sdk_version"
|
||||||
implementation 'com.acmerobotics.roadrunner:actions:1.0.0-beta6'
|
api "org.firstinspires.ftc:Vision:$min_sdk_version"
|
||||||
implementation 'com.acmerobotics.dashboard:dashboard:0.4.15'
|
|
||||||
|
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
|
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
|
||||||
|
|
||||||
//noinspection AnnotationProcessorOnCompilePath
|
//noinspection AnnotationProcessorOnCompilePath
|
||||||
compileOnly 'org.projectlombok:lombok:1.18.30'
|
compileOnly 'org.projectlombok:lombok:1.18.30'
|
||||||
annotationProcessor 'org.projectlombok:lombok:1.18.30'
|
annotationProcessor 'org.projectlombok:lombok:1.18.30'
|
||||||
|
|
||||||
|
implementation 'com.acmerobotics.roadrunner:core:0.5.6'
|
||||||
|
}
|
||||||
|
|
||||||
|
task androidSourcesJar(type: Jar) {
|
||||||
|
classifier = "sources"
|
||||||
|
from android.sourceSets.main.java.srcDirs
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
#Thu Feb 29 12:54:16 CST 2024
|
#Thu Feb 29 12:54:16 CST 2024
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
@ -1,10 +1,2 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.tearabite.ielib" />
|
||||||
<!-- Note: the actual manifest file used in your APK merges this file with contributions
|
|
||||||
from the modules on which your app depends (such as FtcRobotController, etc).
|
|
||||||
So it won't ultimately be as empty as it might here appear to be :-) -->
|
|
||||||
|
|
||||||
<!-- The package name here determines the package for your R class and your BuildConfig class -->
|
|
||||||
<manifest>
|
|
||||||
<application/>
|
|
||||||
</manifest>
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.tearabite.ftctearabits.common;
|
package com.tearabite.ielib.common;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum for the two alliances in FTC
|
* Enum for the two alliances in FTC
|
|
@ -1,4 +1,4 @@
|
||||||
package com.tearabite.ftctearabits.graphics;
|
package com.tearabite.ielib.graphics;
|
||||||
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.tearabite.ftctearabits.localization;
|
package com.tearabite.ielib.localization;
|
||||||
|
|
||||||
import static java.lang.Math.PI;
|
import static java.lang.Math.PI;
|
||||||
import static java.lang.Math.asin;
|
import static java.lang.Math.asin;
|
||||||
|
@ -7,7 +7,7 @@ import static java.lang.Math.cos;
|
||||||
import static java.lang.Math.pow;
|
import static java.lang.Math.pow;
|
||||||
import static java.lang.Math.sin;
|
import static java.lang.Math.sin;
|
||||||
|
|
||||||
import com.acmerobotics.roadrunner.Pose2d;
|
import com.acmerobotics.roadrunner.geometry.Pose2d;
|
||||||
|
|
||||||
import org.firstinspires.ftc.robotcore.external.matrices.VectorF;
|
import org.firstinspires.ftc.robotcore.external.matrices.VectorF;
|
||||||
import org.firstinspires.ftc.robotcore.external.navigation.Quaternion;
|
import org.firstinspires.ftc.robotcore.external.navigation.Quaternion;
|
||||||
|
@ -81,9 +81,9 @@ public class AprilTagPoseEstimator {
|
||||||
double cx = Tx + range * cos(bearing) * cos(ch) + range * sin(bearing) * sin(ch);
|
double cx = Tx + range * cos(bearing) * cos(ch) + range * sin(bearing) * sin(ch);
|
||||||
double cy = Ty + range * cos(bearing) * sin(ch) - range * sin(bearing) * cos(ch);
|
double cy = Ty + range * cos(bearing) * sin(ch) - range * sin(bearing) * cos(ch);
|
||||||
|
|
||||||
double offsetX = this.robotOffset.position.x;
|
double offsetX = this.robotOffset.getX();
|
||||||
double offsetY = this.robotOffset.position.y;
|
double offsetY = this.robotOffset.getY();
|
||||||
double Cyaw = this.robotOffset.heading.toDouble();
|
double Cyaw = this.robotOffset.getHeading();
|
||||||
double rh = (PI / 2) + Tyaw + yaw - Cyaw;
|
double rh = (PI / 2) + Tyaw + yaw - Cyaw;
|
||||||
double rx = cx + offsetX * cos(rh) - offsetY * sin(rh);
|
double rx = cx + offsetX * cos(rh) - offsetY * sin(rh);
|
||||||
double ry = cy + offsetX * sin(rh) + offsetY * cos(rh);
|
double ry = cy + offsetX * sin(rh) + offsetY * cos(rh);
|
|
@ -1,13 +1,15 @@
|
||||||
package com.tearabite.ftctearabits.vision;
|
package com.tearabite.ielib.vision;
|
||||||
|
|
||||||
import static com.tearabite.ftctearabits.graphics.LinePaint.WHITE;
|
import static com.tearabite.ielib.graphics.LinePaint.WHITE;
|
||||||
import static com.tearabite.ftctearabits.vision.FTCColors.FTC_BLUE_RANGE;
|
import static com.tearabite.ielib.vision.FTCColors.FTC_BLUE_RANGE;
|
||||||
import static com.tearabite.ftctearabits.vision.FTCColors.FTC_RED_RANGE_1;
|
import static com.tearabite.ielib.vision.FTCColors.FTC_RED_RANGE_1;
|
||||||
import static com.tearabite.ftctearabits.vision.FTCColors.FTC_RED_RANGE_2;
|
import static com.tearabite.ielib.vision.FTCColors.FTC_RED_RANGE_2;
|
||||||
import static com.tearabite.ftctearabits.vision.OpenCVUtil.getLargestContour;
|
import static com.tearabite.ielib.vision.OpenCVUtil.getLargestContour;
|
||||||
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
|
||||||
|
import com.tearabite.ielib.graphics.LinePaint;
|
||||||
|
|
||||||
import org.firstinspires.ftc.robotcore.internal.camera.calibration.CameraCalibration;
|
import org.firstinspires.ftc.robotcore.internal.camera.calibration.CameraCalibration;
|
||||||
import org.firstinspires.ftc.vision.VisionProcessor;
|
import org.firstinspires.ftc.vision.VisionProcessor;
|
||||||
import org.opencv.core.Core;
|
import org.opencv.core.Core;
|
||||||
|
@ -105,7 +107,7 @@ public class BasicColorDetectionVisionProcessor implements VisionProcessor {
|
||||||
public void onDrawFrame(Canvas canvas, int onscreenWidth, int onscreenHeight, float scaleBmpPxToCanvasPx, float scaleCanvasDensity, Object userContext) {
|
public void onDrawFrame(Canvas canvas, int onscreenWidth, int onscreenHeight, float scaleBmpPxToCanvasPx, float scaleCanvasDensity, Object userContext) {
|
||||||
if (detection != null && detection.isValid()) {
|
if (detection != null && detection.isValid()) {
|
||||||
Point center = detection.getCenter();
|
Point center = detection.getCenter();
|
||||||
canvas.drawCircle((float) center.x, (float) center.y, 10, WHITE);
|
canvas.drawCircle((float) center.x, (float) center.y, 10, LinePaint.WHITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.tearabite.ftctearabits.vision;
|
package com.tearabite.ielib.vision;
|
||||||
|
|
||||||
import static com.tearabite.ftctearabits.vision.OpenCVUtil.getCenterOfContour;
|
import static com.tearabite.ielib.vision.OpenCVUtil.getCenterOfContour;
|
||||||
|
|
||||||
import org.opencv.core.MatOfPoint;
|
import org.opencv.core.MatOfPoint;
|
||||||
import org.opencv.core.Point;
|
import org.opencv.core.Point;
|
||||||
|
@ -77,7 +77,7 @@ public class Detection {
|
||||||
return INVALID_POINT;
|
return INVALID_POINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point centerPx = getCenterOfContour(this.contour);
|
Point centerPx = OpenCVUtil.getCenterOfContour(this.contour);
|
||||||
if (scale == PropertyScale.Pixels) {
|
if (scale == PropertyScale.Pixels) {
|
||||||
return centerPx;
|
return centerPx;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.tearabite.ftctearabits.vision;
|
package com.tearabite.ielib.vision;
|
||||||
|
|
||||||
import org.opencv.core.Scalar;
|
import org.opencv.core.Scalar;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.tearabite.ftctearabits.vision;
|
package com.tearabite.ielib.vision;
|
||||||
|
|
||||||
import org.opencv.core.Mat;
|
import org.opencv.core.Mat;
|
||||||
import org.opencv.core.MatOfInt;
|
import org.opencv.core.MatOfInt;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.tearabite.ftctearabits.vision;
|
package com.tearabite.ielib.vision;
|
||||||
|
|
||||||
import org.opencv.core.Scalar;
|
import org.opencv.core.Scalar;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package com.tearabite.ftctearabits.localization;
|
package com.tearabite.ielib.localization.localization;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
import com.acmerobotics.roadrunner.Pose2d;
|
import com.acmerobotics.roadrunner.geometry.Pose2d;
|
||||||
|
import com.tearabite.ielib.localization.AprilTagPoseEstimator;
|
||||||
|
|
||||||
import org.firstinspires.ftc.robotcore.external.matrices.VectorF;
|
import org.firstinspires.ftc.robotcore.external.matrices.VectorF;
|
||||||
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
|
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
|
||||||
|
@ -19,7 +20,7 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import java.security.InvalidParameterException;
|
import java.security.InvalidParameterException;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
class AprilTagPoseEstimatorTest {
|
public class AprilTagPoseEstimatorTest {
|
||||||
|
|
||||||
private static final AprilTagMetadata metadata = new AprilTagMetadata(
|
private static final AprilTagMetadata metadata = new AprilTagMetadata(
|
||||||
2,
|
2,
|
||||||
|
@ -91,14 +92,14 @@ class AprilTagPoseEstimatorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertIsClose(Pose2d a, Pose2d b) {
|
private void assertIsClose(Pose2d a, Pose2d b) {
|
||||||
boolean isClose = isClose(a.position.x, b.position.x)
|
boolean isClose = isClose(a.getX(), b.getX())
|
||||||
&& isClose(a.position.y, b.position.y)
|
&& isClose(a.getY(), b.getY())
|
||||||
&& isClose(a.heading.toDouble(), b.heading.toDouble());
|
&& isClose(a.getHeading(), b.getHeading());
|
||||||
|
|
||||||
if (!isClose) {
|
if (!isClose) {
|
||||||
fail(String.format("Expected (%.1f, %.1f, %.1f) to be close to (%.1f, %.1f, %.1f)",
|
fail(String.format("Expected (%.1f, %.1f, %.1f) to be close to (%.1f, %.1f, %.1f)",
|
||||||
a.position.x, a.position.y, a.heading.toDouble(),
|
a.getX(), a.getY(), a.getHeading(),
|
||||||
b.position.x, b.position.y, b.heading.toDouble()));
|
b.getX(), b.getY(), b.getHeading()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue