WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
LinearSystemStruct.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
13
14template <int States, int Inputs, int Outputs>
15struct wpi::util::Struct<wpi::math::LinearSystem<States, Inputs, Outputs>> {
17 "LinearSystem__"_ct_string, wpi::util::NumToCtString<States>(),
18 "_"_ct_string, wpi::util::NumToCtString<Inputs>(), "_"_ct_string,
20 static constexpr std::string_view GetTypeName() { return kTypeName; }
29 " a;"_ct_string,
31 " b;"_ct_string,
33 " c;"_ct_string,
35 " d"_ct_string);
36 static constexpr std::string_view GetSchema() { return kSchema; }
37
57
58 static void Pack(
59 std::span<uint8_t> data,
61 constexpr size_t kAOff = 0;
62 constexpr size_t kBOff =
64 constexpr size_t kCOff =
66 constexpr size_t kDOff =
68 wpi::util::PackStruct<kAOff>(data, value.A());
69 wpi::util::PackStruct<kBOff>(data, value.B());
70 wpi::util::PackStruct<kCOff>(data, value.C());
71 wpi::util::PackStruct<kDOff>(data, value.D());
72 }
73
81};
82
A plant defined using state-space notation.
Definition LinearSystem.hpp:35
constexpr const Matrixd< States, States > & A() const
Returns the system matrix A.
Definition LinearSystem.hpp:104
constexpr const Matrixd< States, Inputs > & B() const
Returns the input matrix B.
Definition LinearSystem.hpp:117
constexpr const Matrixd< Outputs, States > & C() const
Returns the output matrix C.
Definition LinearSystem.hpp:130
constexpr const Matrixd< Outputs, Inputs > & D() const
Returns the feedthrough matrix D.
Definition LinearSystem.hpp:143
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
Eigen::Matrix< double, Rows, Cols, Options, MaxRows, MaxCols > Matrixd
Definition EigenCore.hpp:21
void ForEachStructSchema(std::invocable< std::string_view, std::string_view > auto fn, const I &... info)
Definition Struct.hpp:424
constexpr size_t GetStructSize(const I &... info)
Get the size for a raw struct serializable type.
Definition Struct.hpp:337
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
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
Definition CvSource.hpp:15
static constexpr size_t GetSize()
Definition LinearSystemStruct.hpp:21
static constexpr ct_string kTypeName
Definition LinearSystemStruct.hpp:16
static void Pack(std::span< uint8_t > data, const wpi::math::LinearSystem< States, Inputs, Outputs > &value)
Definition LinearSystemStruct.hpp:58
static constexpr ct_string kSchema
Definition LinearSystemStruct.hpp:27
static constexpr std::string_view GetTypeName()
Definition LinearSystemStruct.hpp:20
static constexpr std::string_view GetSchema()
Definition LinearSystemStruct.hpp:36
static wpi::math::LinearSystem< States, Inputs, Outputs > Unpack(std::span< const uint8_t > data)
Definition LinearSystemStruct.hpp:38
static void ForEachNested(std::invocable< std::string_view, std::string_view > auto fn)
Definition LinearSystemStruct.hpp:74
Struct serialization template.
Definition Struct.hpp:39
Fixed length string (array of character) for compile time use.
Definition ct_string.hpp:29