// 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. #pragma once #include #include #include #include "frc/EigenCore.h" template struct wpi::Struct> { static constexpr ct_string kTypeName = wpi::Concat("Vector__"_ct_string, wpi::NumToCtString()); static constexpr std::string_view GetTypeName() { return kTypeName; } static constexpr size_t GetSize() { return Size * 8; } static constexpr ct_string kSchema = wpi::Concat( "double data["_ct_string, wpi::NumToCtString(), "]"_ct_string); static constexpr std::string_view GetSchema() { return kSchema; } static frc::Matrixd Unpack( std::span data) { constexpr size_t kDataOff = 0; wpi::array vec_data = wpi::UnpackStructArray(data); frc::Matrixd vec; for (int i = 0; i < Size; i++) { vec(i) = vec_data[i]; } return vec; } static void Pack( std::span data, const frc::Matrixd& value) { constexpr size_t kDataOff = 0; wpi::array vec_data(wpi::empty_array); for (int i = 0; i < Size; i++) { vec_data[i] = value(i); } wpi::PackStructArray(data, vec_data); } }; static_assert(wpi::StructSerializable>); static_assert(wpi::StructSerializable>);