Skip to content

Commit

Permalink
Improve example Limelight integration
Browse files Browse the repository at this point in the history
  • Loading branch information
bhall-ctre authored Jan 10, 2025
1 parent daa6af2 commit 4ef80ce
Show file tree
Hide file tree
Showing 5 changed files with 797 additions and 128 deletions.
9 changes: 7 additions & 2 deletions cpp/SwerveWithPathPlanner/src/main/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ void Robot::RobotPeriodic() {
* of how to use vision should be tuned per-robot and to the team's specification.
*/
if (kUseLimelight) {
auto llMeasurement = LimelightHelpers::getBotPoseEstimate_wpiBlue("limelight");
if (llMeasurement) {
auto const driveState = m_container.drivetrain.GetState();
auto const heading = driveState.Pose.Rotation().Degrees();
auto const omega = driveState.Speeds.omega;

LimelightHelpers::SetRobotOrientation("limelight", heading.value(), 0, 0, 0, 0, 0);
auto llMeasurement = LimelightHelpers::getBotPoseEstimate_wpiBlue_MegaTag2("limelight");
if (llMeasurement && llMeasurement->tagCount > 0 && omega < 2_tps) {
m_container.drivetrain.AddVisionMeasurement(llMeasurement->pose, utils::FPGAToCurrentTime(llMeasurement->timestampSeconds));
}
}
Expand Down
Loading

0 comments on commit 4ef80ce

Please sign in to comment.