Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2025 Prospect Robotics SWENext Club
Copyright 2025-2026 Prospect Robotics SWENext Club

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -69,7 +69,7 @@ public List<Pose3d> getVisibleTagPoses(Set<Integer> ids) {
return List.of();
}
return retriever.getFiducialMap().values().stream()
.filter(fidicual -> ids.contains(fidicual.getId()))
.filter(fiducial -> ids.contains(fiducial.getId()))
.map(Fiducial::getPosition)
.toList();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2025 Prospect Robotics SWENext Club
Copyright 2025-2026 Prospect Robotics SWENext Club

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -25,10 +25,5 @@
* @param timestampSeconds The timestamp, in seconds, using the drivetrain clock
* @param visibleAprilTags All April Tags that are visible from the vision source.
*/
public record BotPoseEstimate(Pose2d pose, double timestampSeconds, Set<Integer> visibleAprilTags) {

@Deprecated
public BotPoseEstimate(Pose2d pose, double timestampSeconds) {
this(pose, timestampSeconds, Set.of());
}
}
public record BotPoseEstimate(
Pose2d pose, double timestampSeconds, Set<Integer> visibleAprilTags) {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2024-2025 Prospect Robotics SWENext Club
Copyright 2024-2026 Prospect Robotics SWENext Club

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -60,9 +60,7 @@ public BodySubscriber<Result> apply(ResponseInfo responseInfo) {

return BodySubscribers.mapping(
BodyHandlers.ofString(Charset.defaultCharset()).apply(responseInfo),
body -> {
return new Result(new JSONObject(body), responseTimestamp);
});
body -> new Result(new JSONObject(body), responseTimestamp));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2024-2025 Prospect Robotics SWENext Club
Copyright 2024-2026 Prospect Robotics SWENext Club

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,14 +15,11 @@
*/
package com.team2813.lib2813.limelight;

import edu.wpi.first.math.geometry.Pose3d;
import edu.wpi.first.wpilibj.Filesystem;
import java.io.*;
import java.util.List;
import java.util.Optional;
import java.util.OptionalDouble;
import java.util.Set;
import org.json.JSONObject;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public interface Limelight {

Expand All @@ -35,20 +32,6 @@ static Limelight getDefaultLimelight() {
return RestLimelight.getDefaultLimelight();
}

/**
* @deprecated use methods in {@link LocationalData} that return a {@link BotPoseEstimate}.
*/
@Deprecated
OptionalDouble getTimestamp();

/**
* Returns {@code true} if the limelight has identified a target.
*
* @deprecated use {@link LocationalData#hasTarget()}
*/
@Deprecated
boolean hasTarget();

/** Gets an object for getting locational data. */
LocationalData getLocationalData();

Expand All @@ -59,7 +42,7 @@ static Limelight getDefaultLimelight() {
* may also upload the field map to the Limelight if desired. This will likely be a slow
* operation, and should not be regularly called.
*
* @param filepath The path to the file from the deploy directory (using UNIX file seperators)
* @param filepath The path to the file from the deploy directory (using UNIX file separators)
* @param updateLimelight If the limelight should be updated with this field map
* @throws IOException If the given filepath does not exist in the deploy directory or could not
* be read
Expand All @@ -70,26 +53,4 @@ default void setFieldMap(String filepath, boolean updateLimelight) throws IOExce
setFieldMap(stream, updateLimelight);
}
}

/**
* Gets the locations of the given AprilTags.
*
* @deprecated use {@link LocationalData#getVisibleAprilTagPoses()}
*/
@Deprecated
List<Pose3d> getLocatedAprilTags(Set<Integer> visibleTags);

/**
* @deprecated use {@link LocationalData#getCaptureLatency()}
*/
@Deprecated
OptionalDouble getCaptureLatency();

/**
* Gets the most recent JSON from the Limelight. Does not work for all implementations.
*
* @deprecated use {@link LocationalData#isValid()}.
*/
@Deprecated
Optional<JSONObject> getJsonDump();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2025 Prospect Robotics SWENext Club
Copyright 2025-2026 Prospect Robotics SWENext Club

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -919,16 +919,10 @@ public static String[] getLimelightNTStringArray(String tableName, String entryN
return getLimelightNTTableEntry(tableName, entryName).getStringArray(new String[0]);
}

public static URL getLimelightURLString(String tableName, String request) {
public static URL getLimelightURLString(String tableName, String request)
throws MalformedURLException {
String urlString = "http://" + sanitizeName(tableName) + ".local:5807/" + request;
URL url;
try {
url = new URL(urlString);
return url;
} catch (MalformedURLException e) {
System.err.println("bad LL URL");
}
return null;
return new URL(urlString);
}

/////
Expand Down Expand Up @@ -1658,8 +1652,8 @@ public static CompletableFuture<Boolean> takeSnapshot(String tableName, String s
}

private static boolean SYNCH_TAKESNAPSHOT(String tableName, String snapshotName) {
URL url = getLimelightURLString(tableName, "capturesnapshot");
try {
URL url = getLimelightURLString(tableName, "capturesnapshot");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
if (snapshotName != null && !snapshotName.isEmpty()) {
Expand All @@ -1672,6 +1666,8 @@ private static boolean SYNCH_TAKESNAPSHOT(String tableName, String snapshotName)
} else {
System.err.println("Bad LL Request");
}
} catch (MalformedURLException e) {
System.err.println("bad Limelight URL: " + e.getMessage());
} catch (IOException e) {
System.err.println(e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2024-2025 Prospect Robotics SWENext Club
Copyright 2024-2026 Prospect Robotics SWENext Club

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,6 @@
import java.util.Map;
import java.util.Optional;
import java.util.OptionalDouble;
import java.util.Set;

/**
* Get positional data from limelight
Expand Down Expand Up @@ -69,47 +68,16 @@ public interface LocationalData {
*
* <p>Per the Limelight docs, this is the time between the end of the exposure of the middle row
* to the beginning of the tracking loop.
*
* @deprecated Use {@link #getBotPoseEstimateBlue()} or {@link #getBotPoseEstimateRed()}
*/
@Deprecated
OptionalDouble getCaptureLatency();

/**
* Targeting latency in milliseconds.
*
* <p>Per the Limelight docs, this is the time consumed by the tracking loop this frame.
*
* @deprecated Use {@link #getBotPoseEstimateBlue()} or {@link #getBotPoseEstimateRed()}
*/
@Deprecated
OptionalDouble getTargetingLatency();

/**
* @deprecated use methods that return a {@link BotPoseEstimate}.
*/
@Deprecated
OptionalDouble getTimestamp();

@Deprecated
default OptionalDouble lastMSDelay() {
OptionalDouble a = getCaptureLatency();
OptionalDouble b = getTargetingLatency();
if (a.isPresent() && b.isPresent()) {
return OptionalDouble.of(a.getAsDouble() + b.getAsDouble());
}
return OptionalDouble.empty();
}

/**
* Gets the set of all visible tags
*
* @return The visible tags
* @deprecated use {@link #getVisibleAprilTagPoses()}
*/
@Deprecated
Set<Integer> getVisibleTags();

/** Gets the visible AprilTags as a map from ID to position. */
Map<Integer, Pose3d> getVisibleAprilTagPoses();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2025 Prospect Robotics SWENext Club
Copyright 2025-2026 Prospect Robotics SWENext Club

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -23,12 +23,12 @@
import edu.wpi.first.math.geometry.Pose3d;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalDouble;
import java.util.stream.Collectors;
import org.json.JSONObject;
import java.util.Set;

class NetworkTablesLimelight implements Limelight {
private static final double[] ZEROS = new double[6];
Expand All @@ -40,38 +40,13 @@ class NetworkTablesLimelight implements Limelight {
aprilTagMapPoseHelper = new AprilTagMapPoseHelper(new LimelightClient(limelightName));
}

@Override
public OptionalDouble getTimestamp() {
return getLocationalData().getTimestamp();
}

@Override
public boolean hasTarget() {
return getLocationalData().hasTarget();
}

@Override
public void setFieldMap(InputStream stream, boolean updateLimelight) throws IOException {
// The updateLimelight assumes we have the hostname of the limelight, which we don't. For now,
// this won't update the limelight.
aprilTagMapPoseHelper.setFieldMap(stream, false);
}

@Override
public List<Pose3d> getLocatedAprilTags(Set<Integer> visibleTags) {
return aprilTagMapPoseHelper.getVisibleTagPoses(visibleTags);
}

@Override
public Optional<JSONObject> getJsonDump() {
return Optional.empty();
}

@Override
public OptionalDouble getCaptureLatency() {
return getLocationalData().getCaptureLatency();
}

@Override
public LocationalData getLocationalData() {
LimelightHelpers.LimelightResults results = LimelightHelpers.getLatestResults(limelightName);
Expand Down Expand Up @@ -109,7 +84,7 @@ private Map<Integer, Pose3d> getVisibleAprilTagPoses(LimelightResults results) {
return unmodifiableMap(map);
}

private class NTLocationalData implements LocationalData {
private static class NTLocationalData implements LocationalData {
private final LimelightResults results;
private final Optional<BotPoseEstimate> poseEstimate;
private final Optional<BotPoseEstimate> redPoseEstimate;
Expand Down Expand Up @@ -179,18 +154,6 @@ public OptionalDouble getTargetingLatency() {
return OptionalDouble.of(results.latency_pipeline);
}

@Override
public OptionalDouble getTimestamp() {
return OptionalDouble.of(results.timestamp_LIMELIGHT_publish);
}

@Override
public Set<Integer> getVisibleTags() {
return Arrays.stream(results.targets_Fiducials)
.map(fiducial -> (int) fiducial.fiducialID)
.collect(Collectors.toUnmodifiableSet());
}

@Override
public Map<Integer, Pose3d> getVisibleAprilTagPoses() {
return aprilTags;
Expand Down
Loading
Loading