mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[wpimath] Add protobuf/struct for trivial types (#5935)
This implements de/serialization for the types that aren't templated (SwerveDriveKinematics) in C++ or where there is no trivial way to go round-trip (Splines) for the messages.
This commit is contained in:
@@ -169,3 +169,6 @@ class WPILIB_DLLEXPORT ArmFeedforward {
|
||||
units::unit_t<ka_unit> kA{0};
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/controller/proto/ArmFeedforwardProto.h"
|
||||
#include "frc/controller/struct/ArmFeedforwardStruct.h"
|
||||
|
||||
@@ -17,3 +17,6 @@ struct DifferentialDriveWheelVoltages {
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/controller/proto/DifferentialDriveWheelVoltagesProto.h"
|
||||
#include "frc/controller/struct/DifferentialDriveWheelVoltagesStruct.h"
|
||||
|
||||
@@ -176,3 +176,6 @@ class ElevatorFeedforward {
|
||||
units::unit_t<ka_unit> kA{0};
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/controller/proto/ElevatorFeedforwardProto.h"
|
||||
#include "frc/controller/struct/ElevatorFeedforwardStruct.h"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/controller/ArmFeedforward.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::ArmFeedforward> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::ArmFeedforward Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::ArmFeedforward& value);
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/controller/DifferentialDriveWheelVoltages.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::DifferentialDriveWheelVoltages> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::DifferentialDriveWheelVoltages Unpack(
|
||||
const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::DifferentialDriveWheelVoltages& value);
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/controller/ElevatorFeedforward.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::ElevatorFeedforward> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::ElevatorFeedforward Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::ElevatorFeedforward& value);
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/controller/ArmFeedforward.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::ArmFeedforward> {
|
||||
static constexpr std::string_view kTypeString = "struct:ArmFeedforward";
|
||||
static constexpr size_t kSize = 32;
|
||||
static constexpr std::string_view kSchema =
|
||||
"double ks;double kg;double kv;double ka";
|
||||
|
||||
static frc::ArmFeedforward Unpack(std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::ArmFeedforward& value);
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/controller/DifferentialDriveWheelVoltages.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::DifferentialDriveWheelVoltages> {
|
||||
static constexpr std::string_view kTypeString =
|
||||
"struct:DifferentialDriveWheelVoltages";
|
||||
static constexpr size_t kSize = 16;
|
||||
static constexpr std::string_view kSchema = "double left;double right";
|
||||
|
||||
static frc::DifferentialDriveWheelVoltages Unpack(
|
||||
std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::DifferentialDriveWheelVoltages& value);
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/controller/ElevatorFeedforward.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::ElevatorFeedforward> {
|
||||
static constexpr std::string_view kTypeString = "struct:ElevatorFeedforward";
|
||||
static constexpr size_t kSize = 32;
|
||||
static constexpr std::string_view kSchema =
|
||||
"double ks;double kg;double kv;double ka";
|
||||
|
||||
static frc::ElevatorFeedforward Unpack(std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::ElevatorFeedforward& value);
|
||||
};
|
||||
@@ -251,3 +251,6 @@ struct WPILIB_DLLEXPORT ChassisSpeeds {
|
||||
}
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/ChassisSpeedsProto.h"
|
||||
#include "frc/kinematics/struct/ChassisSpeedsStruct.h"
|
||||
|
||||
@@ -91,3 +91,6 @@ class WPILIB_DLLEXPORT DifferentialDriveKinematics
|
||||
units::meter_t trackWidth;
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/DifferentialDriveKinematicsProto.h"
|
||||
#include "frc/kinematics/struct/DifferentialDriveKinematicsStruct.h"
|
||||
|
||||
@@ -112,3 +112,6 @@ struct WPILIB_DLLEXPORT DifferentialDriveWheelSpeeds {
|
||||
}
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/DifferentialDriveWheelSpeedsProto.h"
|
||||
#include "frc/kinematics/struct/DifferentialDriveWheelSpeedsStruct.h"
|
||||
|
||||
@@ -138,6 +138,11 @@ class WPILIB_DLLEXPORT MecanumDriveKinematics
|
||||
*/
|
||||
Twist2d ToTwist2d(const MecanumDriveWheelPositions& wheelDeltas) const;
|
||||
|
||||
const Translation2d GetFrontLeftWheel() const { return m_frontLeftWheel; }
|
||||
const Translation2d GetFrontRightWheel() const { return m_frontRightWheel; }
|
||||
const Translation2d GetRearLeftWheel() const { return m_rearLeftWheel; }
|
||||
const Translation2d GetRearRightWheel() const { return m_rearRightWheel; }
|
||||
|
||||
private:
|
||||
mutable Matrixd<4, 3> m_inverseKinematics;
|
||||
Eigen::HouseholderQR<Matrixd<4, 3>> m_forwardKinematics;
|
||||
@@ -165,3 +170,6 @@ class WPILIB_DLLEXPORT MecanumDriveKinematics
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/MecanumDriveKinematicsProto.h"
|
||||
#include "frc/kinematics/struct/MecanumDriveKinematicsStruct.h"
|
||||
|
||||
@@ -60,3 +60,6 @@ struct WPILIB_DLLEXPORT MecanumDriveWheelPositions {
|
||||
}
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/MecanumDriveWheelPositionsProto.h"
|
||||
#include "frc/kinematics/struct/MecanumDriveWheelPositionsStruct.h"
|
||||
|
||||
@@ -120,3 +120,6 @@ struct WPILIB_DLLEXPORT MecanumDriveWheelSpeeds {
|
||||
}
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/MecanumDriveWheelSpeedsProto.h"
|
||||
#include "frc/kinematics/struct/MecanumDriveWheelSpeedsStruct.h"
|
||||
|
||||
@@ -42,3 +42,6 @@ struct WPILIB_DLLEXPORT SwerveModulePosition {
|
||||
}
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/SwerveModulePositionProto.h"
|
||||
#include "frc/kinematics/struct/SwerveModulePositionStruct.h"
|
||||
|
||||
@@ -47,3 +47,6 @@ struct WPILIB_DLLEXPORT SwerveModuleState {
|
||||
const Rotation2d& currentAngle);
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/kinematics/proto/SwerveModuleStateProto.h"
|
||||
#include "frc/kinematics/struct/SwerveModuleStateStruct.h"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/ChassisSpeeds.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::ChassisSpeeds> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::ChassisSpeeds Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::ChassisSpeeds& value);
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/DifferentialDriveKinematics.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::DifferentialDriveKinematics> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::DifferentialDriveKinematics Unpack(
|
||||
const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::DifferentialDriveKinematics& value);
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/DifferentialDriveWheelSpeeds.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::DifferentialDriveWheelSpeeds> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::DifferentialDriveWheelSpeeds Unpack(
|
||||
const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::DifferentialDriveWheelSpeeds& value);
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/MecanumDriveKinematics.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::MecanumDriveKinematics> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::MecanumDriveKinematics Unpack(
|
||||
const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::MecanumDriveKinematics& value);
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/MecanumDriveWheelPositions.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::MecanumDriveWheelPositions> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::MecanumDriveWheelPositions Unpack(
|
||||
const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::MecanumDriveWheelPositions& value);
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/MecanumDriveWheelSpeeds.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::MecanumDriveWheelSpeeds> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::MecanumDriveWheelSpeeds Unpack(
|
||||
const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::MecanumDriveWheelSpeeds& value);
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/SwerveModulePosition.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::SwerveModulePosition> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::SwerveModulePosition Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::SwerveModulePosition& value);
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/kinematics/SwerveModuleState.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::SwerveModuleState> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::SwerveModuleState Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::SwerveModuleState& value);
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/ChassisSpeeds.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::ChassisSpeeds> {
|
||||
static constexpr std::string_view kTypeString = "struct:ChassisSpeeds";
|
||||
static constexpr size_t kSize = 24;
|
||||
static constexpr std::string_view kSchema =
|
||||
"double vx;double vy;double omega";
|
||||
|
||||
static frc::ChassisSpeeds Unpack(std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::ChassisSpeeds& value);
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/DifferentialDriveKinematics.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::DifferentialDriveKinematics> {
|
||||
static constexpr std::string_view kTypeString =
|
||||
"struct:DifferentialDriveKinematics";
|
||||
static constexpr size_t kSize = 8;
|
||||
static constexpr std::string_view kSchema = "double track_width";
|
||||
|
||||
static frc::DifferentialDriveKinematics Unpack(
|
||||
std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::DifferentialDriveKinematics& value);
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/DifferentialDriveWheelSpeeds.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::DifferentialDriveWheelSpeeds> {
|
||||
static constexpr std::string_view kTypeString =
|
||||
"struct:DifferentialDriveWheelSpeeds";
|
||||
static constexpr size_t kSize = 16;
|
||||
static constexpr std::string_view kSchema = "double left;double right";
|
||||
|
||||
static frc::DifferentialDriveWheelSpeeds Unpack(
|
||||
std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::DifferentialDriveWheelSpeeds& value);
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/MecanumDriveKinematics.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::MecanumDriveKinematics> {
|
||||
static constexpr std::string_view kTypeString =
|
||||
"struct:MecanumDriveKinematics";
|
||||
static constexpr size_t kSize = 4 * wpi::Struct<frc::Translation2d>::kSize;
|
||||
static constexpr std::string_view kSchema =
|
||||
"Translation2d front_left;Translation2d front_right;Translation2d "
|
||||
"rear_left;Translation2d rear_right";
|
||||
|
||||
static frc::MecanumDriveKinematics Unpack(
|
||||
std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::MecanumDriveKinematics& value);
|
||||
static void ForEachNested(
|
||||
std::invocable<std::string_view, std::string_view> auto fn);
|
||||
};
|
||||
|
||||
static_assert(wpi::HasNestedStruct<frc::MecanumDriveKinematics>);
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/MecanumDriveWheelPositions.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::MecanumDriveWheelPositions> {
|
||||
static constexpr std::string_view kTypeString =
|
||||
"struct:MecanumDriveWheelPositions";
|
||||
static constexpr size_t kSize = 32;
|
||||
static constexpr std::string_view kSchema =
|
||||
"double front_left;double front_right;double rear_left;double rear_right";
|
||||
|
||||
static frc::MecanumDriveWheelPositions Unpack(
|
||||
std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::MecanumDriveWheelPositions& value);
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/MecanumDriveWheelSpeeds.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::MecanumDriveWheelSpeeds> {
|
||||
static constexpr std::string_view kTypeString =
|
||||
"struct:MecanumDriveWheelSpeeds";
|
||||
static constexpr size_t kSize = 32;
|
||||
static constexpr std::string_view kSchema =
|
||||
"double front_left;double front_right;double rear_left;double rear_right";
|
||||
|
||||
static frc::MecanumDriveWheelSpeeds Unpack(
|
||||
std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::MecanumDriveWheelSpeeds& value);
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/SwerveModulePosition.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::SwerveModulePosition> {
|
||||
static constexpr std::string_view kTypeString = "struct:SwerveModulePosition";
|
||||
static constexpr size_t kSize = 8 + wpi::Struct<frc::Rotation2d>::kSize;
|
||||
static constexpr std::string_view kSchema =
|
||||
"double distance;Rotation2d angle";
|
||||
|
||||
static frc::SwerveModulePosition Unpack(std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::SwerveModulePosition& value);
|
||||
static void ForEachNested(
|
||||
std::invocable<std::string_view, std::string_view> auto fn);
|
||||
};
|
||||
|
||||
static_assert(wpi::HasNestedStruct<frc::SwerveModulePosition>);
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/kinematics/SwerveModuleState.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::SwerveModuleState> {
|
||||
static constexpr std::string_view kTypeString = "struct:SwerveModuleState";
|
||||
static constexpr size_t kSize = 8 + wpi::Struct<frc::Rotation2d>::kSize;
|
||||
static constexpr std::string_view kSchema = "double speed;Rotation2d angle";
|
||||
|
||||
static frc::SwerveModuleState Unpack(std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data,
|
||||
const frc::SwerveModuleState& value);
|
||||
static void ForEachNested(
|
||||
std::invocable<std::string_view, std::string_view> auto fn);
|
||||
};
|
||||
|
||||
static_assert(wpi::HasNestedStruct<frc::SwerveModuleState>);
|
||||
@@ -239,3 +239,6 @@ class WPILIB_DLLEXPORT DCMotor {
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/system/plant/proto/DCMotorProto.h"
|
||||
#include "frc/system/plant/struct/DCMotorStruct.h"
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/system/plant/DCMotor.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::DCMotor> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::DCMotor Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg, const frc::DCMotor& value);
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/struct/Struct.h>
|
||||
|
||||
#include "frc/system/plant/DCMotor.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::DCMotor> {
|
||||
static constexpr std::string_view kTypeString = "struct:DCMotor";
|
||||
static constexpr size_t kSize = 40;
|
||||
static constexpr std::string_view kSchema =
|
||||
"double nominal_voltage;double stall_torque;double stall_current;double "
|
||||
"free_current;double free_speed";
|
||||
|
||||
static frc::DCMotor Unpack(std::span<const uint8_t, kSize> data);
|
||||
static void Pack(std::span<uint8_t, kSize> data, const frc::DCMotor& value);
|
||||
};
|
||||
@@ -145,3 +145,6 @@ WPILIB_DLLEXPORT
|
||||
void from_json(const wpi::json& json, Trajectory::State& state);
|
||||
|
||||
} // namespace frc
|
||||
|
||||
#include "frc/trajectory/proto/TrajectoryProto.h"
|
||||
#include "frc/trajectory/proto/TrajectoryStateProto.h"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/trajectory/Trajectory.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Trajectory> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::Trajectory Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::Trajectory& value);
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/protobuf/Protobuf.h>
|
||||
|
||||
#include "frc/trajectory/Trajectory.h"
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Trajectory::State> {
|
||||
static google::protobuf::Message* New(google::protobuf::Arena* arena);
|
||||
static frc::Trajectory::State Unpack(const google::protobuf::Message& msg);
|
||||
static void Pack(google::protobuf::Message* msg,
|
||||
const frc::Trajectory::State& value);
|
||||
};
|
||||
Reference in New Issue
Block a user