In VSCode, hit CTRL+SHIFT+P and select "WPILib: Manage Vendor Libraries". Select "Install new libraries (offline)" and paste the following URL: https://storage.googleapis.com/grapple-frc-maven/libgrapplefrc2024.json
Use it!
packagefrc.robot;importau.grapplerobotics.LaserCan;importau.grapplerobotics.ConfigurationFailedException;importedu.wpi.first.wpilibj.TimedRobot;publicclassRobotextendsTimedRobot {privateLaserCan lc; @OverridepublicvoidrobotInit() { lc =newLaserCan(0);// Optionally initialise the settings of the LaserCAN, if you haven't already done so in GrappleHooktry {lc.setRangingMode(LaserCan.RangingMode.SHORT);lc.setRegionOfInterest(new LaserCan.RegionOfInterest(8,8,16,16));lc.setTimingBudget(LaserCan.TimingBudget.TIMING_BUDGET_33MS); } catch (ConfigurationFailedException e) {System.out.println("Configuration failed! "+ e); } } @OverridepublicvoidrobotPeriodic() {LaserCan.Measurement measurement =lc.getMeasurement();if (measurement !=null&&measurement.status==LaserCan.LASERCAN_STATUS_VALID_MEASUREMENT) {System.out.println("The target is "+measurement.distance_mm+"mm away!"); } else {System.out.println("Oh no! The target is out of range, or we can't get a reliable measurement!");// You can still use distance_mm in here, if you're ok tolerating a clamped value or an unreliable measurement. } } @OverridepublicvoidautonomousInit() {} @OverridepublicvoidautonomousPeriodic() {} @OverridepublicvoidteleopInit() {} @OverridepublicvoidteleopPeriodic() {} @OverridepublicvoiddisabledInit() {} @OverridepublicvoiddisabledPeriodic() {} @OverridepublicvoidtestInit() {} @OverridepublicvoidtestPeriodic() {}}