mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Update for jart/json.cpp change
This commit is contained in:
@@ -7,8 +7,9 @@
|
||||
#include "wpi/util/json.hpp"
|
||||
|
||||
void wpi::math::to_json(wpi::util::json& json, const Pose2d& pose) {
|
||||
json = wpi::util::json{{"translation", pose.Translation()},
|
||||
{"rotation", pose.Rotation()}};
|
||||
json.set_object();
|
||||
json["translation"] = pose.Translation();
|
||||
json["rotation"] = pose.Rotation();
|
||||
}
|
||||
|
||||
void wpi::math::from_json(const wpi::util::json& json, Pose2d& pose) {
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
#include "wpi/util/json.hpp"
|
||||
|
||||
void wpi::math::to_json(wpi::util::json& json, const Pose3d& pose) {
|
||||
json = wpi::util::json{{"translation", pose.Translation()},
|
||||
{"rotation", pose.Rotation()}};
|
||||
json.set_object();
|
||||
json["translation"] = pose.Translation();
|
||||
json["rotation"] = pose.Rotation();
|
||||
}
|
||||
|
||||
void wpi::math::from_json(const wpi::util::json& json, Pose3d& pose) {
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
#include "wpi/util/json.hpp"
|
||||
|
||||
void wpi::math::to_json(wpi::util::json& json, const Quaternion& quaternion) {
|
||||
json = wpi::util::json{{"W", quaternion.W()},
|
||||
{"X", quaternion.X()},
|
||||
{"Y", quaternion.Y()},
|
||||
{"Z", quaternion.Z()}};
|
||||
json.set_object();
|
||||
json["W"] = quaternion.W();
|
||||
json["X"] = quaternion.X();
|
||||
json["Y"] = quaternion.Y();
|
||||
json["Z"] = quaternion.Z();
|
||||
}
|
||||
|
||||
void wpi::math::from_json(const wpi::util::json& json, Quaternion& quaternion) {
|
||||
quaternion =
|
||||
Quaternion{json.at("W").get<double>(), json.at("X").get<double>(),
|
||||
json.at("Y").get<double>(), json.at("Z").get<double>()};
|
||||
quaternion = Quaternion{json.at("W").get_number(), json.at("X").get_number(),
|
||||
json.at("Y").get_number(), json.at("Z").get_number()};
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include "wpi/util/json.hpp"
|
||||
|
||||
void wpi::math::to_json(wpi::util::json& json, const Rotation2d& rotation) {
|
||||
json = wpi::util::json{{"radians", rotation.Radians().value()}};
|
||||
json = wpi::util::json::object("radians", rotation.Radians().value());
|
||||
}
|
||||
|
||||
void wpi::math::from_json(const wpi::util::json& json, Rotation2d& rotation) {
|
||||
rotation = Rotation2d{wpi::units::radian_t{json.at("radians").get<double>()}};
|
||||
rotation = Rotation2d{wpi::units::radian_t{json.at("radians").get_number()}};
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "wpi/util/json.hpp"
|
||||
|
||||
void wpi::math::to_json(wpi::util::json& json, const Rotation3d& rotation) {
|
||||
json = wpi::util::json{{"quaternion", rotation.GetQuaternion()}};
|
||||
json = wpi::util::json::object("quaternion", rotation.GetQuaternion());
|
||||
}
|
||||
|
||||
void wpi::math::from_json(const wpi::util::json& json, Rotation3d& rotation) {
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
|
||||
void wpi::math::to_json(wpi::util::json& json,
|
||||
const Translation2d& translation) {
|
||||
json = wpi::util::json{{"x", translation.X().value()},
|
||||
{"y", translation.Y().value()}};
|
||||
json.set_object();
|
||||
json["x"] = translation.X().value();
|
||||
json["y"] = translation.Y().value();
|
||||
}
|
||||
|
||||
void wpi::math::from_json(const wpi::util::json& json,
|
||||
Translation2d& translation) {
|
||||
translation = Translation2d{wpi::units::meter_t{json.at("x").get<double>()},
|
||||
wpi::units::meter_t{json.at("y").get<double>()}};
|
||||
translation = Translation2d{wpi::units::meter_t{json.at("x").get_number()},
|
||||
wpi::units::meter_t{json.at("y").get_number()}};
|
||||
}
|
||||
|
||||
@@ -8,14 +8,15 @@
|
||||
|
||||
void wpi::math::to_json(wpi::util::json& json,
|
||||
const Translation3d& translation) {
|
||||
json = wpi::util::json{{"x", translation.X().value()},
|
||||
{"y", translation.Y().value()},
|
||||
{"z", translation.Z().value()}};
|
||||
json.set_object();
|
||||
json["x"] = translation.X().value();
|
||||
json["y"] = translation.Y().value();
|
||||
json["z"] = translation.Z().value();
|
||||
}
|
||||
|
||||
void wpi::math::from_json(const wpi::util::json& json,
|
||||
Translation3d& translation) {
|
||||
translation = Translation3d{wpi::units::meter_t{json.at("x").get<double>()},
|
||||
wpi::units::meter_t{json.at("y").get<double>()},
|
||||
wpi::units::meter_t{json.at("z").get<double>()}};
|
||||
translation = Translation3d{wpi::units::meter_t{json.at("x").get_number()},
|
||||
wpi::units::meter_t{json.at("y").get_number()},
|
||||
wpi::units::meter_t{json.at("z").get_number()}};
|
||||
}
|
||||
|
||||
@@ -9,20 +9,21 @@
|
||||
using namespace wpi::math;
|
||||
|
||||
void wpi::math::to_json(wpi::util::json& json, const Trajectory::State& state) {
|
||||
json = wpi::util::json{{"time", state.t.value()},
|
||||
{"velocity", state.velocity.value()},
|
||||
{"acceleration", state.acceleration.value()},
|
||||
{"pose", state.pose},
|
||||
{"curvature", state.curvature.value()}};
|
||||
json.set_object();
|
||||
json["time"] = state.t.value();
|
||||
json["velocity"] = state.velocity.value();
|
||||
json["acceleration"] = state.acceleration.value();
|
||||
json["pose"] = state.pose;
|
||||
json["curvature"] = state.curvature.value();
|
||||
}
|
||||
|
||||
void wpi::math::from_json(const wpi::util::json& json,
|
||||
Trajectory::State& state) {
|
||||
state.pose = json.at("pose").get<Pose2d>();
|
||||
state.t = wpi::units::second_t{json.at("time").get<double>()};
|
||||
state.t = wpi::units::second_t{json.at("time").get_number()};
|
||||
state.velocity =
|
||||
wpi::units::meters_per_second_t{json.at("velocity").get<double>()};
|
||||
wpi::units::meters_per_second_t{json.at("velocity").get_number()};
|
||||
state.acceleration = wpi::units::meters_per_second_squared_t{
|
||||
json.at("acceleration").get<double>()};
|
||||
state.curvature = wpi::units::curvature_t{json.at("curvature").get<double>()};
|
||||
json.at("acceleration").get_number()};
|
||||
state.curvature = wpi::units::curvature_t{json.at("curvature").get_number()};
|
||||
}
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
#include "wpi/math/geometry/Translation2d.hpp"
|
||||
#include "wpi/units/length.hpp"
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
#include "wpi/util/json_fwd.hpp"
|
||||
|
||||
namespace wpi::util {
|
||||
class json;
|
||||
} // namespace wpi::util
|
||||
|
||||
namespace wpi::math {
|
||||
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
#include "wpi/math/geometry/Rotation3d.hpp"
|
||||
#include "wpi/math/geometry/Translation3d.hpp"
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
#include "wpi/util/json_fwd.hpp"
|
||||
|
||||
namespace wpi::util {
|
||||
class json;
|
||||
} // namespace wpi::util
|
||||
|
||||
namespace wpi::math {
|
||||
|
||||
|
||||
@@ -10,7 +10,10 @@
|
||||
#include <gcem.hpp>
|
||||
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
#include "wpi/util/json_fwd.hpp"
|
||||
|
||||
namespace wpi::util {
|
||||
class json;
|
||||
} // namespace wpi::util
|
||||
|
||||
namespace wpi::math {
|
||||
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
#include "wpi/units/angle.hpp"
|
||||
#include "wpi/util/StackTrace.hpp"
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
#include "wpi/util/json_fwd.hpp"
|
||||
|
||||
namespace wpi::util {
|
||||
class json;
|
||||
} // namespace wpi::util
|
||||
|
||||
namespace wpi::math {
|
||||
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
#include "wpi/units/math.hpp"
|
||||
#include "wpi/util/MathExtras.hpp"
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
#include "wpi/util/json_fwd.hpp"
|
||||
|
||||
namespace wpi::util {
|
||||
class json;
|
||||
} // namespace wpi::util
|
||||
|
||||
namespace wpi::math {
|
||||
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
#include "wpi/units/length.hpp"
|
||||
#include "wpi/units/math.hpp"
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
#include "wpi/util/json_fwd.hpp"
|
||||
|
||||
namespace wpi::util {
|
||||
class json;
|
||||
} // namespace wpi::util
|
||||
|
||||
namespace wpi::math {
|
||||
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
#include "wpi/units/length.hpp"
|
||||
#include "wpi/units/math.hpp"
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
#include "wpi/util/json_fwd.hpp"
|
||||
|
||||
namespace wpi::util {
|
||||
class json;
|
||||
} // namespace wpi::util
|
||||
|
||||
namespace wpi::math {
|
||||
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
#include "wpi/units/velocity.hpp"
|
||||
#include "wpi/util/MathExtras.hpp"
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
#include "wpi/util/json_fwd.hpp"
|
||||
|
||||
namespace wpi::util {
|
||||
class json;
|
||||
} // namespace wpi::util
|
||||
|
||||
namespace wpi::math {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user