Yet Another Limelight Library is an improved version of the LimelightHelpers script released by LimelightVision for use in FIRST Robotics Competition (FRC) teams. This library provides enhanced functionality and additional features for easier integration and control of Limelight vision systems on your robot.
- Improved API: Simplified and intuitive API for controlling the Limelight camera and retrieving vision data.
- Easy Configuration: Easy-to-use configuration options to fine-tune the vision system according to your robot’s needs.
https://broncbotz3481.github.io/YALL/vendordep/repo/yall.json
If you prefer to install the library manually, download the latest version from the releases page and add it to your FRC project’s src/main
directory.
Once installed, you can begin using LimelightLib in your code by importing it:
import limelight.Limelight;
Limelight limelight = new Limelight("limelight");
// Set the limelight to use Pipeline LED control, with the Camera offset of 0, and save.
limelight.getSettings()
.withLimelightLEDMode(LEDMode.PipelineControl)
.withCameraOffset(Pose3d.kZero)
.save();
// Get target data
limelight.getLatestResults().ifPresent((LimelightResults result) -> {
for (NeuralClassifier object : result.targets_Classifier)
{
// Classifier says its a algae.
if (object.className.equals("algae"))
{
// Check pixel location of algae.
if (object.ty > 2 && object.ty < 1)
{
// Algae is valid! do stuff!
}
}
}
});
// Required for megatag2 in periodic() function before fetching pose.
limelight.getSettings()
.withRobotOrientation(new Orientation3d(gyro.getRotation3d(),
new AngularVelocity3d(DegreesPerSecond.of(gyro.getPitchVelocity()),
DegreesPerSecond.of(gyro.getRollVelocity()),
DegreesPerSecond.of(gyro.getYawVelocity()))))
.save();
// Get MegaTag2 pose
Optional<PoseEstimate> visionEstimate = limelight.getPoseEstimator(true).getPoseEstimate();
// If the pose is present
visionEstimate.ifPresent((PoseEstimate poseEstimate) -> {
// Add it to the pose estimator.
poseEstimator.addVisionMeasurement(poseEstimate.pose.toPose2d(), poseEstimate.timestampSeconds);
});
// Alternatively you can do
Optional<PoseEstimate> BotPose.BLUE_MEGATAG2.get(limelight);
// If the pose is present
visionEstimate.ifPresent((PoseEstimate poseEstimate) -> {
// Add it to the pose estimator.
poseEstimator.addVisionMeasurement(poseEstimate.pose.toPose2d(), poseEstimate.timestampSeconds);
});
- Settings: To easily configure settings you can chain options:
// Set the limelight to use Pipeline LED control, with the Camera offset of 0, and save.
limelight.getSettings()
.withLimelightLEDMode(LEDMode.PipelineControl)
.withCameraOffset(Pose3d.kZero);
- Pose Estimates: To fetch
PoseEstimate
objects you can use this enum:
Optional<PoseEstimate> BotPose.BLUE_MEGATAG2.get(limelight);
- Java Docs are at https://broncbotz3481.github.io/YALL/docs/
Constructor for initializing the Limelight object.
Limelight limelight = new Limelight("limelight");
// Get the results
limelight.getLatestResults().ifPresent((LimelightResults result) -> {
for (NeuralClassifier object : result.targets_Classifier)
{
// Classifier says its a coral.
if (object.className.equals("coral"))
{
// Check pixel location of coral.
if (object.ty > 2 && object.ty < 1)
{
// Coral is valid! do stuff!
}
}
}
});
Limelight limelight = new Limelight("limelight");
// Required for megatag2 in periodic() function before fetching pose.
limelight.getSettings()
.withRobotOrientation(new Orientation3d(gyro.getRotation3d(),
new AngularVelocity3d(DegreesPerSecond.of(gyro.getPitchVelocity()),
DegreesPerSecond.of(gyro.getRollVelocity()),
DegreesPerSecond.of(gyro.getYawVelocity()))))
.save();
// Get MegaTag2 pose
Optional<PoseEstimate> visionEstimate = poseEstimator.getPoseEstimate();
// If the pose is present
visionEstimate.ifPresent((PoseEstimate poseEstimate) -> {
// Add it to the pose estimator.
poseEstimator.addVisionMeasurement(poseEstimate.pose.toPose2d(), poseEstimate.timestampSeconds);
});
We welcome contributions from the FRC community! To contribute to the Yet Another Limelight Library project, please follow these steps:
- Fork the repository.
- Create a feature branch (
git checkout -b feature-name
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-name
). - Open a pull request to the main repository.
Please make sure your code follows the project's style guidelines and includes tests for new features.
Yet Another Limelight Library is licensed under the MIT License. See the LICENSE file for details.
Enjoy using Yet Another Limelight Library to enhance your FRC robot’s vision capabilities! For further assistance or to report issues, please visit our GitHub Issues page.