[wpimath] Add remaining struct and protobuf implementations (#5953)

This commit is contained in:
Joseph Eng
2024-07-29 07:55:44 -07:00
committed by GitHub
parent 3e1e3fb4ca
commit 073192d513
112 changed files with 3989 additions and 45 deletions

View File

@@ -0,0 +1,28 @@
// 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 <gtest/gtest.h>
#include "../../StructTestBase.h"
#include "frc/controller/DifferentialDriveFeedforward.h"
using namespace frc;
struct DifferentialDriveFeedforwardStructTestData {
using Type = DifferentialDriveFeedforward;
inline static const Type kTestData{
decltype(1_V / 1_mps){0.174}, decltype(1_V / 1_mps_sq){0.229},
decltype(1_V / 1_mps){4.4}, decltype(1_V / 1_mps_sq){4.5}};
static void CheckEq(const Type& testData, const Type& data) {
EXPECT_EQ(testData.m_kVLinear.value(), data.m_kVLinear.value());
EXPECT_EQ(testData.m_kALinear.value(), data.m_kALinear.value());
EXPECT_EQ(testData.m_kVAngular.value(), data.m_kVAngular.value());
EXPECT_EQ(testData.m_kAAngular.value(), data.m_kAAngular.value());
}
};
INSTANTIATE_TYPED_TEST_SUITE_P(DifferentialDriveFeedforward, StructTest,
DifferentialDriveFeedforwardStructTestData);

View File

@@ -0,0 +1,31 @@
// 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 <gtest/gtest.h>
#include "../../StructTestBase.h"
#include "frc/controller/SimpleMotorFeedforward.h"
#include "frc/controller/struct/SimpleMotorFeedforwardStruct.h"
#include "units/acceleration.h"
#include "units/velocity.h"
using namespace frc;
struct SimpleMotorFeedforwardStructTestData {
using Type = SimpleMotorFeedforward<units::meters>;
inline static const Type kTestData = {units::volt_t{0.4},
units::volt_t{4.0} / 1_mps,
units::volt_t{0.7} / 1_mps_sq, 25_ms};
static void CheckEq(const Type& testData, const Type& data) {
EXPECT_EQ(testData.GetKs().value(), data.GetKs().value());
EXPECT_EQ(testData.GetKv().value(), data.GetKv().value());
EXPECT_EQ(testData.GetKa().value(), data.GetKa().value());
EXPECT_EQ(testData.GetDt().value(), data.GetDt().value());
}
};
INSTANTIATE_TYPED_TEST_SUITE_P(SimpleMotorFeedforwardMeters, StructTest,
SimpleMotorFeedforwardStructTestData);