mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] Add AprilTag and AprilTagFieldLayout (#4421)
This is an API for looking up a Pose3d from a tag id, and includes functionality to load that map from a JSON file. This also adds JSON support to Pose3d, Rotation3d. Translation3d, and Quaternion. Co-authored-by: Tyler Veness <calcmogul@gmail.com> Co-authored-by: AMereBagatelle <themerebagatelle@gmail.com>
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
|
||||
#include <wpi/json.h>
|
||||
|
||||
#include "Eigen/Core"
|
||||
#include "Eigen/LU"
|
||||
#include "Eigen/QR"
|
||||
@@ -238,3 +240,11 @@ units::radian_t Rotation3d::Angle() const {
|
||||
Rotation2d Rotation3d::ToRotation2d() const {
|
||||
return Rotation2d{Z()};
|
||||
}
|
||||
|
||||
void frc::to_json(wpi::json& json, const Rotation3d& rotation) {
|
||||
json = wpi::json{{"quaternion", rotation.GetQuaternion()}};
|
||||
}
|
||||
|
||||
void frc::from_json(const wpi::json& json, Rotation3d& rotation) {
|
||||
rotation = Rotation3d{json.at("quaternion").get<Quaternion>()};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user