2024-01-08 11:38:08 -07:00
|
|
|
// 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 frc4388.robot.subsystems;
|
|
|
|
|
import edu.wpi.first.math.geometry.Pose2d;
|
2024-02-16 21:49:50 -07:00
|
|
|
import edu.wpi.first.math.geometry.Rotation2d;
|
|
|
|
|
import edu.wpi.first.networktables.NetworkTableInstance;
|
2024-01-08 11:38:08 -07:00
|
|
|
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
|
|
|
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
2024-02-15 15:35:53 -07:00
|
|
|
|
2024-02-16 21:49:50 -07:00
|
|
|
// Look at vvv for networktables stuff
|
|
|
|
|
// https://docs.limelightvision.io/docs/docs-limelight/apis/complete-networktables-api#apriltag-and-3d-data
|
2024-02-15 15:35:53 -07:00
|
|
|
|
2024-02-16 21:49:50 -07:00
|
|
|
public class Limelight extends SubsystemBase {
|
|
|
|
|
private double[] cameraPose;
|
|
|
|
|
private Boolean isTag;
|
2024-02-15 15:35:53 -07:00
|
|
|
|
2024-02-16 21:49:50 -07:00
|
|
|
public boolean getIsTag() {
|
|
|
|
|
return isTag;
|
2024-02-15 15:35:53 -07:00
|
|
|
}
|
|
|
|
|
|
2024-02-16 21:49:50 -07:00
|
|
|
public Pose2d getPose() {
|
|
|
|
|
//TODO - Get actual values!
|
2024-02-15 15:35:53 -07:00
|
|
|
|
2024-02-16 21:49:50 -07:00
|
|
|
double x = 0;
|
|
|
|
|
double y = 0;
|
|
|
|
|
double yaw = 0;
|
2024-02-15 15:35:53 -07:00
|
|
|
|
2024-02-16 21:49:50 -07:00
|
|
|
Rotation2d rot = Rotation2d.fromDegrees(yaw);
|
2024-02-15 15:35:53 -07:00
|
|
|
|
2024-02-16 21:49:50 -07:00
|
|
|
return new Pose2d(x, y, rot);
|
2024-02-15 10:27:44 -07:00
|
|
|
}
|
2024-02-15 15:35:53 -07:00
|
|
|
|
2024-02-16 21:49:50 -07:00
|
|
|
@Override
|
|
|
|
|
public void periodic() {
|
|
|
|
|
// This method will be called once per scheduler run
|
2024-02-15 15:35:53 -07:00
|
|
|
|
2024-02-16 21:49:50 -07:00
|
|
|
isTag = NetworkTableInstance.getDefault().getTable("limelight").getEntry("tv").getBoolean(false);
|
|
|
|
|
cameraPose = NetworkTableInstance.getDefault().getTable("limelight").getEntry("camerapose_targetspace").getDoubleArray(new double[6]);
|
2024-02-15 15:35:53 -07:00
|
|
|
}
|
2024-02-16 21:49:50 -07:00
|
|
|
}
|