PhotonVision C++ dev-v2025.0.0-beta-8-2-gbd1c5c03
Loading...
Searching...
No Matches
VisionTargetSim.h
Go to the documentation of this file.
1/*
2 * MIT License
3 *
4 * Copyright (c) PhotonVision
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25#pragma once
26
27#include <vector>
28
29#include <frc/geometry/Pose3d.h>
30
32
33namespace photon {
35 public:
36 VisionTargetSim(const frc::Pose3d& pose, const TargetModel& model)
37 : fiducialId(-1), pose(pose), model(model) {}
38 VisionTargetSim(const frc::Pose3d& pose, const TargetModel& model, int id)
39 : fiducialId(id), pose(pose), model(model) {}
40 void SetPose(const frc::Pose3d& newPose) { pose = newPose; }
41 void SetModel(const TargetModel& newModel) { model = newModel; }
42 frc::Pose3d GetPose() const { return pose; }
43 TargetModel GetModel() const { return model; }
44 std::vector<frc::Translation3d> GetFieldVertices() const {
45 return model.GetFieldVertices(pose);
46 }
48
49 int objDetClassId = -1;
50 float objDetConf = -1;
51
52 bool operator<(const VisionTargetSim& right) const {
53 return pose.Translation().Norm() < right.pose.Translation().Norm();
54 }
55
56 bool operator==(const VisionTargetSim& other) const {
57 return units::math::abs(pose.Translation().X() -
58 other.GetPose().Translation().X()) < 1_in &&
59 units::math::abs(pose.Translation().Y() -
60 other.GetPose().Translation().Y()) < 1_in &&
61 units::math::abs(pose.Translation().Z() -
62 other.GetPose().Translation().Z()) < 1_in &&
63 units::math::abs(pose.Rotation().X() -
64 other.GetPose().Rotation().X()) < 1_deg &&
65 units::math::abs(pose.Rotation().Y() -
66 other.GetPose().Rotation().Y()) < 1_deg &&
67 units::math::abs(pose.Rotation().Z() -
68 other.GetPose().Rotation().Z()) < 1_deg &&
69 model.GetIsPlanar() == other.GetModel().GetIsPlanar();
70 }
71
72 private:
73 frc::Pose3d pose;
74 TargetModel model;
75};
76} // namespace photon
Definition TargetModel.h:28
std::vector< frc::Translation3d > GetFieldVertices(const frc::Pose3d &targetPose) const
Definition TargetModel.h:78
bool GetIsPlanar() const
Definition TargetModel.h:104
Definition VisionTargetSim.h:34
TargetModel GetModel() const
Definition VisionTargetSim.h:43
void SetPose(const frc::Pose3d &newPose)
Definition VisionTargetSim.h:40
float objDetConf
Definition VisionTargetSim.h:50
int fiducialId
Definition VisionTargetSim.h:47
std::vector< frc::Translation3d > GetFieldVertices() const
Definition VisionTargetSim.h:44
frc::Pose3d GetPose() const
Definition VisionTargetSim.h:42
int objDetClassId
Definition VisionTargetSim.h:49
VisionTargetSim(const frc::Pose3d &pose, const TargetModel &model, int id)
Definition VisionTargetSim.h:38
bool operator==(const VisionTargetSim &other) const
Definition VisionTargetSim.h:56
void SetModel(const TargetModel &newModel)
Definition VisionTargetSim.h:41
bool operator<(const VisionTargetSim &right) const
Definition VisionTargetSim.h:52
VisionTargetSim(const frc::Pose3d &pose, const TargetModel &model)
Definition VisionTargetSim.h:36
Definition VisionEstimation.h:32