3#include <frc/smartdashboard/Field2d.h>
4#include <pathplanner/lib/commands/FollowPathHolonomic.h>
45 if (rawCorners.size() < 8)
69 units::degree_t cY,
double area,
70 std::vector<std::vector<double>> corners)
76 :
classId{static_cast<uint8_t>(detectionResult.m_classID)},
79 centerX{detectionResult.m_TargetXDegreesCrosshairAdjusted},
80 centerY{detectionResult.m_TargetYDegreesCrosshairAdjusted},
165 std::function<frc::Pose2d()> poseGetter,
166 std::function<frc::Field2d *()> fieldGetter);
221 void SortTargetsByProximity(std::vector<DetectedObject> &objects);
222 void PublishTrackedTarget(
const TrackedTarget &target,
int index);
225 std::function<frc::Pose2d()> m_poseGetter;
226 std::function<frc::Field2d *()> m_fieldGetter;
227 std::vector<TrackedTarget> m_trackedTargets;
std::optional< frc::Pose2d > GetBestTargetPose(std::vector< DetectedObject > &)
From a list of detected objects, get the pose of the best one.
std::optional< DetectedObject > GetBestTarget(std::vector< DetectedObject > &)
Get the best target for tracking/intaking.
bool HasTargetLock(std::vector< DetectedObject > &)
Check if a target has been acquired.
TargetTracker(TargetTrackerConfig config, std::function< frc::Pose2d()> poseGetter, std::function< frc::Field2d *()> fieldGetter)
std::optional< frc::Pose2d > GetTargetPose(const DetectedObject &)
Get the pose of the given object.
void UpdateTrackedTargets(const std::vector< DetectedObject > &objects)
Push targets to SmartDashboard.
std::vector< DetectedObject > GetTargets()
Get a list of all found, valid targets.
units::inch_t GetDistanceToTarget(const DetectedObject &)
Get the estimated distance to the target.
DetectedCorner(const std::vector< double > &coord)
DetectedCorners(const std::vector< double > &rawCorners)
DetectedCorners(const std::vector< std::vector< double > > &corners)
DetectedCorner bottomLeft
DetectedCorner bottomRight
DetectedObject(uint8_t id, double conf, units::degree_t cX, units::degree_t cY, double area, std::vector< std::vector< double > > corners)
void withRawCorners(const std::vector< double > &rawCorners)
DetectedObject(const LimelightHelpers::DetectionResultClass &detectionResult)
DetectedCorners detectedCorners
double trigDistancePercentage
Ranges from 0 to 1; Multiplies trig-based distances and then applies the inverse to width-based estim...
units::degree_t gamepieceRotation
Rotation of the gamepiece relative to the field; helpful for automatic intaking.
double areaPercentageThreshold
Ignore any targets below this percentage to exclude spurious detections.
frc::Pose2d simGamepiecePose
Pose of the mock gamepiece in sim.
units::inch_t cameraLensHeight
Camera height relative to the floor.
std::string limelightName
Name of the limelight in shuffleboard.
double confidenceThreshold
Targets must have a greater value in order to be used.
units::inch_t gamepieceWidth
Width of the gamepiece.
uint8_t maxTrackedItems
Max number of items that will be pushed to SmartDashboard as poses.
units::dimensionless::scalar_t focalLength
Calculated by doing: (known distance / known width in pixels) * gamepiece width.
units::degree_t cameraAngle
Camera angle relative to the floor; positive = up.
frc::Pose2d invalidTrackedPose
Move invalid objects to this pose.