-
Notifications
You must be signed in to change notification settings - Fork 2
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
dd1ca2b
commit 567619b
Showing
3 changed files
with
845 additions
and
5 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/main/java/frc/robot/subsystems/vision/LimelightHelperUser.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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.subsystems.vision; | ||
|
||
import edu.wpi.first.math.geometry.Pose3d; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
import frc.robot.subsystems.vision.LimelightHelpers; | ||
|
||
public class LimelightHelperUser extends SubsystemBase { | ||
String limelightName = "limelight"; | ||
|
||
/** Creates a new ExampleSubsystem. */ | ||
public LimelightHelperUser(String limelightName) { | ||
this.limelightName = limelightName; | ||
} | ||
|
||
/** | ||
* Example command factory method. | ||
* | ||
* @return a command | ||
*/ | ||
public CommandBase exampleMethodCommand() { | ||
// Inline construction of command goes here. | ||
// Subsystem::RunOnce implicitly requires `this` subsystem. | ||
return runOnce( | ||
() -> { | ||
/* one-time action goes here */ | ||
}); | ||
} | ||
|
||
public Pose3d getPose3d() { | ||
return LimelightHelpers.getLatestResults(limelightName).targetingResults.getBotPose3d(); | ||
} | ||
|
||
public double getX() { | ||
return getPose3d().getX(); | ||
} | ||
|
||
public double getY() { | ||
return getPose3d().getY(); | ||
} | ||
|
||
public void reportToSmartDashboard() { | ||
SmartDashboard.putNumber("Vision Robot X", getX()); | ||
SmartDashboard.putNumber("Vision Robot Y", getY()); | ||
} | ||
} |
Oops, something went wrong.