Skip to content

Commit ef33086

Browse files
a
1 parent a292996 commit ef33086

File tree

11 files changed

+119
-57
lines changed

11 files changed

+119
-57
lines changed

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ task(compileVisionNuitka) {
299299
description = "Compile vision runtime to a standalone binary with Nuitka."
300300
onlyIf { !visionSkipNuitka }
301301
doLast {
302-
def pythonCmd = (project.findProperty("visionPython") ?: System.getenv("VISION_PYTHON") ?: "python").toString()
302+
def pythonCmd = (project.findProperty("visionPython") ?: System.getenv("VISION_PYTHON") ?: "./.venv/Scripts/python.exe").toString()
303303
def nuitkaScript = (project.findProperty("visionNuitkaScript") ?: System.getenv("VISION_NUITKA_SCRIPT") ?: "vision/run.py").toString()
304304
def outputDir = layout.buildDirectory.dir("visionNuitka").get().asFile
305305
delete(outputDir)
@@ -317,6 +317,8 @@ task(compileVisionNuitka) {
317317
"--output-dir=${outputDir.absolutePath.replace("\\", "/")}",
318318
"--output-filename=vision_runtime",
319319
"--include-data-dir=${configDir}=vision/config",
320+
"--nofollow-import-to=torch",
321+
"--nofollow-import-to=torch.*",
320322
nuitkaScript
321323
]
322324
if (!extraArgsRaw.isEmpty()) {

calibration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,4 @@
140140
"C:\\Users\\paulh\\2026-Rebuilt\\calib_images\\calib_0049.png"
141141
],
142142
"rejected_files": []
143-
}
143+
}

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ trimesh[easy]
99
rtree
1010
opencv-python==4.13.0.92
1111
pyright
12-
opencv-contrib-python
12+
opencv-contrib-python
13+
matplotlib
14+
nuitka

src/main/java/org/curtinfrc/frc2026/Robot.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import org.curtinfrc.frc2026.util.Repulsor.Profiler.Profiler;
6565
import org.curtinfrc.frc2026.util.Repulsor.Reasoning.Rebuilt2026Reasoner;
6666
import org.curtinfrc.frc2026.util.Repulsor.Repulsor;
67+
import org.curtinfrc.frc2026.util.Repulsor.StaticInstance;
6768
import org.curtinfrc.frc2026.util.Repulsor.Setpoints.HeightSetpoint;
6869
import org.curtinfrc.frc2026.util.Repulsor.Setpoints.RepulsorSetpoint;
6970
import org.curtinfrc.frc2026.util.Repulsor.Setpoints.Setpoints;
@@ -164,6 +165,8 @@ void wireRepulsor() {
164165
repulsor.setReasoner(reasoner);
165166

166167
repulsor.setup();
168+
169+
StaticInstance.initialize(repulsor);
167170
}
168171

