22#include <frc/geometry/Pose3d.h>
23#include <frc/geometry/Translation3d.h>
31 : vertices({frc::Translation3d{0_m, -width / 2.0, -height / 2.0},
32 frc::Translation3d{0_m, width / 2.0, -height / 2.0},
33 frc::Translation3d{0_m, width / 2.0, height / 2.0},
34 frc::Translation3d{0_m, -width / 2.0, height / 2.0}}),
39 units::meter_t height)
41 frc::Translation3d{length / 2.0, -width / 2.0, -height / 2.0},
42 frc::Translation3d{length / 2.0, width / 2.0, -height / 2.0},
43 frc::Translation3d{length / 2.0, width / 2.0, height / 2.0},
44 frc::Translation3d{length / 2.0, -width / 2.0, height / 2.0},
45 frc::Translation3d{-length / 2.0, -width / 2.0, height / 2.0},
46 frc::Translation3d{-length / 2.0, width / 2.0, height / 2.0},
47 frc::Translation3d{-length / 2.0, width / 2.0, -height / 2.0},
48 frc::Translation3d{-length / 2.0, -width / 2.0, -height / 2.0},
53 frc::Translation3d{0_m, -diameter / 2.0, 0_m},
54 frc::Translation3d{0_m, 0_m, -diameter / 2.0},
55 frc::Translation3d{0_m, diameter / 2.0, 0_m},
56 frc::Translation3d{0_m, 0_m, diameter / 2.0},
61 explicit TargetModel(
const std::vector<frc::Translation3d>& verts)
62 : isSpherical(false) {
63 if (verts.size() <= 2) {
64 vertices = std::vector<frc::Translation3d>();
67 bool cornersPlanar = true;
68 for (const auto& corner : verts) {
69 if (corner.X() != 0_m) {
70 cornersPlanar = false;
73 isPlanar = cornersPlanar;
79 const frc::Pose3d& targetPose)
const {
81 targetPose.Translation()};
82 std::vector<frc::Translation3d> retVal;
83 retVal.reserve(vertices.size());
84 for (
const auto& vert : vertices) {
85 retVal.emplace_back(basisChange.Apply(vert));
91 const frc::Translation3d& cameraTrl) {
92 frc::Translation3d relCam = cameraTrl - tgtTrl;
93 frc::Rotation3d orientToCam = frc::Rotation3d{
95 frc::Rotation2d{units::math::hypot(relCam.X(), relCam.Y()).to<
double>(),
96 -relCam.Z().to<
double>()}
98 frc::Rotation2d{relCam.X().to<
double>(), relCam.Y().to<
double>()}
100 return frc::Pose3d{tgtTrl, orientToCam};
103 std::vector<frc::Translation3d>
GetVertices()
const {
return vertices; }
108 std::vector<frc::Translation3d> vertices;
Definition TargetModel.h:28
TargetModel(units::meter_t length, units::meter_t width, units::meter_t height)
Definition TargetModel.h:38
TargetModel(units::meter_t width, units::meter_t height)
Definition TargetModel.h:30
static frc::Pose3d GetOrientedPose(const frc::Translation3d &tgtTrl, const frc::Translation3d &cameraTrl)
Definition TargetModel.h:90
bool GetIsSpherical() const
Definition TargetModel.h:105
std::vector< frc::Translation3d > GetVertices() const
Definition TargetModel.h:103
std::vector< frc::Translation3d > GetFieldVertices(const frc::Pose3d &targetPose) const
Definition TargetModel.h:78
TargetModel(const std::vector< frc::Translation3d > &verts)
Definition TargetModel.h:61
TargetModel(units::meter_t diameter)
Definition TargetModel.h:51
bool GetIsPlanar() const
Definition TargetModel.h:104
Definition VisionEstimation.h:32
static const TargetModel kAprilTag36h11
Definition TargetModel.h:114
static const TargetModel kAprilTag16h5
Definition TargetModel.h:113