Skip to content

Commit

Permalink
adding todos for pedal system testing
Browse files Browse the repository at this point in the history
  • Loading branch information
RCMast3r committed Feb 7, 2024
1 parent 7ba8ce0 commit 0176440
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
5 changes: 2 additions & 3 deletions lib/systems/src/PedalsSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PedalsSystemData_s PedalsSystem::evaluate_pedals(const AnalogConversion_s &accel
{
implausibilityStartTime_ = 0;
}

out.accelPercent = (accel1.conversion + accel2.conversion) / 2.0;
out.brakePercent = (brake1.conversion + brake2.conversion) / 2.0;
out.brakePressed = pedal_is_active_(brake1.conversion, brake2.conversion, brakeParams_.activation_percentage);
Expand Down Expand Up @@ -84,8 +84,7 @@ bool PedalsSystem::evaluate_pedal_implausibilities_(const AnalogConversion_s &pe
bool PedalsSystem::evaluate_brake_and_accel_pressed_(const AnalogConversion_s &accelPedalData1,
const AnalogConversion_s &accelPedalData2,
const AnalogConversion_s &brakePedalData1,
const AnalogConversion_s &brakePedalData2
)
const AnalogConversion_s &brakePedalData2)
{

bool accel_pressed = pedal_is_active_(accelPedalData1.conversion, accelPedalData2.conversion, accelParams_.activation_percentage); // .1
Expand Down
47 changes: 28 additions & 19 deletions test/pedals_system_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,40 @@ author: Lucas Plant
#include <array>


// struct PedalIsActiveTestCase
// {
// // defines input and output params
struct PedalIsActiveTestCase
{
// defines input and output params

// // input params
// PedalsDriverInterface pedalsinput;
// input params
PedalsDriverInterface pedalsinput;

// // expected output
// bool expect_active;
// };
// expected output
bool expect_active;
};


// TODO accel and brake implausibility for greater than max or less than min

// TEST(PedalsSystemTesting, test_pedal_is_active)
// {
// PedalsParams params_for_test = {1, 1, 10, 10, 1, 1, 9, 9};
// PedalsSystem pedals_system(params_for_test, params_for_test);
// std::array<PedalIsActiveTestCase, 1> test_cases{{{{0, 0, 3, 3}, true}}};
// TODO accel and brake implausibility for values not within acceptable percentage differences

// for (const auto &test_case : test_cases)
// {
// auto out = pedals_system.mech_brake_active(test_case.pedalsinput);
// EXPECT_EQ(test_case.expect_active, out);
// }
// }
// TODO test accel and brake implausibility for both pressed at same time

// TODO test accel and brake activation

// TODO test implausibility duration alert

TEST(PedalsSystemTesting, test_pedal_is_active)
{
PedalsParams params_for_test = {1, 1, 10, 10, 1, 1, 9, 9};
PedalsSystem pedals_system(params_for_test, params_for_test);
std::array<PedalIsActiveTestCase, 1> test_cases{{{{0, 0, 3, 3}, true}}};

for (const auto &test_case : test_cases)
{
auto out = pedals_system.mech_brake_active(test_case.pedalsinput);
EXPECT_EQ(test_case.expect_active, out);
}
}



Expand Down

0 comments on commit 0176440

Please sign in to comment.