WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
SwerveDriveKinematicsProto.h
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 <stdexcept>
8
9#include <fmt/format.h>
12
15
16template <size_t NumModules>
17struct wpi::Protobuf<frc::SwerveDriveKinematics<NumModules>> {
23
24 static std::optional<frc::SwerveDriveKinematics<NumModules>> Unpack(
25 InputStream& stream) {
28 .modules = modules.Callback(),
29 };
31 if (!stream.Decode(msg)) {
32 return {};
33 }
34
36 }
37
38 static bool Pack(OutputStream& stream,
40 wpi::PackCallback<frc::Translation2d> modules{value.GetModules()};
42 .modules = modules.Callback(),
43 };
44 return stream.Encode(msg);
45 }
46};
Helper class that converts a chassis velocity (dx, dy, and dtheta components) into individual module ...
Definition SwerveDriveKinematics.h:54
pb_callback_t Callback() const
Gets the nanopb callback pointing to this object.
Definition ProtobufCallbacks.h:141
void SetLimits(DecodeLimits limit) noexcept
Set the limits on what happens if more elements exist in the buffer then expected.
Definition ProtobufCallbacks.h:134
A callback method that will pack elements when called.
Definition ProtobufCallbacks.h:486
Class for wrapping a nanopb istream.
Definition Protobuf.h:55
bool Decode(typename Protobuf< std::remove_cvref_t< T > >::MessageStruct &msg, unsigned int flags=0)
Decodes a protobuf.
Definition Protobuf.h:104
Class for wrapping a nanopb ostream.
Definition Protobuf.h:119
bool Encode(const typename Protobuf< std::remove_cvref_t< T > >::MessageStruct &msg)
Decodes a protobuf.
Definition Protobuf.h:211
struct _wpi_proto_ProtobufSwerveDriveKinematics wpi_proto_ProtobufSwerveDriveKinematics
Definition CAN.h:11
Definition kinematics.npb.h:88
static std::optional< frc::SwerveDriveKinematics< NumModules > > Unpack(InputStream &stream)
Definition SwerveDriveKinematicsProto.h:24
static bool Pack(OutputStream &stream, const frc::SwerveDriveKinematics< NumModules > &value)
Definition SwerveDriveKinematicsProto.h:38
Protobuf serialization template.
Definition Protobuf.h:36
A DirectUnpackCallback backed by a wpi::array<T, N>.
Definition ProtobufCallbacks.h:446
wpi::array< T, N > & Array() noexcept
Returns a reference to the backing array.
Definition ProtobufCallbacks.h:474