[wpimath] Struct cleanup (#6011)

This commit is contained in:
Joseph Eng
2023-12-04 22:40:18 -08:00
committed by GitHub
parent 90757b9e90
commit 14c3ade155
32 changed files with 95 additions and 49 deletions

View File

@@ -11,12 +11,16 @@
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 constexpr std::string_view GetTypeString() {
return "struct:ArmFeedforward";
}
static constexpr size_t GetSize() { return 32; }
static constexpr std::string_view GetSchema() {
return "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);
static frc::ArmFeedforward Unpack(std::span<const uint8_t> data);
static void Pack(std::span<uint8_t> data, const frc::ArmFeedforward& value);
};
static_assert(wpi::StructSerializable<frc::ArmFeedforward>);

View File

@@ -11,13 +11,18 @@
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 constexpr std::string_view GetTypeString() {
return "struct:DifferentialDriveWheelVoltages";
}
static constexpr size_t GetSize() { return 16; }
static constexpr std::string_view GetSchema() {
return "double left;double right";
}
static frc::DifferentialDriveWheelVoltages Unpack(
std::span<const uint8_t, kSize> data);
static void Pack(std::span<uint8_t, kSize> data,
std::span<const uint8_t> data);
static void Pack(std::span<uint8_t> data,
const frc::DifferentialDriveWheelVoltages& value);
};
static_assert(wpi::StructSerializable<frc::DifferentialDriveWheelVoltages>);

View File

@@ -11,12 +11,17 @@
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 constexpr std::string_view GetTypeString() {
return "struct:ElevatorFeedforward";
}
static constexpr size_t GetSize() { return 32; }
static constexpr std::string_view GetSchema() {
return "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,
static frc::ElevatorFeedforward Unpack(std::span<const uint8_t> data);
static void Pack(std::span<uint8_t> data,
const frc::ElevatorFeedforward& value);
};
static_assert(wpi::StructSerializable<frc::ElevatorFeedforward>);

View File

@@ -29,4 +29,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::Pose2d> {
}
};
static_assert(wpi::StructSerializable<frc::Pose2d>);
static_assert(wpi::HasNestedStruct<frc::Pose2d>);

View File

@@ -29,4 +29,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::Pose3d> {
}
};
static_assert(wpi::StructSerializable<frc::Pose3d>);
static_assert(wpi::HasNestedStruct<frc::Pose3d>);

View File

@@ -22,3 +22,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::Quaternion> {
static frc::Quaternion Unpack(std::span<const uint8_t> data);
static void Pack(std::span<uint8_t> data, const frc::Quaternion& value);
};
static_assert(wpi::StructSerializable<frc::Quaternion>);

View File

@@ -20,3 +20,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::Rotation2d> {
static frc::Rotation2d Unpack(std::span<const uint8_t> data);
static void Pack(std::span<uint8_t> data, const frc::Rotation2d& value);
};
static_assert(wpi::StructSerializable<frc::Rotation2d>);

View File

@@ -27,4 +27,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::Rotation3d> {
}
};
static_assert(wpi::StructSerializable<frc::Rotation3d>);
static_assert(wpi::HasNestedStruct<frc::Rotation3d>);

View File

@@ -31,4 +31,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::Transform2d> {
}
};
static_assert(wpi::StructSerializable<frc::Transform2d>);
static_assert(wpi::HasNestedStruct<frc::Transform2d>);

View File

@@ -31,4 +31,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::Transform3d> {
}
};
static_assert(wpi::StructSerializable<frc::Transform3d>);
static_assert(wpi::HasNestedStruct<frc::Transform3d>);

View File

@@ -20,3 +20,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::Translation2d> {
static frc::Translation2d Unpack(std::span<const uint8_t> data);
static void Pack(std::span<uint8_t> data, const frc::Translation2d& value);
};
static_assert(wpi::StructSerializable<frc::Translation2d>);

View File

@@ -22,3 +22,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::Translation3d> {
static frc::Translation3d Unpack(std::span<const uint8_t> data);
static void Pack(std::span<uint8_t> data, const frc::Translation3d& value);
};
static_assert(wpi::StructSerializable<frc::Translation3d>);

View File

@@ -20,3 +20,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::Twist2d> {
static frc::Twist2d Unpack(std::span<const uint8_t> data);
static void Pack(std::span<uint8_t> data, const frc::Twist2d& value);
};
static_assert(wpi::StructSerializable<frc::Twist2d>);

View File

@@ -20,3 +20,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::Twist3d> {
static frc::Twist3d Unpack(std::span<const uint8_t> data);
static void Pack(std::span<uint8_t> data, const frc::Twist3d& value);
};
static_assert(wpi::StructSerializable<frc::Twist3d>);

View File

@@ -22,3 +22,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::ChassisSpeeds> {
static frc::ChassisSpeeds Unpack(std::span<const uint8_t> data);
static void Pack(std::span<uint8_t> data, const frc::ChassisSpeeds& value);
};
static_assert(wpi::StructSerializable<frc::ChassisSpeeds>);

View File

@@ -21,3 +21,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::DifferentialDriveKinematics> {
static void Pack(std::span<uint8_t> data,
const frc::DifferentialDriveKinematics& value);
};
static_assert(wpi::StructSerializable<frc::DifferentialDriveKinematics>);

View File

@@ -24,3 +24,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::DifferentialDriveWheelSpeeds> {
static void Pack(std::span<uint8_t> data,
const frc::DifferentialDriveWheelSpeeds& value);
};
static_assert(wpi::StructSerializable<frc::DifferentialDriveWheelSpeeds>);

View File

@@ -31,4 +31,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::MecanumDriveKinematics> {
}
};
static_assert(wpi::StructSerializable<frc::MecanumDriveKinematics>);
static_assert(wpi::HasNestedStruct<frc::MecanumDriveKinematics>);

View File

@@ -24,3 +24,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::MecanumDriveWheelPositions> {
static void Pack(std::span<uint8_t> data,
const frc::MecanumDriveWheelPositions& value);
};
static_assert(wpi::StructSerializable<frc::MecanumDriveWheelPositions>);

View File

@@ -24,3 +24,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::MecanumDriveWheelSpeeds> {
static void Pack(std::span<uint8_t> data,
const frc::MecanumDriveWheelSpeeds& value);
};
static_assert(wpi::StructSerializable<frc::MecanumDriveWheelSpeeds>);

View File

@@ -30,4 +30,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::SwerveModulePosition> {
}
};
static_assert(wpi::StructSerializable<frc::SwerveModulePosition>);
static_assert(wpi::HasNestedStruct<frc::SwerveModulePosition>);

View File

@@ -30,4 +30,5 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::SwerveModuleState> {
}
};
static_assert(wpi::StructSerializable<frc::SwerveModuleState>);
static_assert(wpi::HasNestedStruct<frc::SwerveModuleState>);

View File

@@ -11,12 +11,16 @@
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 constexpr std::string_view GetTypeString() { return "struct:DCMotor"; }
static constexpr size_t GetSize() { return 40; }
static constexpr std::string_view GetSchema() {
return "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);
static frc::DCMotor Unpack(std::span<const uint8_t> data);
static void Pack(std::span<uint8_t> data, const frc::DCMotor& value);
};
static_assert(wpi::StructSerializable<frc::DCMotor>);