Files
allwpilib/wpimath/src/main/native/cpp/controller/struct/DifferentialDriveFeedforwardStruct.cpp
Gold856 35e8abedeb Don't force public variables to use Hungarian notation (#8774)
People generally have expressed a dislike for the Hungarian notation
used in member variables, especially in examples/templates, and our
styleguide shouldn't be forced on downstream consumers, so this removes
all Hungarian notation from the examples/templates.

There are _some_ benefits to Hungarian for private member variables
(like knowing what's a member vs. local in a PR review) so we'll keep
private member variables the same for now, but public variables should
no longer use Hungarian notation, since it looks much worse. A new PMD
XPath rule has been added to accomplish this goal. Some other
non-compliant variables were fixed for the new rule.
2026-04-25 11:32:08 -07:00

35 lines
1.5 KiB
C++

// 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.
#include "wpi/math/controller/struct/DifferentialDriveFeedforwardStruct.hpp"
namespace {
constexpr size_t kKvLinearOff = 0;
constexpr size_t kKaLinearOff = kKvLinearOff + 8;
constexpr size_t kKvAngularOff = kKaLinearOff + 8;
constexpr size_t kKaAngularOff = kKvAngularOff + 8;
} // namespace
wpi::math::DifferentialDriveFeedforward
wpi::util::Struct<wpi::math::DifferentialDriveFeedforward>::Unpack(
std::span<const uint8_t> data) {
return {decltype(1_V /
1_mps){wpi::util::UnpackStruct<double, kKvLinearOff>(data)},
decltype(1_V / 1_mps_sq){
wpi::util::UnpackStruct<double, kKaLinearOff>(data)},
decltype(1_V /
1_mps){wpi::util::UnpackStruct<double, kKvAngularOff>(data)},
decltype(1_V / 1_mps_sq){
wpi::util::UnpackStruct<double, kKaAngularOff>(data)}};
}
void wpi::util::Struct<wpi::math::DifferentialDriveFeedforward>::Pack(
std::span<uint8_t> data,
const wpi::math::DifferentialDriveFeedforward& value) {
wpi::util::PackStruct<kKvLinearOff>(data, value.kVLinear.value());
wpi::util::PackStruct<kKaLinearOff>(data, value.kALinear.value());
wpi::util::PackStruct<kKvAngularOff>(data, value.kVAngular.value());
wpi::util::PackStruct<kKaAngularOff>(data, value.kAAngular.value());
}