fdfddfd
This commit is contained in:
parent
12f912bfa0
commit
3b33d797cb
61
build.gradle
61
build.gradle
|
@ -1,28 +1,15 @@
|
|||
buildscript {
|
||||
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'
|
||||
apply plugin: "com.android.library"
|
||||
|
||||
version = "release-SNAPSHOT"
|
||||
android {
|
||||
namespace = 'com.tearabite.ftctearabits'
|
||||
compileSdkVersion 29
|
||||
//
|
||||
namespace = 'com.tearabite.ielib'
|
||||
compileSdkVersion 28
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 24
|
||||
//noinspection ExpiredTargetSdkVersion
|
||||
targetSdkVersion 28
|
||||
multiDexEnabled true
|
||||
targetSdkVersion 26
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
@ -30,36 +17,44 @@ android {
|
|||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release { }
|
||||
debug { }
|
||||
}
|
||||
testOptions {
|
||||
unitTests.all {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url = 'https://maven.brott.dev/'
|
||||
}
|
||||
google()
|
||||
maven { url = 'https://maven.brott.dev/' }
|
||||
}
|
||||
|
||||
ext {
|
||||
dashboard_version = "0.5.6"
|
||||
min_sdk_version = "9.1.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.firstinspires.ftc:RobotCore:9.1.0'
|
||||
implementation 'org.firstinspires.ftc:Vision:9.1.0'
|
||||
|
||||
implementation 'com.acmerobotics.roadrunner:core:1.0.0-beta6'
|
||||
implementation 'com.acmerobotics.roadrunner:actions:1.0.0-beta6'
|
||||
implementation 'com.acmerobotics.dashboard:dashboard:0.4.15'
|
||||
api "org.firstinspires.ftc:RobotCore:$min_sdk_version"
|
||||
api "org.firstinspires.ftc:Hardware:$min_sdk_version"
|
||||
api "org.firstinspires.ftc:RobotServer:$min_sdk_version"
|
||||
api "org.firstinspires.ftc:FtcCommon:$min_sdk_version"
|
||||
api "org.firstinspires.ftc:Vision:$min_sdk_version"
|
||||
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
|
||||
|
||||
//noinspection AnnotationProcessorOnCompilePath
|
||||
compileOnly '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
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
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
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -1,10 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- 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>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.tearabite.ielib" />
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.tearabite.ftctearabits.common;
|
||||
package com.tearabite.ielib.common;
|
||||
|
||||
/**
|
||||
* 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.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.asin;
|
||||
|
@ -7,7 +7,7 @@ import static java.lang.Math.cos;
|
|||
import static java.lang.Math.pow;
|
||||
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.navigation.Quaternion;
|
||||
|
@ -81,9 +81,9 @@ public class AprilTagPoseEstimator {
|
|||
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 offsetX = this.robotOffset.position.x;
|
||||
double offsetY = this.robotOffset.position.y;
|
||||
double Cyaw = this.robotOffset.heading.toDouble();
|
||||
double offsetX = this.robotOffset.getX();
|
||||
double offsetY = this.robotOffset.getY();
|
||||
double Cyaw = this.robotOffset.getHeading();
|
||||
double rh = (PI / 2) + Tyaw + yaw - Cyaw;
|
||||
double rx = cx + offsetX * cos(rh) - offsetY * sin(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.ftctearabits.vision.FTCColors.FTC_BLUE_RANGE;
|
||||
import static com.tearabite.ftctearabits.vision.FTCColors.FTC_RED_RANGE_1;
|
||||
import static com.tearabite.ftctearabits.vision.FTCColors.FTC_RED_RANGE_2;
|
||||
import static com.tearabite.ftctearabits.vision.OpenCVUtil.getLargestContour;
|
||||
import static com.tearabite.ielib.graphics.LinePaint.WHITE;
|
||||
import static com.tearabite.ielib.vision.FTCColors.FTC_BLUE_RANGE;
|
||||
import static com.tearabite.ielib.vision.FTCColors.FTC_RED_RANGE_1;
|
||||
import static com.tearabite.ielib.vision.FTCColors.FTC_RED_RANGE_2;
|
||||
import static com.tearabite.ielib.vision.OpenCVUtil.getLargestContour;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
|
||||
import com.tearabite.ielib.graphics.LinePaint;
|
||||
|
||||
import org.firstinspires.ftc.robotcore.internal.camera.calibration.CameraCalibration;
|
||||
import org.firstinspires.ftc.vision.VisionProcessor;
|
||||
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) {
|
||||
if (detection != null && detection.isValid()) {
|
||||
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.Point;
|
||||
|
@ -77,7 +77,7 @@ public class Detection {
|
|||
return INVALID_POINT;
|
||||
}
|
||||
|
||||
Point centerPx = getCenterOfContour(this.contour);
|
||||
Point centerPx = OpenCVUtil.getCenterOfContour(this.contour);
|
||||
if (scale == PropertyScale.Pixels) {
|
||||
return centerPx;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.tearabite.ftctearabits.vision;
|
||||
package com.tearabite.ielib.vision;
|
||||
|
||||
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.MatOfInt;
|
|
@ -1,4 +1,4 @@
|
|||
package com.tearabite.ftctearabits.vision;
|
||||
package com.tearabite.ielib.vision;
|
||||
|
||||
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.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.navigation.DistanceUnit;
|
||||
|
@ -19,7 +20,7 @@ import org.junit.jupiter.params.provider.MethodSource;
|
|||
import java.security.InvalidParameterException;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class AprilTagPoseEstimatorTest {
|
||||
public class AprilTagPoseEstimatorTest {
|
||||
|
||||
private static final AprilTagMetadata metadata = new AprilTagMetadata(
|
||||
2,
|
||||
|
@ -91,14 +92,14 @@ class AprilTagPoseEstimatorTest {
|
|||
}
|
||||
|
||||
private void assertIsClose(Pose2d a, Pose2d b) {
|
||||
boolean isClose = isClose(a.position.x, b.position.x)
|
||||
&& isClose(a.position.y, b.position.y)
|
||||
&& isClose(a.heading.toDouble(), b.heading.toDouble());
|
||||
boolean isClose = isClose(a.getX(), b.getX())
|
||||
&& isClose(a.getY(), b.getY())
|
||||
&& isClose(a.getHeading(), b.getHeading());
|
||||
|
||||
if (!isClose) {
|
||||
fail(String.format("Expected (%.1f, %.1f, %.1f) to be close to (%.1f, %.1f, %.1f)",
|
||||
a.position.x, a.position.y, a.heading.toDouble(),
|
||||
b.position.x, b.position.y, b.heading.toDouble()));
|
||||
a.getX(), a.getY(), a.getHeading(),
|
||||
b.getX(), b.getY(), b.getHeading()));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue