27 #ifndef FABLE_JSON_WITH_EIGEN_HPP_ 28 #define FABLE_JSON_WITH_EIGEN_HPP_ 30 #include <nlohmann/json.hpp> 32 #include <Eigen/Geometry> 37 struct adl_serializer<Eigen::Vector3d> {
38 static void to_json(json& j,
const Eigen::Vector3d& v) {
46 static void from_json(
const json& j, Eigen::Vector3d& v) {
47 v.x() = j[
"x"].get<
double>();
48 v.y() = j[
"y"].get<
double>();
49 v.z() = j[
"z"].get<
double>();
54 struct adl_serializer<Eigen::Quaterniond> {
55 static void to_json(json& j,
const Eigen::Quaterniond& q) {
64 static void from_json(
const json& j, Eigen::Quaterniond& q) {
65 q.w() = j[
"w"].get<
double>();
66 q.x() = j[
"x"].get<
double>();
67 q.y() = j[
"y"].get<
double>();
68 q.z() = j[
"z"].get<
double>();
73 struct adl_serializer<Eigen::Isometry3d> {
74 static void to_json(json& j,
const Eigen::Isometry3d& o) {
75 Eigen::Vector3d trans = o.translation();
77 {
"translation", trans},
78 {
"rotation", Eigen::Quaterniond(o.rotation())},
82 static void from_json(
const json& j, Eigen::Isometry3d& o) {
84 o.linear() = j[
"rotation"].get<Eigen::Quaterniond>().matrix();
85 o.translation() = j[
"translation"].get<Eigen::Vector3d>();
91 #endif // FABLE_JSON_WITH_EIGEN_HPP_ Definition: confable.hpp:132