mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
[wpimath] Add remaining struct and protobuf implementations (#5953)
This commit is contained in:
@@ -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 "../../ProtoTestBase.h"
|
||||
#include "frc/controller/DifferentialDriveFeedforward.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
struct DifferentialDriveFeedforwardProtoTestData {
|
||||
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, ProtoTest,
|
||||
DifferentialDriveFeedforwardProtoTestData);
|
||||
@@ -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 "../../ProtoTestBase.h"
|
||||
#include "frc/controller/SimpleMotorFeedforward.h"
|
||||
#include "frc/controller/proto/SimpleMotorFeedforwardProto.h"
|
||||
#include "units/acceleration.h"
|
||||
#include "units/velocity.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
struct SimpleMotorFeedforwardProtoTestData {
|
||||
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, ProtoTest,
|
||||
SimpleMotorFeedforwardProtoTestData);
|
||||
Reference in New Issue
Block a user