This is a guide on how to add visual measurements in to your Phoenix Tunner X generated project.
By @YasushikoX
YouTube Guide:
Getting Started With LimeLight !!MUST READ!!
LimeLight Startihg With April Tags
-
Set up Lime Light for MegaTag 2 in Advanced -> MegaTag Field-Space Localization. Guide (Please also read lime light set up from links)
-
Update all motors etc. in Phoenix X.
-
Make sure drive train is on separte CAN bus.
-
Verify Phoenix Pro license.
-
Generate Phoenix X project.
-
Download LimeLight Library and at it to your robot folder.
-
Add the following to the code:
At the Top:
LimelightHelpers.PoseEstimate limelightMeasurement; private final Pigeon2 pigeon = new Pigeon2(0,"Drive Base");
In constructor:
setVisionMeasurementStdDevs(VecBuilder.fill(.5, .5, 9999999));
In Periodic:
LimelightHelpers.SetRobotOrientation("limelight", pigeon.getYaw().getValueAsDouble(), 0, 0, 0, 0, 0); limelightMeasurement = LimelightHelpers.getBotPoseEstimate_wpiBlue_MegaTag2("limelight"); try { if (limelightMeasurement != null && limelightMeasurement.pose != null) { if (limelightMeasurement.pose.getX() != 0) { addVisionMeasurement(limelightMeasurement.pose, limelightMeasurement.timestampSeconds); SmartDashboard.putBoolean("LimeLight", true); } else{ SmartDashboard.putBoolean("LimeLight", false); } } } catch (Exception e) { System.err.println("An error occurred: " + e.getMessage()); e.printStackTrace(); }
- Use Advantage Scope to see position
- Chief Delphi is your helper
- Check Odometry Rate and make sure its 250hz for less drift