mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
SCRIPT: wpiformat
This commit is contained in:
committed by
Peter Johnson
parent
ae6bdc9d25
commit
2109161534
@@ -60,7 +60,8 @@ Twist2d MecanumDriveKinematics::ToTwist2d(
|
||||
|
||||
Eigen::Vector3d twistVector = m_forwardKinematics.solve(wheelDeltasVector);
|
||||
|
||||
return {wpi::units::meter_t{twistVector(0)}, wpi::units::meter_t{twistVector(1)},
|
||||
return {wpi::units::meter_t{twistVector(0)},
|
||||
wpi::units::meter_t{twistVector(1)},
|
||||
wpi::units::radian_t{twistVector(2)}};
|
||||
}
|
||||
|
||||
@@ -72,7 +73,8 @@ Twist2d MecanumDriveKinematics::ToTwist2d(
|
||||
|
||||
Eigen::Vector3d twistVector = m_forwardKinematics.solve(wheelDeltasVector);
|
||||
|
||||
return {wpi::units::meter_t{twistVector(0)}, wpi::units::meter_t{twistVector(1)},
|
||||
return {wpi::units::meter_t{twistVector(0)},
|
||||
wpi::units::meter_t{twistVector(1)},
|
||||
wpi::units::radian_t{twistVector(2)}};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "wpimath/protobuf/kinematics.npb.h"
|
||||
|
||||
std::optional<wpi::math::ChassisSpeeds> wpi::util::Protobuf<wpi::math::ChassisSpeeds>::Unpack(
|
||||
InputStream& stream) {
|
||||
std::optional<wpi::math::ChassisSpeeds>
|
||||
wpi::util::Protobuf<wpi::math::ChassisSpeeds>::Unpack(InputStream& stream) {
|
||||
wpi_proto_ProtobufChassisSpeeds msg;
|
||||
if (!stream.Decode(msg)) {
|
||||
return {};
|
||||
@@ -20,8 +20,8 @@ std::optional<wpi::math::ChassisSpeeds> wpi::util::Protobuf<wpi::math::ChassisSp
|
||||
};
|
||||
}
|
||||
|
||||
bool wpi::util::Protobuf<wpi::math::ChassisSpeeds>::Pack(OutputStream& stream,
|
||||
const wpi::math::ChassisSpeeds& value) {
|
||||
bool wpi::util::Protobuf<wpi::math::ChassisSpeeds>::Pack(
|
||||
OutputStream& stream, const wpi::math::ChassisSpeeds& value) {
|
||||
wpi_proto_ProtobufChassisSpeeds msg{
|
||||
.vx = value.vx.value(),
|
||||
.vy = value.vy.value(),
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "wpimath/protobuf/kinematics.npb.h"
|
||||
|
||||
std::optional<wpi::math::DifferentialDriveKinematics>
|
||||
wpi::util::Protobuf<wpi::math::DifferentialDriveKinematics>::Unpack(InputStream& stream) {
|
||||
std::optional<wpi::math::DifferentialDriveKinematics> wpi::util::Protobuf<
|
||||
wpi::math::DifferentialDriveKinematics>::Unpack(InputStream& stream) {
|
||||
wpi_proto_ProtobufDifferentialDriveKinematics msg;
|
||||
if (!stream.Decode(msg)) {
|
||||
return {};
|
||||
|
||||
@@ -20,7 +20,8 @@ std::optional<wpi::math::DifferentialDriveWheelPositions> wpi::util::Protobuf<
|
||||
}
|
||||
|
||||
bool wpi::util::Protobuf<wpi::math::DifferentialDriveWheelPositions>::Pack(
|
||||
OutputStream& stream, const wpi::math::DifferentialDriveWheelPositions& value) {
|
||||
OutputStream& stream,
|
||||
const wpi::math::DifferentialDriveWheelPositions& value) {
|
||||
wpi_proto_ProtobufDifferentialDriveWheelPositions msg{
|
||||
.left = value.left.value(),
|
||||
.right = value.right.value(),
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "wpimath/protobuf/kinematics.npb.h"
|
||||
|
||||
std::optional<wpi::math::DifferentialDriveWheelSpeeds>
|
||||
wpi::util::Protobuf<wpi::math::DifferentialDriveWheelSpeeds>::Unpack(InputStream& stream) {
|
||||
std::optional<wpi::math::DifferentialDriveWheelSpeeds> wpi::util::Protobuf<
|
||||
wpi::math::DifferentialDriveWheelSpeeds>::Unpack(InputStream& stream) {
|
||||
wpi_proto_ProtobufDifferentialDriveWheelSpeeds msg;
|
||||
if (!stream.Decode(msg)) {
|
||||
return {};
|
||||
@@ -20,7 +20,8 @@ wpi::util::Protobuf<wpi::math::DifferentialDriveWheelSpeeds>::Unpack(InputStream
|
||||
}
|
||||
|
||||
bool wpi::util::Protobuf<wpi::math::DifferentialDriveWheelSpeeds>::Pack(
|
||||
OutputStream& stream, const wpi::math::DifferentialDriveWheelSpeeds& value) {
|
||||
OutputStream& stream,
|
||||
const wpi::math::DifferentialDriveWheelSpeeds& value) {
|
||||
wpi_proto_ProtobufDifferentialDriveWheelSpeeds msg{
|
||||
.left = value.left.value(),
|
||||
.right = value.right.value(),
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "wpi/util/protobuf/ProtobufCallbacks.hpp"
|
||||
#include "wpimath/protobuf/kinematics.npb.h"
|
||||
|
||||
std::optional<wpi::math::MecanumDriveKinematics>
|
||||
wpi::util::Protobuf<wpi::math::MecanumDriveKinematics>::Unpack(InputStream& stream) {
|
||||
std::optional<wpi::math::MecanumDriveKinematics> wpi::util::Protobuf<
|
||||
wpi::math::MecanumDriveKinematics>::Unpack(InputStream& stream) {
|
||||
wpi::util::UnpackCallback<wpi::math::Translation2d> frontLeft;
|
||||
wpi::util::UnpackCallback<wpi::math::Translation2d> frontRight;
|
||||
wpi::util::UnpackCallback<wpi::math::Translation2d> rearLeft;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "wpimath/protobuf/kinematics.npb.h"
|
||||
|
||||
std::optional<wpi::math::MecanumDriveWheelPositions>
|
||||
wpi::util::Protobuf<wpi::math::MecanumDriveWheelPositions>::Unpack(InputStream& stream) {
|
||||
std::optional<wpi::math::MecanumDriveWheelPositions> wpi::util::Protobuf<
|
||||
wpi::math::MecanumDriveWheelPositions>::Unpack(InputStream& stream) {
|
||||
wpi_proto_ProtobufMecanumDriveWheelPositions msg;
|
||||
if (!stream.Decode(msg)) {
|
||||
return {};
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "wpimath/protobuf/kinematics.npb.h"
|
||||
|
||||
std::optional<wpi::math::MecanumDriveWheelSpeeds>
|
||||
wpi::util::Protobuf<wpi::math::MecanumDriveWheelSpeeds>::Unpack(InputStream& stream) {
|
||||
std::optional<wpi::math::MecanumDriveWheelSpeeds> wpi::util::Protobuf<
|
||||
wpi::math::MecanumDriveWheelSpeeds>::Unpack(InputStream& stream) {
|
||||
wpi_proto_ProtobufMecanumDriveWheelSpeeds msg;
|
||||
if (!stream.Decode(msg)) {
|
||||
return {};
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "wpi/util/protobuf/ProtobufCallbacks.hpp"
|
||||
#include "wpimath/protobuf/kinematics.npb.h"
|
||||
|
||||
std::optional<wpi::math::SwerveModulePosition>
|
||||
wpi::util::Protobuf<wpi::math::SwerveModulePosition>::Unpack(InputStream& stream) {
|
||||
std::optional<wpi::math::SwerveModulePosition> wpi::util::Protobuf<
|
||||
wpi::math::SwerveModulePosition>::Unpack(InputStream& stream) {
|
||||
wpi::util::UnpackCallback<wpi::math::Rotation2d> angle;
|
||||
wpi_proto_ProtobufSwerveModulePosition msg{
|
||||
.distance = 0,
|
||||
|
||||
@@ -14,9 +14,12 @@ using StructType = wpi::util::Struct<wpi::math::ChassisSpeeds>;
|
||||
|
||||
wpi::math::ChassisSpeeds StructType::Unpack(std::span<const uint8_t> data) {
|
||||
return wpi::math::ChassisSpeeds{
|
||||
wpi::units::meters_per_second_t{wpi::util::UnpackStruct<double, kVxOff>(data)},
|
||||
wpi::units::meters_per_second_t{wpi::util::UnpackStruct<double, kVyOff>(data)},
|
||||
wpi::units::radians_per_second_t{wpi::util::UnpackStruct<double, kOmegaOff>(data)},
|
||||
wpi::units::meters_per_second_t{
|
||||
wpi::util::UnpackStruct<double, kVxOff>(data)},
|
||||
wpi::units::meters_per_second_t{
|
||||
wpi::util::UnpackStruct<double, kVyOff>(data)},
|
||||
wpi::units::radians_per_second_t{
|
||||
wpi::util::UnpackStruct<double, kOmegaOff>(data)},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ using StructType = wpi::util::Struct<wpi::math::DifferentialDriveKinematics>;
|
||||
wpi::math::DifferentialDriveKinematics StructType::Unpack(
|
||||
std::span<const uint8_t> data) {
|
||||
return wpi::math::DifferentialDriveKinematics{
|
||||
wpi::units::meter_t{wpi::util::UnpackStruct<double, kTrackwidthOff>(data)},
|
||||
wpi::units::meter_t{
|
||||
wpi::util::UnpackStruct<double, kTrackwidthOff>(data)},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ constexpr size_t kLeftOff = 0;
|
||||
constexpr size_t kRightOff = kLeftOff + 8;
|
||||
} // namespace
|
||||
|
||||
using StructType = wpi::util::Struct<wpi::math::DifferentialDriveWheelPositions>;
|
||||
using StructType =
|
||||
wpi::util::Struct<wpi::math::DifferentialDriveWheelPositions>;
|
||||
|
||||
wpi::math::DifferentialDriveWheelPositions StructType::Unpack(
|
||||
std::span<const uint8_t> data) {
|
||||
|
||||
@@ -14,8 +14,10 @@ using StructType = wpi::util::Struct<wpi::math::DifferentialDriveWheelSpeeds>;
|
||||
wpi::math::DifferentialDriveWheelSpeeds StructType::Unpack(
|
||||
std::span<const uint8_t> data) {
|
||||
return wpi::math::DifferentialDriveWheelSpeeds{
|
||||
wpi::units::meters_per_second_t{wpi::util::UnpackStruct<double, kLeftOff>(data)},
|
||||
wpi::units::meters_per_second_t{wpi::util::UnpackStruct<double, kRightOff>(data)},
|
||||
wpi::units::meters_per_second_t{
|
||||
wpi::util::UnpackStruct<double, kLeftOff>(data)},
|
||||
wpi::units::meters_per_second_t{
|
||||
wpi::util::UnpackStruct<double, kRightOff>(data)},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ constexpr size_t kRearRightOff =
|
||||
|
||||
using StructType = wpi::util::Struct<wpi::math::MecanumDriveKinematics>;
|
||||
|
||||
wpi::math::MecanumDriveKinematics StructType::Unpack(std::span<const uint8_t> data) {
|
||||
wpi::math::MecanumDriveKinematics StructType::Unpack(
|
||||
std::span<const uint8_t> data) {
|
||||
return wpi::math::MecanumDriveKinematics{
|
||||
wpi::util::UnpackStruct<wpi::math::Translation2d, kFrontLeftOff>(data),
|
||||
wpi::util::UnpackStruct<wpi::math::Translation2d, kFrontRightOff>(data),
|
||||
|
||||
@@ -17,7 +17,8 @@ wpi::math::MecanumDriveWheelPositions StructType::Unpack(
|
||||
std::span<const uint8_t> data) {
|
||||
return wpi::math::MecanumDriveWheelPositions{
|
||||
wpi::units::meter_t{wpi::util::UnpackStruct<double, kFrontLeftOff>(data)},
|
||||
wpi::units::meter_t{wpi::util::UnpackStruct<double, kFrontRightOff>(data)},
|
||||
wpi::units::meter_t{
|
||||
wpi::util::UnpackStruct<double, kFrontRightOff>(data)},
|
||||
wpi::units::meter_t{wpi::util::UnpackStruct<double, kRearLeftOff>(data)},
|
||||
wpi::units::meter_t{wpi::util::UnpackStruct<double, kRearRightOff>(data)},
|
||||
};
|
||||
|
||||
@@ -13,13 +13,15 @@ constexpr size_t kRearRightOff = kRearLeftOff + 8;
|
||||
|
||||
using StructType = wpi::util::Struct<wpi::math::MecanumDriveWheelSpeeds>;
|
||||
|
||||
wpi::math::MecanumDriveWheelSpeeds StructType::Unpack(std::span<const uint8_t> data) {
|
||||
wpi::math::MecanumDriveWheelSpeeds StructType::Unpack(
|
||||
std::span<const uint8_t> data) {
|
||||
return wpi::math::MecanumDriveWheelSpeeds{
|
||||
wpi::units::meters_per_second_t{
|
||||
wpi::util::UnpackStruct<double, kFrontLeftOff>(data)},
|
||||
wpi::units::meters_per_second_t{
|
||||
wpi::util::UnpackStruct<double, kFrontRightOff>(data)},
|
||||
wpi::units::meters_per_second_t{wpi::util::UnpackStruct<double, kRearLeftOff>(data)},
|
||||
wpi::units::meters_per_second_t{
|
||||
wpi::util::UnpackStruct<double, kRearLeftOff>(data)},
|
||||
wpi::units::meters_per_second_t{
|
||||
wpi::util::UnpackStruct<double, kRearRightOff>(data)},
|
||||
};
|
||||
|
||||
@@ -11,7 +11,8 @@ constexpr size_t kAngleOff = kDistanceOff + 8;
|
||||
|
||||
using StructType = wpi::util::Struct<wpi::math::SwerveModulePosition>;
|
||||
|
||||
wpi::math::SwerveModulePosition StructType::Unpack(std::span<const uint8_t> data) {
|
||||
wpi::math::SwerveModulePosition StructType::Unpack(
|
||||
std::span<const uint8_t> data) {
|
||||
return wpi::math::SwerveModulePosition{
|
||||
wpi::units::meter_t{wpi::util::UnpackStruct<double, kDistanceOff>(data)},
|
||||
wpi::util::UnpackStruct<wpi::math::Rotation2d, kAngleOff>(data),
|
||||
|
||||
@@ -13,7 +13,8 @@ using StructType = wpi::util::Struct<wpi::math::SwerveModuleState>;
|
||||
|
||||
wpi::math::SwerveModuleState StructType::Unpack(std::span<const uint8_t> data) {
|
||||
return wpi::math::SwerveModuleState{
|
||||
wpi::units::meters_per_second_t{wpi::util::UnpackStruct<double, kSpeedOff>(data)},
|
||||
wpi::units::meters_per_second_t{
|
||||
wpi::util::UnpackStruct<double, kSpeedOff>(data)},
|
||||
wpi::util::UnpackStruct<wpi::math::Rotation2d, kAngleOff>(data),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user