169172
public Robot() {
@@ -296,11 +299,11 @@ public Robot() {
296299
hoodedShooter = new HoodedShooter(new ShooterIO() {}, new HoodIO() {}, drive::getPose);
297300
}
298301

299-
// drive.setPose(
300-
// new Pose2d(
301-
// 15.391 - (Constants.ROBOT_X / 2), 3.84 + (Constants.ROBOT_Y / 2), new Rotation2d()));
302+
drive.setPose(
303+
new Pose2d(
304+
15.391 - (Constants.ROBOT_X / 2), 3.84 + (Constants.ROBOT_Y / 2), new Rotation2d()));
302305

303-
drive.setPose(new Pose2d(0, 0, new Rotation2d()));
306+
// drive.setPose(new Pose2d(0, 0, new Rotation2d()));
304307

305308
DriverStation.silenceJoystickConnectionWarning(true);
306309

src/main/java/org/curtinfrc/frc2026/util/Repulsor/DriveRepulsor.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,17 @@
1919

2020
package org.curtinfrc.frc2026.util.Repulsor;
2121

22+
import org.curtinfrc.frc2026.util.Repulsor.Fields.Rebuilt2026;
23+
import org.curtinfrc.frc2026.util.Repulsor.Fields.FieldMapBuilder.CategorySpec;
24+
import org.curtinfrc.frc2026.util.Repulsor.Setpoints.HeightSetpoint;
25+
import org.curtinfrc.frc2026.util.Repulsor.Setpoints.RepulsorSetpoint;
26+
import org.curtinfrc.frc2026.util.Repulsor.Setpoints.SetpointType;
27+
import org.curtinfrc.frc2026.util.Repulsor.Setpoints.StaticPoseSetpoint;
28+
2229
import edu.wpi.first.math.controller.PIDController;
2330
import edu.wpi.first.math.geometry.Pose2d;
2431
import edu.wpi.first.math.kinematics.ChassisSpeeds;
32+
import edu.wpi.first.wpilibj2.command.Command;
2533
import edu.wpi.first.wpilibj2.command.SubsystemBase;
2634

2735
public abstract class DriveRepulsor extends SubsystemBase {
@@ -30,4 +38,15 @@ public abstract class DriveRepulsor extends SubsystemBase {
3038
public abstract Pose2d getPose();
3139

3240
public abstract PIDController getOmegaPID();
41+
42+
public Command alignTo(Pose2d targetPose) {
43+
Repulsor re = StaticInstance.getInstance();
44+
45+
RepulsorSetpoint setpoint = new RepulsorSetpoint(new StaticPoseSetpoint("ALIGN_TARGET_" + targetPose.hashCode(), SetpointType.kOther, targetPose), HeightSetpoint.L1);
46+
47+
assert re != null : "Repulsor instance is not initialized";
48+
assert re.isSameDrive(this) : "Repulsor instance does not match this DriveRepulsor";
49+
50+
return re.alignTo(setpoint, CategorySpec.kEndgame);
51+
}
3352
}

src/main/java/org/curtinfrc/frc2026/util/Repulsor/Repulsor.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ public enum UsageType {
8383
private DriveRepulsor m_drive;
8484
private UsageType m_usageType = UsageType.kAutoDrive;
8585

86+
public boolean isSameDrive(DriveRepulsor other) {
87+
return this.m_drive == other;
88+
}
89+
8690
private RepulsorSetpoint m_currentGoal =
8791
new RepulsorSetpoint(Setpoints.Rebuilt2026.CENTER_COLLECT, HeightSetpoint.NONE);
8892

@@ -203,11 +207,7 @@ public Repulsor(
203207
SimMatchDriver.simInit(false);
204208
}
205209

206-
public Repulsor(
207-
DriveRepulsor drive,
208-
double robot_x,
209-
double robot_y,
210-
Supplier<Boolean> hasPiece) {
210+
public Repulsor(DriveRepulsor drive, double robot_x, double robot_y, Supplier<Boolean> hasPiece) {
211211
this(drive, UsageType.kFullAuto, robot_x, robot_y, hasPiece);
212212
}
213213

@@ -282,6 +282,10 @@ public void update() {
282282
enabled = ds.getConfigBool("force_controller_override");
283283
}
284284

285+
if (!m_usageType.equals(UsageType.kFullAuto)) {
286+
return;
287+
}
288+
285289
if (enabled) {
286290
m_behaviourManager.stop();
287291
return;

src/main/java/org/curtinfrc/frc2026/util/Repulsor/Setpoints/Specific/_Rebuilt2026.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.curtinfrc.frc2026.util.Repulsor.Shooting.ShotLibrary;
5050
import org.curtinfrc.frc2026.util.Repulsor.Shooting.ShotLibraryBuilder;
5151
import org.curtinfrc.frc2026.util.Repulsor.Shooting.ShotSolution;
52+
import org.curtinfrc.frc2026.util.Repulsor.Setpoints.StaticPoseSetpoint;
5253

5354
public class _Rebuilt2026 {
5455
protected _Rebuilt2026() {}
@@ -447,20 +448,6 @@ private static int obstaclesStableHash(List<? extends Obstacle> obs) {
447448
return (System.identityHashCode(obs) * 31) ^ obs.size();
448449
}
449450

450-
private static final class StaticPoseSetpoint extends GameSetpoint {
451-
private final Pose2d bluePose;
452-
453-
StaticPoseSetpoint(String name, SetpointType type, Pose2d bluePose) {
454-
super(name, type);
455-
this.bluePose = bluePose == null ? Pose2d.kZero : bluePose;
456-
}
457-
458-
@Override
459-
public Pose2d bluePose(SetpointContext ctx) {
460-
return bluePose;
461-
}
462-
}
463-
464451
private static final class ApproachFromTagSetpoint extends GameSetpoint {
465452
private final int tagId;
466453
private final double standoffMeters;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.curtinfrc.frc2026.util.Repulsor.Setpoints;
2+
3+
import edu.wpi.first.math.geometry.Pose2d;
4+
5+
public class StaticPoseSetpoint extends GameSetpoint {
6+
private final Pose2d bluePose;
7+
8+
public StaticPoseSetpoint(String name, SetpointType type, Pose2d bluePose) {
9+
super(name, type);
10+
this.bluePose = bluePose == null ? Pose2d.kZero : bluePose;
11+
}
12+
13+
@Override
14+
public Pose2d bluePose(SetpointContext ctx) {
15+
return bluePose;
16+
}
17+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.curtinfrc.frc2026.util.Repulsor;
2+
3+
public class StaticInstance {
4+
public static Repulsor repulsor;
5+
6+
public static Repulsor getInstance() {
7+
Repulsor local = repulsor;
8+
if (local == null) {
9+
synchronized (Repulsor.class) {
10+
local = repulsor;
11+
if (local == null) {
12+
throw new IllegalStateException("Repulsor instance has not been initialized. Please initialize it before calling getInstance().");
13+
}
14+
}
15+
}
16+
return local;
17+
}
18+
19+
public static void initialize(Repulsor repulsorInstance) {
20+
synchronized (Repulsor.class) {
21+
if (repulsor == null) {
22+
repulsor = repulsorInstance;
23+
} else {
24+
throw new IllegalStateException("Repulsor instance has already been initialized.");
25+
}
26+
}
27+
}
28+
}

vision/config/runtime.json

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,41 +31,40 @@
3131
"roll_deg": 0.0
3232
},
3333
"calibration": {
34-
"K": [
35-
[
36-
854.9288633679033,
37-
0.0,
38-
646.6629754587065
34+
"K": [
35+
[
36+
854.9288633679033,
37+
0.0,
38+
646.6629754587065
39+
],
40+
[
41+
0.0,
42+
853.5201517704674,
43+
353.80122201918516
44+
],
45+
[
46+
0.0,
47+
0.0,
48+
1.0
49+
]
3950
],
40-
[
51+
"dist": [
52+
-2.8742702562830074,
53+
-15.964065766291867,
54+
-0.005370936357486865,
55+
0.0008317338423974286,
56+
66.33662248059912,
57+
-3.101767730188295,
58+
-14.269791592285904,
59+
62.68118871650012,
4160
0.0,
42-
853.5201517704674,
43-
353.80122201918516
44-
],
45-
[
4661
0.0,
4762
0.0,
48-
1.0
63+
0.0,
64+
0.0,
65+
0.0
4966
]
50-
],
51-
"dist": [
52-
-2.8742702562830074,
53-
-15.964065766291867,
54-
-0.005370936357486865,
55-
0.0008317338423974286,
56-
66.33662248059912,
57-
-3.101767730188295,
58-
-14.269791592285904,
59-
62.68118871650012,
60-
0.0,
61-
0.0,
62-
0.0,
63-
0.0,
64-
0.0,
65-
0.0
66-
]
67-
68-
},
67+
},
6968
"axis_cam_from_cv": [
7069
[
7170
0.0,

0 commit comments

Comments
 (0)