Class TorqueVision
java.lang.Object
org.texastorque.torquelib.sensors.TorqueVision
Client interface for the TorqueVision.
TorqueLight and TorqueVision are vision cameras developed by
Jack Pittenger at Texas Torque that runs PhotonVision.
TorqueVision was the updated version for the 2023 season that
was designed to specialize in April Tag detection.
The TorqueVision class is updated to specialize in AprilTags
and to use the Optional class to avoid null pointer exceptions.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionTorqueVision
(String name, edu.wpi.first.apriltag.AprilTagFieldLayout layout, edu.wpi.first.math.geometry.Transform3d centerToCamera) Creates a new TorqueLight object with desired table name. -
Method Summary
Modifier and TypeMethodDescriptionint
final double
Deprecated.final int
How many targets do we see?final org.photonvision.PhotonCamera
final Optional<edu.wpi.first.math.geometry.Pose3d>
getPositionOfBestAprilTag
(Map<Integer, edu.wpi.first.math.geometry.Pose3d> knownTags, double poseAmbiguity) Get position of best April Tag.final org.photonvision.targeting.PhotonPipelineResult
Get the current result.final Optional<edu.wpi.first.math.geometry.Pose3d>
getRobotPoseAprilTag3d
(Map<Integer, edu.wpi.first.math.geometry.Pose3d> knownTags, double poseAmbiguity) An estimate of the robot's position as a Pose3d based on a map of known April Tags and the camera stream.final Optional<edu.wpi.first.math.geometry.Pose3d>
getRobotPoseAprilTag3d
(Map<Integer, edu.wpi.first.math.geometry.Pose3d> knownTags, double poseAmbiguity, double minDistance, double maxDistance) An estimate of the robot's position as a Pose3d based on a map of known April Tags and the camera stream.final org.photonvision.targeting.PhotonTrackedTarget
Get the current target.final double
Reads the result timestamp in seconds.final Optional<edu.wpi.first.math.geometry.Transform3d>
getTransformToAprilTag3d
(double poseAmbiguity) The estimated transformation between the camera and the identified AprilTag as a Transform3d.final boolean
Does the camera have any targets?final void
setCenterToCamera
(edu.wpi.first.math.geometry.Transform3d centerToCamera) Sets the transform to the camera from the center.final void
setFieldLayout
(edu.wpi.first.apriltag.AprilTagFieldLayout layout) static final edu.wpi.first.math.geometry.Transform2d
transform3dTo2d
(edu.wpi.first.math.geometry.Transform3d transform) Converts a Transform3d to a Transform2d.final void
update()
Call this periodically to update the vision state.final void
updateVisionMeasurement
(BiConsumer<edu.wpi.first.math.geometry.Pose2d, Double> addVisionMeasurement) Add vision measurements to the pose estimator.
-
Field Details
-
photonPoseEstimator
public final org.photonvision.PhotonPoseEstimator photonPoseEstimator
-
-
Constructor Details
-
TorqueVision
public TorqueVision(String name, edu.wpi.first.apriltag.AprilTagFieldLayout layout, edu.wpi.first.math.geometry.Transform3d centerToCamera) Creates a new TorqueLight object with desired table name.- Parameters:
name
- Table name.centerToCamera
- The transformation from the center to the camera.
-
-
Method Details
-
update
public final void update()Call this periodically to update the vision state. -
setCenterToCamera
public final void setCenterToCamera(edu.wpi.first.math.geometry.Transform3d centerToCamera) Sets the transform to the camera from the center.- Parameters:
centerToCamera
-
-
getResult
public final org.photonvision.targeting.PhotonPipelineResult getResult()Get the current result.- Returns:
- The current result.
-
getTarget
public final org.photonvision.targeting.PhotonTrackedTarget getTarget()Get the current target.- Returns:
- The current target.
-
hasTargets
public final boolean hasTargets()Does the camera have any targets?- Returns:
- If we have targets or not.
-
getNumberOfTargets
public final int getNumberOfTargets()How many targets do we see?- Returns:
- The number of targets that the camera detects.
-
getRobotPoseAprilTag3d
public final Optional<edu.wpi.first.math.geometry.Pose3d> getRobotPoseAprilTag3d(Map<Integer, edu.wpi.first.math.geometry.Pose3d> knownTags, double poseAmbiguity) An estimate of the robot's position as a Pose3d based on a map of known April Tags and the camera stream.- Parameters:
knownTags
- The map of known April Tags.- Returns:
- The position estimate of the robot as a Pose3d.
-
getRobotPoseAprilTag3d
public final Optional<edu.wpi.first.math.geometry.Pose3d> getRobotPoseAprilTag3d(Map<Integer, edu.wpi.first.math.geometry.Pose3d> knownTags, double poseAmbiguity, double minDistance, double maxDistance) An estimate of the robot's position as a Pose3d based on a map of known April Tags and the camera stream.- Parameters:
knownTags
- The map of known April Tags.- Returns:
- The position estimate of the robot as a Pose3d.
-
getTransformToAprilTag3d
public final Optional<edu.wpi.first.math.geometry.Transform3d> getTransformToAprilTag3d(double poseAmbiguity) The estimated transformation between the camera and the identified AprilTag as a Transform3d.- Parameters:
poseAmbiguity
- The maximum pose ambiguity to return a result.- Returns:
- The estimated transformation as a Transform3d.
-
getPositionOfBestAprilTag
public final Optional<edu.wpi.first.math.geometry.Pose3d> getPositionOfBestAprilTag(Map<Integer, edu.wpi.first.math.geometry.Pose3d> knownTags, double poseAmbiguity) Get position of best April Tag.- Parameters:
knownTags
- The map of known April Tags.- Returns:
- The position estimate of the robot as a Pose3d.
-
transform3dTo2d
public static final edu.wpi.first.math.geometry.Transform2d transform3dTo2d(edu.wpi.first.math.geometry.Transform3d transform) Converts a Transform3d to a Transform2d.- Returns:
- The converted Transform2d.
-
getLatency
Deprecated.Reads the camera latency in milliseconds.- Returns:
- The camera latency in milliseconds
-
getTimestamp
public final double getTimestamp()Reads the result timestamp in seconds. More accruate than getLatency.- Returns:
- The result timestamp in seconds.
-
getLastGoodAprilTagID
public int getLastGoodAprilTagID() -
getPhotonCamera
public final org.photonvision.PhotonCamera getPhotonCamera()- Returns:
- The internal PhotonCamera
-
updateVisionMeasurement
public final void updateVisionMeasurement(BiConsumer<edu.wpi.first.math.geometry.Pose2d, Double> addVisionMeasurement) Add vision measurements to the pose estimator.- Parameters:
addVisionMeasurement
- The PoseEstimator::addVisionMeasurement method.
-
setFieldLayout
public final void setFieldLayout(edu.wpi.first.apriltag.AprilTagFieldLayout layout)
-