[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:
Brennen Puth
2022-11-04 12:56:22 -04:00
committed by GitHub
parent 7aab8fa93a
commit b2b473b24a
22 changed files with 813 additions and 4 deletions

View File

@@ -11,6 +11,10 @@
#include "Translation3d.h"
#include "Twist3d.h"
namespace wpi {
class json;
} // namespace wpi
namespace frc {
/**
@@ -202,4 +206,10 @@ class WPILIB_DLLEXPORT Pose3d {
Rotation3d m_rotation;
};
WPILIB_DLLEXPORT
void to_json(wpi::json& json, const Pose3d& pose);
WPILIB_DLLEXPORT
void from_json(const wpi::json& json, Pose3d& pose);
} // namespace frc

View File

@@ -8,6 +8,10 @@
#include "frc/EigenCore.h"
namespace wpi {
class json;
} // namespace wpi
namespace frc {
class WPILIB_DLLEXPORT Quaternion {
@@ -92,4 +96,10 @@ class WPILIB_DLLEXPORT Quaternion {
Eigen::Vector3d m_v{0.0, 0.0, 0.0};
};
WPILIB_DLLEXPORT
void to_json(wpi::json& json, const Quaternion& quaternion);
WPILIB_DLLEXPORT
void from_json(const wpi::json& json, Quaternion& quaternion);
} // namespace frc

View File

@@ -11,6 +11,10 @@
#include "frc/EigenCore.h"
#include "units/angle.h"
namespace wpi {
class json;
} // namespace wpi
namespace frc {
/**
@@ -180,4 +184,10 @@ class WPILIB_DLLEXPORT Rotation3d {
Quaternion m_q;
};
WPILIB_DLLEXPORT
void to_json(wpi::json& json, const Rotation3d& rotation);
WPILIB_DLLEXPORT
void from_json(const wpi::json& json, Rotation3d& rotation);
} // namespace frc

View File

@@ -10,6 +10,10 @@
#include "Translation2d.h"
#include "units/length.h"
namespace wpi {
class json;
} // namespace wpi
namespace frc {
/**
@@ -182,6 +186,12 @@ class WPILIB_DLLEXPORT Translation3d {
units::meter_t m_z = 0_m;
};
WPILIB_DLLEXPORT
void to_json(wpi::json& json, const Translation3d& state);
WPILIB_DLLEXPORT
void from_json(const wpi::json& json, Translation3d& state);
} // namespace frc
#include "Translation3d.inc"