2024-03-09 12:09:02 -06: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.
|
|
|
|
|
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/math/kinematics/struct/DifferentialDriveWheelPositionsStruct.hpp"
|
2024-03-09 12:09:02 -06:00
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
constexpr size_t kLeftOff = 0;
|
|
|
|
|
constexpr size_t kRightOff = kLeftOff + 8;
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
using StructType = wpi::util::Struct<wpi::math::DifferentialDriveWheelPositions>;
|
2024-03-09 12:09:02 -06:00
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
wpi::math::DifferentialDriveWheelPositions StructType::Unpack(
|
2024-03-09 12:09:02 -06:00
|
|
|
std::span<const uint8_t> data) {
|
2025-11-07 20:00:05 -05:00
|
|
|
return wpi::math::DifferentialDriveWheelPositions{
|
|
|
|
|
wpi::units::meter_t{wpi::util::UnpackStruct<double, kLeftOff>(data)},
|
|
|
|
|
wpi::units::meter_t{wpi::util::UnpackStruct<double, kRightOff>(data)},
|
2024-03-09 12:09:02 -06:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StructType::Pack(std::span<uint8_t> data,
|
2025-11-07 20:00:05 -05:00
|
|
|
const wpi::math::DifferentialDriveWheelPositions& value) {
|
|
|
|
|
wpi::util::PackStruct<kLeftOff>(data, value.left.value());
|
|
|
|
|
wpi::util::PackStruct<kRightOff>(data, value.right.value());
|
2024-03-09 12:09:02 -06:00
|
|
|
}
|