WPILibC++ 2024.3.2
Pose2dStruct.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 <wpi/SymbolExports.h>
8#include <wpi/struct/Struct.h>
9
10#include "frc/geometry/Pose2d.h"
11
12template <>
13struct WPILIB_DLLEXPORT wpi::Struct<frc::Pose2d> {
14 static constexpr std::string_view GetTypeString() { return "struct:Pose2d"; }
15 static constexpr size_t GetSize() {
16 return wpi::GetStructSize<frc::Translation2d>() +
17 wpi::GetStructSize<frc::Rotation2d>();
18 }
19 static constexpr std::string_view GetSchema() {
20 return "Translation2d translation;Rotation2d rotation";
21 }
22
23 static frc::Pose2d Unpack(std::span<const uint8_t> data);
24 static void Pack(std::span<uint8_t> data, const frc::Pose2d& value);
25 static void ForEachNested(
26 std::invocable<std::string_view, std::string_view> auto fn) {
27 wpi::ForEachStructSchema<frc::Translation2d>(fn);
28 wpi::ForEachStructSchema<frc::Rotation2d>(fn);
29 }
30};
31
#define WPILIB_DLLEXPORT
Definition: SymbolExports.h:36
Represents a 2D pose containing translational and rotational elements.
Definition: Pose2d.h:23
Specifies that a struct type has nested struct declarations.
Definition: Struct.h:119
Specifies that a type is capable of raw struct serialization and deserialization.
Definition: Struct.h:68
basic_string_view< char > string_view
Definition: core.h:501
Definition: ntcore_cpp.h:26
static void Pack(std::span< uint8_t > data, const frc::Pose2d &value)
static frc::Pose2d Unpack(std::span< const uint8_t > data)
static void ForEachNested(std::invocable< std::string_view, std::string_view > auto fn)
Definition: Pose2dStruct.h:25
static constexpr std::string_view GetTypeString()
Definition: Pose2dStruct.h:14
static constexpr std::string_view GetSchema()
Definition: Pose2dStruct.h:19
static constexpr size_t GetSize()
Definition: Pose2dStruct.h:15