8#include <unordered_set>
11#include <frc/apriltag/AprilTagFieldLayout.h>
12#include <frc/estimator/PoseEstimator.h>
13#include <frc/estimator/SwerveDrivePoseEstimator.h>
14#include <frc/geometry/Pose2d.h>
15#include <frc/geometry/Pose3d.h>
16#include <frc/geometry/Rotation3d.h>
17#include <frc/geometry/Twist3d.h>
18#include <networktables/NetworkTableEntry.h>
19#include <networktables/NetworkTableInstance.h>
20#include <units/angle.h>
21#include <units/angular_velocity.h>
22#include <units/dimensionless.h>
23#include <units/length.h>
24#include <units/time.h>
25#include <units/velocity.h>
26#include <valkyrie/cameras/Limelight.h>
27#include <valkyrie/sensors/PoseEstimateSensor.h>
74 const frc::AprilTagFieldLayout& fieldLayout)>;
94 const frc::AprilTagFieldLayout& fieldLayout);
102 Limelight(std::shared_ptr<cameras::Limelight> camera, frc::AprilTagField field);
113 void SetupSim(std::function<frc::Pose2d()> robotPoseGetter, std::unordered_set<int> tagIDs, units::degree_t horizontalFOV,
114 units::degree_t verticalFOV, units::meter_t maxDistance = units::meter_t{std::numeric_limits<double>::infinity()},
115 units::degree_t viewableAngle = 70_deg);
122 inline void SetConfig(
const Config& c) { config = c; }
127 inline void SetVisionFilter(
const VisionFilter _visionFilter) { visionFilter = _visionFilter; }
132 inline void SetDoubtCalculator(
const DoubtCalculator _doubtCalculator) { doubtCalculator = _doubtCalculator; }
134 inline std::shared_ptr<cameras::Limelight> GetCamera()
const {
return cam; }
163 std::optional<PoseEstimate> GetPoseEstimate();
165 void SimulationLoop();
169 std::shared_ptr<cameras::Limelight> cam;
172 frc::AprilTagFieldLayout fieldLayout;
void SetDoubtCalculator(const DoubtCalculator _doubtCalculator)
Set a custom doubt (uncertainty) calculation function.
Definition Limelight.h:132
void SetupSim(std::function< frc::Pose2d()> robotPoseGetter, std::unordered_set< int > tagIDs, units::degree_t horizontalFOV, units::degree_t verticalFOV, units::meter_t maxDistance=units::meter_t{std::numeric_limits< double >::infinity()}, units::degree_t viewableAngle=70_deg)
Configure the simulation state for this sensor.
Solver
Solvers for AprilTag pose estimation.
Definition Limelight.h:46
@ MT2
MegaTag2 solver.
Definition Limelight.h:48
@ MT1
MegaTag1 solver.
Definition Limelight.h:47
void LoggablePeriodic() override
Periodic callback for logging updates.
const Config & GetConfig() const
Get the current sensor configuration.
Definition Limelight.h:120
static bool StandardVisionFilter(const cameras::Limelight::PoseEstimate &context, const Config &_config, const frc::AprilTagFieldLayout &fieldLayout)
Standard filter for determining if a vision measurement is valid.
void SetVisionFilter(const VisionFilter _visionFilter)
Set a custom vision filtering function.
Definition Limelight.h:127
static PoseEstimate::Doubts StandardDoubtCalculator(const cameras::Limelight::PoseEstimate &context, const Config &_config)
Standard logic to calculate measurement uncertainty based on context.
std::unique_ptr< SimState > simState
Pointer to simulation configuration.
Definition Limelight.h:151
Limelight(std::shared_ptr< cameras::Limelight > camera, frc::AprilTagField field)
Construct a new Limelight object.
Pose Estimate of the Limelight.
Definition Limelight.h:222
Holds calculated uncertainty for a vision measurement.
Definition PoseEstimateSensor.h:12
Configuration parameters for the AprilTags sensor.
Definition Limelight.h:54
units::meter_t translationalStdDevCoefficient
Translational standard deviation coefficient for power-law scaling.
Definition Limelight.h:59
units::radian_t rotationalStdDevCoefficient
Rotational standard deviation coefficient for power-law scaling.
Definition Limelight.h:61
double tagWeight
Weight factor applied based on the number of detected tags.
Definition Limelight.h:63
units::second_t maxMeasurementAge
Maximum age of a measurement before it is rejected as stale.
Definition Limelight.h:66
double ambiguityThreshold
Ambiguity threshold for MT1 solver to reject poor results.
Definition Limelight.h:68
units::meter_t fieldBorderMargin
Field border margin for rejecting measurements too close to the edge.
Definition Limelight.h:56
Parameters for simulated vision processing.
Definition Limelight.h:142
units::degree_t viewableAngle
Sim max viewable angle.
Definition Limelight.h:148
std::unordered_set< int > tagIDs
Tags visible in sim.
Definition Limelight.h:144
units::degree_t verticalFOV
Sim vertical FOV.
Definition Limelight.h:146
units::degree_t horizontalFOV
Sim horizontal FOV.
Definition Limelight.h:145
units::meter_t maxDistance
Max simulated range.
Definition Limelight.h:147
std::function< frc::Pose2d()> robotPoseGetter
Robot pose source.
Definition Limelight.h:143