2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2019-07-24 02:57:39 -04:00
|
|
|
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/math/geometry/Rotation2d.hpp"
|
2019-07-24 02:57:39 -04:00
|
|
|
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/util/json.hpp"
|
2019-11-02 13:35:03 -05:00
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
void wpi::math::to_json(wpi::util::json& json, const Rotation2d& rotation) {
|
2026-03-29 15:38:18 -07:00
|
|
|
json = wpi::util::json::object("radians", rotation.Radians().value());
|
2019-11-02 13:35:03 -05:00
|
|
|
}
|
|
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
void wpi::math::from_json(const wpi::util::json& json, Rotation2d& rotation) {
|
2026-03-29 15:38:18 -07:00
|
|
|
rotation = Rotation2d{wpi::units::radian_t{json.at("radians").get_number()}};
|
2019-11-02 13:35:03 -05:00
|
|
|
}
|