Class TorqueLight
java.lang.Object
org.texastorque.torquelib.sensors.TorqueLight
Java client interface for the TorqueLight.
TorqueLight is a vision camera developed by Texas Torque
that runs PhotonVision.
-
Constructor Summary
ConstructorDescriptionTorqueLight
(String name) Creates a new TorqueLight object with desired physical parameters. -
Method Summary
Modifier and TypeMethodDescriptionfinal double
Returns the avg pitch angle of the targets as degrees.final double
Returns the avg yaw angle of the targets as degrees.static final double
getDistanceToElevatedTarget
(TorqueLight camera, double cameraHeight, double targetHeight, edu.wpi.first.math.geometry.Rotation2d angle) Calculates the distance to the target in meters.final double
Reads the camera latency in milliseconds.final double
static final edu.wpi.first.math.geometry.Pose2d
getRobotPose
(edu.wpi.first.math.geometry.Rotation2d theta_r, edu.wpi.first.math.geometry.Rotation2d theta_dp, edu.wpi.first.math.geometry.Rotation2d theta_dy, double H_h, double H_c, edu.wpi.first.math.geometry.Rotation2d theta_cp, double r_tc, double theta_t, double r_H, double x_h, double y_h) Gets the estimated robot position using vision calculations.final edu.wpi.first.math.geometry.Pose2d
getRobotPoseAprilTag2d
(Map<Integer, edu.wpi.first.math.geometry.Pose3d> knownTags) final edu.wpi.first.math.geometry.Pose3d
getRobotPoseAprilTag3d
(Map<Integer, edu.wpi.first.math.geometry.Pose3d> knownTags) final double
Returns the area of the target.final double
Returns the pitch angle of the target as degrees.final double
Returns the yaw angle of the target as degrees.final edu.wpi.first.math.geometry.Transform3d
final boolean
Does the camera have any targets.final void
update()
Call this periodically to update the vision state.
-
Constructor Details
-
TorqueLight
Creates a new TorqueLight object with desired physical parameters. -
TorqueLight
public TorqueLight()
-
-
Method Details
-
update
public final void update()Call this periodically to update the vision state. -
hasTargets
public final boolean hasTargets()Does the camera have any targets.- Returns:
- Do we have targets or not.
-
getTargetArea
public final double getTargetArea()Returns the area of the target.- Returns:
- the area of the target.
-
getTargetYaw
public final double getTargetYaw()Returns the yaw angle of the target as degrees.- Returns:
- The yaw angle of the target as degrees.
-
getAverageYaw
public final double getAverageYaw()Returns the avg yaw angle of the targets as degrees.- Returns:
- The avg yaw angle of the targets as degrees.
-
getTargetPitch
public final double getTargetPitch()Returns the pitch angle of the target as degrees.- Returns:
- The pitch angle of the target as degrees.
-
getAveragePitch
public final double getAveragePitch()Returns the avg pitch angle of the targets as degrees.- Returns:
- The avg pitch angle of the targets as degrees.
-
getNumberOfTargets
public final double getNumberOfTargets()- Returns:
- The number of targets that the camera detects.
-
getDistanceToElevatedTarget
public static final double getDistanceToElevatedTarget(TorqueLight camera, double cameraHeight, double targetHeight, edu.wpi.first.math.geometry.Rotation2d angle) Calculates the distance to the target in meters.- Returns:
- The distance to the target in meters.
-
getRobotPose
public static final edu.wpi.first.math.geometry.Pose2d getRobotPose(edu.wpi.first.math.geometry.Rotation2d theta_r, edu.wpi.first.math.geometry.Rotation2d theta_dp, edu.wpi.first.math.geometry.Rotation2d theta_dy, double H_h, double H_c, edu.wpi.first.math.geometry.Rotation2d theta_cp, double r_tc, double theta_t, double r_H, double x_h, double y_h) Gets the estimated robot position using vision calculations.- Parameters:
camera
- The camera object we are using.theta_r
- Robot's CCW rotation w/ respect to the field.theta_dp
- Camera detection pitch.theta_dy
- Camera detection yaw.H_h
- Height (m) of the targets.H_c
- Height (m) of the camera.theta_cp
- Camera mount's pitch.r_tc
- Radius of the turret + camera.theta_t
- Polar degree rotation of the turret relative the camera.r_H
- Radius of the hub.x_H
- X position of the hub.y_H
- Y position of the hub.
-
getRobotPoseAprilTag3d
-
getRobotPoseAprilTag2d
-
getTransformToAprilTag3d
public final edu.wpi.first.math.geometry.Transform3d getTransformToAprilTag3d() -
getLatency
public final double getLatency()Reads the camera latency in milliseconds.- Returns:
- The camera latency in milliseconds
-