8#include "wpi/units/length.hpp"
15template <
class Distance>
16 requires wpi::units::length_unit<Distance> || wpi::units::angle_unit<Distance>
19 return "SimpleMotorFeedforward";
21 static constexpr size_t GetSize() {
return 32; }
23 return "double ks;double kv;double ka;double dt";
27 std::span<const uint8_t> data) {
29 wpi::units::unit<std::ratio<1>,
30 wpi::units::traits::base_unit_of<Distance>>;
32 constexpr size_t kKsOff = 0;
33 constexpr size_t kKvOff = kKsOff + 8;
34 constexpr size_t kKaOff = kKvOff + 8;
35 constexpr size_t kDtOff = kKaOff + 8;
38 wpi::units::unit_t<typename BaseFeedforward::kv_unit>{
40 wpi::units::unit_t<typename BaseFeedforward::ka_unit>{
45 static void Pack(std::span<uint8_t> data,
48 wpi::units::unit<std::ratio<1>,
49 wpi::units::traits::base_unit_of<Distance>>;
51 constexpr size_t kKsOff = 0;
52 constexpr size_t kKvOff = kKsOff + 8;
53 constexpr size_t kKaOff = kKvOff + 8;
54 constexpr size_t kDtOff = kKaOff + 8;
58 wpi::units::unit_t<typename BaseFeedforward::kv_unit>{value.
GetKv()}
62 wpi::units::unit_t<typename BaseFeedforward::ka_unit>{value.
GetKa()}
65 wpi::units::second_t{value.
GetDt()}.value());
A helper class that computes feedforward voltages for a simple permanent-magnet DC motor.
Definition SimpleMotorFeedforward.hpp:24
constexpr wpi::units::second_t GetDt() const
Returns the period.
Definition SimpleMotorFeedforward.hpp:234
constexpr wpi::units::volt_t GetKs() const
Returns the static gain.
Definition SimpleMotorFeedforward.hpp:213
constexpr wpi::units::unit_t< kv_unit > GetKv() const
Returns the velocity gain.
Definition SimpleMotorFeedforward.hpp:220
constexpr wpi::units::unit_t< ka_unit > GetKa() const
Returns the acceleration gain.
Definition SimpleMotorFeedforward.hpp:227
Specifies that a type is capable of raw struct serialization and deserialization.
Definition Struct.hpp:69
void PackStruct(std::span< uint8_t > data, T &&value, const I &... info)
Pack a serialized struct.
Definition Struct.hpp:200
T UnpackStruct(std::span< const uint8_t > data, const I &... info)
Unpack a serialized struct.
Definition Struct.hpp:138
Definition CvSource.hpp:15
static wpi::math::SimpleMotorFeedforward< Distance > Unpack(std::span< const uint8_t > data)
Definition SimpleMotorFeedforwardStruct.hpp:26
static void Pack(std::span< uint8_t > data, const wpi::math::SimpleMotorFeedforward< Distance > &value)
Definition SimpleMotorFeedforwardStruct.hpp:45
static constexpr std::string_view GetTypeName()
Definition SimpleMotorFeedforwardStruct.hpp:18
static constexpr size_t GetSize()
Definition SimpleMotorFeedforwardStruct.hpp:21
static constexpr std::string_view GetSchema()
Definition SimpleMotorFeedforwardStruct.hpp:22
Struct serialization template.
Definition Struct.hpp:39