Skip to content

Commit

Permalink
Add Limelight portforwarding
Browse files Browse the repository at this point in the history
Signed-off-by: Jade Turner <[email protected]>
  • Loading branch information
spacey-sooty committed Jan 9, 2025
1 parent 7bd906c commit 088b2bc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion AdvantageScope Swerve Calibration.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
}
}
],
"game": "2024 Field",
"game": "2025 Field",
"origin": "blue"
},
"controllerUUID": "psf0y633oclnjyocus23hcnq1d4tpyte",
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
String frcYear = '2024'
String frcYear = '2025'
File frcHome
if (OperatingSystem.current().isWindows()) {
String publicFolder = System.getenv('PUBLIC')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Rotation3d;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.net.PortForwarder;
import edu.wpi.first.networktables.DoubleArrayPublisher;
import edu.wpi.first.networktables.DoubleArraySubscriber;
import edu.wpi.first.networktables.DoubleSubscriber;
Expand All @@ -30,6 +31,8 @@

/** IO implementation for real Limelight hardware. */
public class VisionIOLimelight implements VisionIO {
public static int numberLimelights = 0;

private final Supplier<Rotation2d> rotationSupplier;
private final DoubleArrayPublisher orientationPublisher;

Expand All @@ -55,6 +58,12 @@ public VisionIOLimelight(String name, Supplier<Rotation2d> rotationSupplier) {
megatag1Subscriber = table.getDoubleArrayTopic("botpose_wpiblue").subscribe(new double[] {});
megatag2Subscriber =
table.getDoubleArrayTopic("botpose_orb_wpiblue").subscribe(new double[] {});

int portOffset = 10 * numberLimelights;
for (int port = 5800; port <= 5809; port++) {
PortForwarder.add(port+portOffset, name + ".local", port);
}
numberLimelights += 1;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.curtinfrc.frc2025.subsystems.vision;

import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.net.PortForwarder;
import edu.wpi.first.networktables.DoubleSubscriber;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.RobotController;
Expand All @@ -15,6 +16,12 @@ public VisionIOLimelightGamepiece(String name) {
latencySubscriber = table.getDoubleTopic("tl").subscribe(0.0);
txSubscriber = table.getDoubleTopic("tx").subscribe(0.0);
tySubscriber = table.getDoubleTopic("ty").subscribe(0.0);

int portOffset = 10 * VisionIOLimelight.numberLimelights;
for (int port = 5800; port <= 5809; port++) {
PortForwarder.add(port+portOffset, name + ".local", port);
}
VisionIOLimelight.numberLimelights += 1;
}

@Override
Expand Down

0 comments on commit 088b2bc

Please sign in to comment.