-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7abb7a4
commit d0df476
Showing
24 changed files
with
151 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...melight/structures/AngularVelocity3d.java → ...ight/networktables/AngularVelocity3d.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ght/structures/LimelightPipelineData.java → .../networktables/LimelightPipelineData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package limelight.structures; | ||
package limelight.networktables; | ||
|
||
|
||
import edu.wpi.first.networktables.NetworkTable; | ||
|
4 changes: 2 additions & 2 deletions
4
...ght/estimator/LimelightPoseEstimator.java → ...networktables/LimelightPoseEstimator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...melight/structures/LimelightSettings.java → ...ight/networktables/LimelightSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package limelight.networktables; | ||
|
||
import static edu.wpi.first.units.Units.Meters; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import edu.wpi.first.apriltag.AprilTag; | ||
import edu.wpi.first.apriltag.AprilTagFieldLayout; | ||
import edu.wpi.first.math.geometry.Pose2d; | ||
import edu.wpi.first.math.geometry.Rectangle2d; | ||
import edu.wpi.first.networktables.NetworkTable; | ||
import edu.wpi.first.networktables.NetworkTableInstance; | ||
import edu.wpi.first.units.measure.Distance; | ||
import java.util.List; | ||
import java.util.function.Supplier; | ||
import limelight.Limelight; | ||
import limelight.networktables.target.AprilTagFiducial; | ||
|
||
public class LimelightSim | ||
{ | ||
|
||
private Limelight m_limelight; | ||
private Supplier<Pose2d> m_pose; | ||
private AprilTagFieldLayout m_fieldLayout; | ||
private NetworkTable m_limelightTable; | ||
private Distance m_limelightViewDistance = Meters.of(1); | ||
|
||
/** | ||
* Limelight simulation class | ||
* | ||
* @param limelight {@link Limelight} to use. | ||
* @param odomPose Supplier of the odom pose. | ||
* @param fieldLayout {@link AprilTagFieldLayout} to use. | ||
*/ | ||
public LimelightSim(Limelight limelight, Supplier<Pose2d> odomPose, AprilTagFieldLayout fieldLayout) | ||
{ | ||
m_limelight = limelight; | ||
m_pose = odomPose; | ||
m_fieldLayout = fieldLayout; | ||
m_limelightTable = NetworkTableInstance.getDefault().getTable(limelight.limelightName); | ||
|
||
} | ||
|
||
/** | ||
* Gets the {@link AprilTag} in view of the Limelight, does this by using a Rectangle bounding box from your current | ||
* pose. | ||
* | ||
* @return List of {@link AprilTag}s in range | ||
*/ | ||
public List<AprilTag> getAprilTagsInView() | ||
{ | ||
Rectangle2d viewbox = new Rectangle2d(m_pose.get(), m_limelightViewDistance, m_limelightViewDistance); | ||
// TODO: Improve this to use a triangular cone FOV. | ||
return m_fieldLayout.getTags().stream() | ||
.filter(aprilTag -> viewbox.contains(aprilTag.pose.toPose2d().getTranslation())) | ||
.toList(); | ||
} | ||
|
||
|
||
public void updateTagKeys() | ||
{ | ||
LimelightData data = m_limelight.getData(); | ||
List<AprilTag> tags = getAprilTagsInView(); | ||
LimelightResults llJson = new LimelightResults(); | ||
llJson.botpose = LimelightUtils.pose2dToArray(m_pose.get()); | ||
llJson.valid = true; | ||
llJson.targets_Fiducials = (AprilTagFiducial[]) (tags.stream().map(aprilTag -> { | ||
AprilTagFiducial fid = new AprilTagFiducial(); | ||
fid.fiducialID = aprilTag.ID; | ||
fid.fiducialFamily = "36h11"; | ||
return fid; | ||
}).toArray()); | ||
try | ||
{ | ||
data.results.setString(data.resultsObjectMapper.writer().withDefaultPrettyPrinter().writeValueAsString(llJson)); | ||
} catch (JsonProcessingException e) | ||
{ | ||
throw new RuntimeException(e); | ||
} | ||
// TODO: Expand this to implement more of the ll json. | ||
|
||
} | ||
|
||
|
||
} |
4 changes: 2 additions & 2 deletions
4
...light/structures/LimelightTargetData.java → ...ht/networktables/LimelightTargetData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../limelight/structures/LimelightUtils.java → ...melight/networktables/LimelightUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package limelight.structures; | ||
package limelight.networktables; | ||
|
||
|
||
import static edu.wpi.first.units.Units.Degrees; | ||
|
2 changes: 1 addition & 1 deletion
2
...a/limelight/structures/Orientation3d.java → ...imelight/networktables/Orientation3d.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ava/limelight/estimator/PoseEstimate.java → ...limelight/networktables/PoseEstimate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...va/limelight/structures/package-info.java → ...limelight/networktables/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/** | ||
* All Structures and utilities relating to Limelight NetworkTable data. | ||
*/ | ||
package limelight.structures; | ||
package limelight.networktables; |
6 changes: 3 additions & 3 deletions
6
...t/structures/target/AprilTagFiducial.java → ...etworktables/target/AprilTagFiducial.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../limelight/structures/target/Barcode.java → ...melight/networktables/target/Barcode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...tructures/target/RetroreflectiveTape.java → ...orktables/target/RetroreflectiveTape.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...light/structures/target/package-info.java → ...ht/networktables/target/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/** | ||
* Target data structures mapped to NetworkTables data. | ||
*/ | ||
package limelight.structures.target; | ||
package limelight.networktables.target; |
2 changes: 1 addition & 1 deletion
2
...res/target/pipeline/NeuralClassifier.java → ...les/target/pipeline/NeuralClassifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tures/target/pipeline/NeuralDetector.java → ...ables/target/pipeline/NeuralDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.