diff --git a/photon-core/src/main/java/org/photonvision/vision/pipeline/AprilTagPipeline.java b/photon-core/src/main/java/org/photonvision/vision/pipeline/AprilTagPipeline.java index f49aaab5d..4a17673c9 100644 --- a/photon-core/src/main/java/org/photonvision/vision/pipeline/AprilTagPipeline.java +++ b/photon-core/src/main/java/org/photonvision/vision/pipeline/AprilTagPipeline.java @@ -181,20 +181,13 @@ public class AprilTagPipeline extends CVPipeline applyTrls(List trls) { @@ -162,7 +107,7 @@ public class RotTrlTransform3d { } public Rotation3d apply(Rotation3d rot) { - return rotate(rot); + return rot.plus(this.rot); } public List applyRots(List rots) { @@ -170,57 +115,10 @@ public class RotTrlTransform3d { } public Pose3d apply(Pose3d pose) { - // return new Pose3d(pose.getTranslation().rotateBy(rot).plus(trl), - // pose.getRotation().plus(rot)); return new Pose3d(apply(pose.getTranslation()), apply(pose.getRotation())); } public List applyPoses(List poses) { return poses.stream().map(this::apply).collect(Collectors.toList()); } - - // TODO: removal awaiting wpilib Rotation3d performance improvements - private Quaternion times(Quaternion other) { - final double o_w = other.getW(); - final double o_x = other.getX(); - final double o_y = other.getY(); - final double o_z = other.getZ(); - return times(m_w, m_x, m_y, m_z, o_w, o_x, o_y, o_z); - } - - private static Quaternion times(Quaternion a, Quaternion b) { - final double m_w = a.getW(); - final double m_x = a.getX(); - final double m_y = a.getY(); - final double m_z = a.getZ(); - final double o_w = b.getW(); - final double o_x = b.getX(); - final double o_y = b.getY(); - final double o_z = b.getZ(); - return times(m_w, m_x, m_y, m_z, o_w, o_x, o_y, o_z); - } - - private static Quaternion times( - double m_w, - double m_x, - double m_y, - double m_z, - double o_w, - double o_x, - double o_y, - double o_z) { - // https://en.wikipedia.org/wiki/Quaternion#Scalar_and_vector_parts - - // v₁ x v₂ - final double cross_x = m_y * o_z - o_y * m_z; - final double cross_y = o_x * m_z - m_x * o_z; - final double cross_z = m_x * o_y - o_x * m_y; - - // v = w₁v₂ + w₂v₁ + v₁ x v₂ - final double new_x = o_x * m_w + (m_x * o_w) + cross_x; - final double new_y = o_y * m_w + (m_y * o_w) + cross_y; - final double new_z = o_z * m_w + (m_z * o_w) + cross_z; - - return new Quaternion(m_w * o_w - (m_x * o_x + m_y * o_y + m_z * o_z), new_x, new_y, new_z); - } }