Class AprilTagVisionSubsystem

java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
xbot.common.subsystems.vision.AprilTagVisionSubsystem
All Implemented Interfaces:
Sendable, Subsystem, DataFrameRefreshable

@Singleton public class AprilTagVisionSubsystem extends SubsystemBase implements DataFrameRefreshable
Subsystem for processing AprilTag vision data. Based on the AdvantageKit sample implementation by team 6328.
  • Constructor Details

  • Method Details

    • getCameraCount

      public int getCameraCount()
      Returns the number of cameras.
    • getCameraPosition

      public Transform3d getCameraPosition(int cameraIndex)
      Gets the position of the camera relative to the robot.
      Parameters:
      cameraIndex - The index of the camera to use.
      Returns:
      The 3D position of the camera relative to the robot.
    • getLatestTargetObservation

      public AprilTagVisionIO.TargetObservation getLatestTargetObservation(int cameraIndex)
      Returns the latest target observation.
      Parameters:
      cameraIndex - The index of the camera to use.
      Returns:
      The latest target observation.
    • getTargetX

      public Rotation2d getTargetX(int cameraIndex)
      Returns the X angle to the best target, which can be used for simple servoing with vision.
      Parameters:
      cameraIndex - The index of the camera to use.
    • tagVisibleByCamera

      public boolean tagVisibleByCamera(int cameraIndex, int tagId)
      Returns true if the camera can see the specified tag.
      Parameters:
      cameraIndex - The camera to check.
      tagId - The tag to check.
      Returns:
      true if the camera can see the tag.
    • tagVisibleByAnyCamera

      public boolean tagVisibleByAnyCamera(int tagId)
      Returns true if any camera can see the specified tag.
      Parameters:
      tagId - The tag to check.
      Returns:
      true if any camera can see the tag.
    • camerasWithTagVisible

      public Set<Integer> camerasWithTagVisible(int tagId)
      Returns the set of cameras that can see the specified tag.
      Parameters:
      tagId - The tag to check.
      Returns:
      The set of cameras that can see the tag.
    • getAllPoseObservations

      public List<VisionPoseObservation> getAllPoseObservations()
      Gets all the pose observations in this iteration of the scheduler loop.
      Returns:
      A list of pose observations.
    • refreshDataFrame

      public void refreshDataFrame()
      Description copied from interface: DataFrameRefreshable
      Consumes and processes inputs from the device or subsystem.
      Specified by:
      refreshDataFrame in interface DataFrameRefreshable
    • periodic

      public void periodic()
      Specified by:
      periodic in interface Subsystem