2023-11-21 13:14:06 -05: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/MecanumDriveWheelPositionsStruct.hpp"
|
2023-11-21 13:14:06 -05:00
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
constexpr size_t kFrontLeftOff = 0;
|
|
|
|
|
constexpr size_t kFrontRightOff = kFrontLeftOff + 8;
|
|
|
|
|
constexpr size_t kRearLeftOff = kFrontRightOff + 8;
|
|
|
|
|
constexpr size_t kRearRightOff = kRearLeftOff + 8;
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
using StructType = wpi::util::Struct<wpi::math::MecanumDriveWheelPositions>;
|
2023-11-21 13:14:06 -05:00
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
wpi::math::MecanumDriveWheelPositions StructType::Unpack(
|
2023-12-02 23:36:44 -08:00
|
|
|
std::span<const uint8_t> data) {
|
2025-11-07 20:00:05 -05:00
|
|
|
return wpi::math::MecanumDriveWheelPositions{
|
|
|
|
|
wpi::units::meter_t{wpi::util::UnpackStruct<double, kFrontLeftOff>(data)},
|
|
|
|
|
wpi::units::meter_t{wpi::util::UnpackStruct<double, kFrontRightOff>(data)},
|
|
|
|
|
wpi::units::meter_t{wpi::util::UnpackStruct<double, kRearLeftOff>(data)},
|
|
|
|
|
wpi::units::meter_t{wpi::util::UnpackStruct<double, kRearRightOff>(data)},
|
2023-11-21 13:14:06 -05:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-02 23:36:44 -08:00
|
|
|
void StructType::Pack(std::span<uint8_t> data,
|
2025-11-07 20:00:05 -05:00
|
|
|
const wpi::math::MecanumDriveWheelPositions& value) {
|
|
|
|
|
wpi::util::PackStruct<kFrontLeftOff>(data, value.frontLeft.value());
|
|
|
|
|
wpi::util::PackStruct<kFrontRightOff>(data, value.frontRight.value());
|
|
|
|
|
wpi::util::PackStruct<kRearLeftOff>(data, value.rearLeft.value());
|
|
|
|
|
wpi::util::PackStruct<kRearRightOff>(data, value.rearRight.value());
|
2023-11-21 13:14:06 -05:00
|
|
|
}
|