WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
SwerveDriveKinematicsStruct.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <fmt/format.h>
8
12
13template <size_t NumModules>
15 static constexpr ct_string kTypeName =
16 wpi::util::Concat("SwerveDriveKinematics__"_ct_string,
18 static constexpr std::string_view GetTypeName() { return kTypeName; }
19 static constexpr size_t GetSize() {
21 }
22 static constexpr ct_string kSchema =
23 wpi::util::Concat("Translation2d modules["_ct_string,
25 static constexpr std::string_view GetSchema() { return kSchema; }
26
28 std::span<const uint8_t> data) {
29 constexpr size_t kModulesOff = 0;
32 NumModules>(data)};
33 }
34
35 static void Pack(std::span<uint8_t> data,
37 constexpr size_t kModulesOff = 0;
39 value.GetModules());
40 }
41
42 static void ForEachNested(
43 std::invocable<std::string_view, std::string_view> auto fn) {
45 }
46};
47
48static_assert(
51static_assert(
Helper class that converts a chassis velocity (dx, dy, and dtheta components) into individual module ...
Definition SwerveDriveKinematics.hpp:59
const wpi::util::array< Translation2d, NumModules > & GetModules() const
Definition SwerveDriveKinematics.hpp:463
Represents a translation in 2D space.
Definition Translation2d.hpp:30
Specifies that a struct type has nested struct declarations.
Definition Struct.hpp:120
Specifies that a type is capable of raw struct serialization and deserialization.
Definition Struct.hpp:69
void ForEachStructSchema(std::invocable< std::string_view, std::string_view > auto fn, const I &... info)
Definition Struct.hpp:424
void PackStructArray(std::span< uint8_t > data, const wpi::util::array< T, N > &arr)
Pack a serialized struct array starting at a given offset within the data.
Definition Struct.hpp:234
constexpr auto NumToCtString()
Converts any integral to a ct_string at compile-time.
Definition ct_string.hpp:202
constexpr auto Concat(ct_string< Char, Traits, N1 > const &s1, ct_string< Char, Traits, N > const &... s)
Concatenates multiple fixed_strings into a larger fixed_string at compile time.
Definition ct_string.hpp:168
wpi::util::array< T, N > UnpackStructArray(std::span< const uint8_t > data)
Unpack a serialized struct array starting at a given offset within the data.
Definition Struct.hpp:172
Definition CvSource.hpp:15
static void ForEachNested(std::invocable< std::string_view, std::string_view > auto fn)
Definition SwerveDriveKinematicsStruct.hpp:42
static constexpr std::string_view GetTypeName()
Definition SwerveDriveKinematicsStruct.hpp:18
static constexpr ct_string kTypeName
Definition SwerveDriveKinematicsStruct.hpp:15
static wpi::math::SwerveDriveKinematics< NumModules > Unpack(std::span< const uint8_t > data)
Definition SwerveDriveKinematicsStruct.hpp:27
static constexpr std::string_view GetSchema()
Definition SwerveDriveKinematicsStruct.hpp:25
static constexpr size_t GetSize()
Definition SwerveDriveKinematicsStruct.hpp:19
static void Pack(std::span< uint8_t > data, const wpi::math::SwerveDriveKinematics< NumModules > &value)
Definition SwerveDriveKinematicsStruct.hpp:35
static constexpr ct_string kSchema
Definition SwerveDriveKinematicsStruct.hpp:22
Struct serialization template.
Definition Struct.hpp:39
Fixed length string (array of character) for compile time use.
Definition ct_string.hpp:29