001/* 002 * MIT License 003 * 004 * Copyright (c) PhotonVision 005 * 006 * Permission is hereby granted, free of charge, to any person obtaining a copy 007 * of this software and associated documentation files (the "Software"), to deal 008 * in the Software without restriction, including without limitation the rights 009 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 010 * copies of the Software, and to permit persons to whom the Software is 011 * furnished to do so, subject to the following conditions: 012 * 013 * The above copyright notice and this permission notice shall be included in all 014 * copies or substantial portions of the Software. 015 * 016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 018 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 019 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 022 * SOFTWARE. 023 */ 024 025package org.photonvision.simulation; 026 027import edu.wpi.first.math.geometry.Pose3d; 028import edu.wpi.first.math.geometry.Translation3d; 029import java.util.List; 030import org.photonvision.estimation.TargetModel; 031 032/** Describes a vision target located somewhere on the field that your vision system can detect. */ 033public class VisionTargetSim { 034 private Pose3d pose; 035 private TargetModel model; 036 037 public final int fiducialID; 038 039 /** 040 * Describes a vision target located somewhere on the field that your vision system can detect. 041 * 042 * @param pose Pose3d of the tag in field-relative coordinates 043 * @param model TargetModel which describes the shape of the target 044 */ 045 public VisionTargetSim(Pose3d pose, TargetModel model) { 046 this.pose = pose; 047 this.model = model; 048 this.fiducialID = -1; 049 } 050 051 /** 052 * Describes a fiducial tag located somewhere on the field that your vision system can detect. 053 * 054 * @param pose Pose3d of the tag in field-relative coordinates 055 * @param model TargetModel which describes the shape of the target(tag) 056 * @param id The ID of this fiducial tag 057 */ 058 public VisionTargetSim(Pose3d pose, TargetModel model, int id) { 059 this.pose = pose; 060 this.model = model; 061 this.fiducialID = id; 062 } 063 064 public void setPose(Pose3d pose) { 065 this.pose = pose; 066 } 067 068 public void setModel(TargetModel model) { 069 this.model = model; 070 } 071 072 public Pose3d getPose() { 073 return pose; 074 } 075 076 public TargetModel getModel() { 077 return model; 078 } 079 080 /** This target's vertices offset from its field pose. */ 081 public List<Translation3d> getFieldVertices() { 082 return model.getFieldVertices(pose); 083 } 084 085 @Override 086 public boolean equals(Object obj) { 087 return this == obj 088 && obj instanceof VisionTargetSim o 089 && pose.equals(o.pose) 090 && model.equals(o.model); 091 } 092}