2024-07-29 07:55:44 -07:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
|
|
#include "frc/controller/proto/DifferentialDriveFeedforwardProto.h"
|
|
|
|
|
|
2024-11-07 22:42:50 -08:00
|
|
|
#include "wpimath/protobuf/controller.npb.h"
|
2024-07-29 07:55:44 -07:00
|
|
|
|
2024-11-07 22:42:50 -08:00
|
|
|
std::optional<frc::DifferentialDriveFeedforward>
|
|
|
|
|
wpi::Protobuf<frc::DifferentialDriveFeedforward>::Unpack(InputStream& stream) {
|
|
|
|
|
wpi_proto_ProtobufDifferentialDriveFeedforward msg;
|
|
|
|
|
if (!stream.Decode(msg)) {
|
|
|
|
|
return {};
|
|
|
|
|
}
|
2024-07-29 07:55:44 -07:00
|
|
|
|
2024-11-07 22:42:50 -08:00
|
|
|
return frc::DifferentialDriveFeedforward{
|
|
|
|
|
decltype(1_V / 1_mps){msg.kv_linear},
|
|
|
|
|
decltype(1_V / 1_mps_sq){msg.ka_linear},
|
|
|
|
|
decltype(1_V / 1_mps){msg.kv_angular},
|
|
|
|
|
decltype(1_V / 1_mps_sq){msg.ka_angular},
|
|
|
|
|
};
|
2024-07-29 07:55:44 -07:00
|
|
|
}
|
|
|
|
|
|
2024-11-07 22:42:50 -08:00
|
|
|
bool wpi::Protobuf<frc::DifferentialDriveFeedforward>::Pack(
|
|
|
|
|
OutputStream& stream, const frc::DifferentialDriveFeedforward& value) {
|
|
|
|
|
wpi_proto_ProtobufDifferentialDriveFeedforward msg{
|
|
|
|
|
.kv_linear = value.m_kVLinear.value(),
|
|
|
|
|
.ka_linear = value.m_kALinear.value(),
|
|
|
|
|
.kv_angular = value.m_kVAngular.value(),
|
|
|
|
|
.ka_angular = value.m_kAAngular.value(),
|
|
|
|
|
};
|
|
|
|
|
return stream.Encode(msg);
|
2024-07-29 07:55:44 -07:00
|
|
|
}
|