mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
[wpimath] Move struct/proto classes to separate files (#5918)
Also add unit tests.
This commit is contained in:
@@ -6,8 +6,6 @@
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/json_fwd.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/geometry/Rotation3d.h"
|
||||
#include "frc/geometry/Translation2d.h"
|
||||
@@ -185,30 +183,6 @@ void from_json(const wpi::json& json, Translation3d& state);
|
||||
|
||||
} // namespace frc
|
||||
|
||||
template <>
|
||||
struct wpi::Struct<frc::Translation3d> {
|
||||
static constexpr std::string_view kTypeString = "struct:Translation3d";
|
||||
static constexpr size_t kSize = 24;
|
||||
static constexpr std::string_view kSchema = "double x;double y;double z";
|
||||
static frc::Translation3d Unpack(std::span<const uint8_t, 24> data) {
|
||||
return {units::meter_t{wpi::UnpackStruct<double, 0>(data)},
|
||||
units::meter_t{wpi::UnpackStruct<double, 8>(data)},
|
||||
units::meter_t{wpi::UnpackStruct<double, 16>(data)}};
|
||||
}
|
||||
static void Pack(std::span<uint8_t, 24> data,
|
||||
const frc::Translation3d& value) {
|
||||
wpi::PackStruct<0>(data, value.X().value());
|
||||
wpi::PackStruct<8>(data, value.Y().value());
|
||||
wpi::PackStruct<16>(data, value.Z().value());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Translation3d> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::Translation3d Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::Translation3d& value);
|
||||
};
|
||||
|
||||
#include "frc/geometry/proto/Translation3dProto.h"
|
||||
#include "frc/geometry/struct/Translation3dStruct.h"
|
||||
#include "frc/geometry/Translation3d.inc"
|
||||
|
||||
Reference in New Issue
Block a user