Skip to content

Commit

Permalink
resolving #69 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
RCMast3r committed Apr 11, 2024
1 parent adb6d1c commit bb794f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/systems/src/PedalsSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ PedalsSystemData_s PedalsSystem::evaluate_pedals(const AnalogConversion_s &accel
out.accelPercent = ((accel1.conversion + accel2.conversion) / 2.0);
out.accelPercent = remove_deadzone_(out.accelPercent, accelParams_.deadzone_margin);
out.accelPercent = std::max(out.accelPercent, 0.0f);
out.accelPressed = pedal_is_active_(accel1.conversion, accel2.conversion, accelParams_, false);
out.accelImplausible = evaluate_pedal_implausibilities_(accel1, accel2, accelParams_, 0.1);
out.brakeImplausible = evaluate_pedal_implausibilities_(brake, brakeParams_);
out.brakeAndAccelPressedImplausibility = evaluate_brake_and_accel_pressed_(accel1, accel2, brake);
Expand All @@ -49,7 +50,6 @@ PedalsSystemData_s PedalsSystem::evaluate_pedals(const AnalogConversion_s &accel

out.mechBrakeActive = out.brakePercent >= brakeParams_.mechanical_activation_percentage;
out.regenPercent = std::max(std::min(out.brakePercent / brakeParams_.mechanical_activation_percentage, 1.0f), 0.0f);
out.brakePressed = out.brakePercent > brakeParams_.activation_percentage;


out.implausibilityExceededMaxDuration = max_duration_of_implausibility_exceeded_(curr_time);
Expand Down
14 changes: 14 additions & 0 deletions test/test_systems/pedals_system_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,19 @@ TEST(PedalsSystemTesting, check_accel_never_negative_double)

}

TEST(PedalsSystemTesting, check_accel_pressed)
{
AnalogConversion_s test_pedal_good_val_accel = {1200, 0.2, AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};
AnalogConversion_s test_pedal_good_val_brake = {1001, 0.0, AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};

auto params = gen_positive_slope_only_params();
PedalsSystem pedals(params, params);
PedalsSystem pedals_single(params, params);
auto data_double = pedals.evaluate_pedals(test_pedal_good_val_accel, test_pedal_good_val_accel, test_pedal_good_val_brake, test_pedal_good_val_brake, 1300);
EXPECT_TRUE(data_double.accelPressed);
auto data_single = pedals_single.evaluate_pedals(test_pedal_good_val_accel, test_pedal_good_val_accel, test_pedal_good_val_brake, 1300);
EXPECT_TRUE(data_single.accelPressed);
}


#endif /* PEDALS_SYSTEM_TEST */

0 comments on commit bb794f2

Please sign in to comment.