ReduxLib C++ 2025.0.0-beta2
Loading...
Searching...
No Matches
CanandgyroStruct.h
1// Copyright (c) Redux Robotics and other contributors.
2// This is open source and can be modified and shared under the 3-clause BSD license.
3
4#pragma once
5#include "redux/sensors/canandgyro/CanandgyroFaults.h"
6#include "redux/sensors/canandgyro/CanandgyroData.h"
7#include "redux/sensors/canandgyro/CanandgyroStatus.h"
8#include "wpi/struct/Struct.h"
9
10namespace wpi {
11
12/** WPILib struct template for CanandgyroFaults */
13template <>
15 /** @return Type string name */
16 static constexpr std::string_view GetTypeName() {
17 return "CanandgyroFaults";
18 }
19 /** @return size of serialized payload in bytes */
20 static constexpr size_t GetSize() { return 1; }
21
22 /** @return wpistruct schema */
23 static constexpr std::string_view GetSchema() {
24 return (
25 "bool power_cycle:1;"
26 "bool can_id_conflict:1;"
27 "bool can_general_error:1;"
28 "bool out_of_temperature_range:1;"
29 "bool hardware_fault:1;"
30 "bool calibrating:1;"
31 "bool angular_velocity_saturation:1;"
32 "bool acceleration_saturation:1;"
33 );
34 }
35
36 /**
37 * @param data to unpack to object
38 * @return CanandgyroFaults
39 */
40 static ::redux::sensors::canandgyro::CanandgyroFaults Unpack(std::span<const uint8_t> data);
41 /**
42 * @param data to pack object into
43 * @param value object reference
44 */
45 static void Pack(std::span<uint8_t> data,
46 const ::redux::sensors::canandgyro::CanandgyroFaults& value);
47};
48
49/** WPILib struct template for CanandgyroStatus */
50template <>
52 /** @return Type string name */
53 static constexpr std::string_view GetTypeName() {
54 return "CanandgyroStatus";
55 }
56 /** @return size of serialized payload in bytes */
57 static constexpr size_t GetSize() { return 10; }
58 /** @return wpistruct schema */
59 static constexpr std::string_view GetSchema() {
60 return (
61 "CanandgyroFaults active_faults;"
62 "CanandgyroFaults sticky_faults;"
63 "double temperature;"
64 );
65 }
66
67 /**
68 * @param data to unpack to object
69 * @return CanandgyroStatus
70 */
71 static ::redux::sensors::canandgyro::CanandgyroStatus Unpack(std::span<const uint8_t> data);
72 /**
73 * @param data to pack object into
74 * @param value object reference
75 */
76 static void Pack(std::span<uint8_t> data,
77 const ::redux::sensors::canandgyro::CanandgyroStatus& value);
78 /**
79 * @param fn to run
80 */
81 static void ForEachNested(
82 std::invocable<std::string_view, std::string_view> auto fn) {
83 wpi::ForEachStructSchema<::redux::sensors::canandgyro::CanandgyroFaults>(fn);
84 }
85};
86
87/** WPILib struct template for Canandgyro AngularVelocity */
88template <>
90 /** @return Type string name */
91 static constexpr std::string_view GetTypeName() {
92 return "CanandgyroAngularVelocity";
93 }
94 /** @return size of serialized payload in bytes */
95 static constexpr size_t GetSize() { return 24; }
96 /** @return wpistruct schema */
97 static constexpr std::string_view GetSchema() {
98 return (
99 "double roll;"
100 "double pitch;"
101 "double yaw;"
102 );
103 }
104
105 /**
106 * @param data to unpack to object
107 * @return object
108 */
109 static ::redux::sensors::canandgyro::AngularVelocity Unpack(std::span<const uint8_t> data);
110 /**
111 * @param data to pack object into
112 * @param value object reference
113 */
114 static void Pack(std::span<uint8_t> data,
115 const ::redux::sensors::canandgyro::AngularVelocity& value);
116};
117
118/** WPILib struct template for Canandgyro Acceleration */
119template <>
121 /** @return Type string name */
122 static constexpr std::string_view GetTypeName() {
123 return "CanandgyroAcceleration";
124 }
125 /** @return size of serialized payload in bytes */
126 static constexpr size_t GetSize() { return 24; }
127 /** @return wpistruct schema */
128 static constexpr std::string_view GetSchema() {
129 return (
130 "double x;"
131 "double y;"
132 "double z;"
133 );
134 }
135
136 /**
137 * @param data to unpack to object
138 * @return object
139 */
140 static ::redux::sensors::canandgyro::Acceleration Unpack(std::span<const uint8_t> data);
141 /**
142 * @param data to pack object into
143 * @param value object reference
144 */
145 static void Pack(std::span<uint8_t> data,
146 const ::redux::sensors::canandgyro::Acceleration& value);
147};
148}
149
150
151static_assert(wpi::StructSerializable<::redux::sensors::canandgyro::AngularVelocity>);
152static_assert(wpi::StructSerializable<::redux::sensors::canandgyro::Acceleration>);
153static_assert(wpi::StructSerializable<::redux::sensors::canandgyro::CanandgyroStatus>);
154static_assert(wpi::StructSerializable<::redux::sensors::canandgyro::CanandgyroFaults>);
155static_assert(wpi::HasNestedStruct<::redux::sensors::canandgyro::CanandgyroStatus>);
Definition: CanandgyroData.h:74
Definition: CanandgyroData.h:17
Definition: CanandgyroFaults.h:13
Definition: CanandgyroStatus.h:13
static constexpr std::string_view GetSchema()
Definition: CanandgyroStruct.h:128
static constexpr size_t GetSize()
Definition: CanandgyroStruct.h:126
static constexpr std::string_view GetTypeName()
Definition: CanandgyroStruct.h:122
static void Pack(std::span< uint8_t > data, const ::redux::sensors::canandgyro::Acceleration &value)
::redux::sensors::canandgyro::Acceleration Unpack(std::span< const uint8_t > data)
static constexpr std::string_view GetSchema()
Definition: CanandgyroStruct.h:97
static void Pack(std::span< uint8_t > data, const ::redux::sensors::canandgyro::AngularVelocity &value)
::redux::sensors::canandgyro::AngularVelocity Unpack(std::span< const uint8_t > data)
static constexpr std::string_view GetTypeName()
Definition: CanandgyroStruct.h:91
static constexpr size_t GetSize()
Definition: CanandgyroStruct.h:95
static constexpr std::string_view GetTypeName()
Definition: CanandgyroStruct.h:16
static constexpr size_t GetSize()
Definition: CanandgyroStruct.h:20
::redux::sensors::canandgyro::CanandgyroFaults Unpack(std::span< const uint8_t > data)
static constexpr std::string_view GetSchema()
Definition: CanandgyroStruct.h:23
static void Pack(std::span< uint8_t > data, const ::redux::sensors::canandgyro::CanandgyroFaults &value)
static constexpr size_t GetSize()
Definition: CanandgyroStruct.h:57
static constexpr std::string_view GetTypeName()
Definition: CanandgyroStruct.h:53
static void Pack(std::span< uint8_t > data, const ::redux::sensors::canandgyro::CanandgyroStatus &value)
::redux::sensors::canandgyro::CanandgyroStatus Unpack(std::span< const uint8_t > data)
static void ForEachNested(std::invocable< std::string_view, std::string_view > auto fn)
Definition: CanandgyroStruct.h:81
static constexpr std::string_view GetSchema()
Definition: CanandgyroStruct.h:59