Skip to content

Commit

Permalink
updating pedals systems test, version of shared firmware interfaces a…
Browse files Browse the repository at this point in the history
…nd to the latest pedals parameters
  • Loading branch information
RCMast3r committed Sep 13, 2024
1 parent df03ce2 commit 3bb36b4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
16 changes: 8 additions & 8 deletions include/MCU_rev15_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ const unsigned long TELEM_CAN_BAUDRATE = 500000;
// All of these values are the PEDAL min/max
// the sensor min/max that trip implaus are calculated
// in the PedalsSystem constructor
const int ACCEL1_PEDAL_MAX = 3409; // 3330
const int ACCEL2_PEDAL_MAX = 259; // 388
const int ACCEL1_PEDAL_MAX = 3491;
const int ACCEL2_PEDAL_MAX = 189;

const int ACCEL1_PEDAL_MIN = 2129;
const int ACCEL2_PEDAL_MIN = 1517;
const int ACCEL1_PEDAL_MIN = 2244;
const int ACCEL2_PEDAL_MIN = 1405;

const int BRAKE1_PEDAL_MAX = 1945; // 2200;
const int BRAKE2_PEDAL_MAX = 1742; // 2200;
const int BRAKE1_PEDAL_MAX = 1945;
const int BRAKE2_PEDAL_MAX = 1742;

const int BRAKE1_PEDAL_MIN = 1230; // 785; // 1230 to 1750
const int BRAKE2_PEDAL_MIN = 2437; // 785; // 2450 to 1930
const int BRAKE1_PEDAL_MIN = 1192;
const int BRAKE2_PEDAL_MIN = 2476;

const int ACCEL1_PEDAL_OOR_MIN = 90;
const int ACCEL2_PEDAL_OOR_MIN = 90;
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extra_scripts = pre:extra_script.py
lib_deps =
${common.lib_deps_shared}
SPI
https://github.com/hytech-racing/shared_firmware_interfaces.git#feature/thermistor-template
https://github.com/hytech-racing/shared_firmware_interfaces.git#shared_types
https://github.com/tonton81/FlexCAN_T4
https://github.com/ssilverman/QNEthernet#v0.26.0
https://github.com/RCMast3r/hytech_can#testing_new_inv_ids
Expand Down
29 changes: 18 additions & 11 deletions test/test_systems/pedals_system_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,15 @@ TEST(PedalsSystemTesting, test_accel_and_brake_pressed_at_same_time_and_activati
TEST(PedalsSystemTesting, test_implausibility_duration)
{
AnalogConversion_s test_accel1_val = {2583, 0.37, AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};
AnalogConversion_s test_accel2_val = {1068, 0.37, AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};
AnalogConversion_s test_brake_val = {1510, get_pedal_conversion_val(BRAKE1_PEDAL_MIN, BRAKE1_PEDAL_MAX, 1510), AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};
AnalogConversion_s test_accel2_val = {1068, 1.00, AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};
AnalogConversion_s test_brake_val = {1510, get_pedal_conversion_val(BRAKE1_PEDAL_MIN, BRAKE1_PEDAL_MAX, BRAKE1_PEDAL_MAX), AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};

PedalsSystem pedals(get_real_accel_pedal_params(), get_real_brake_pedal_params());

auto data = pedals.evaluate_pedals(test_accel1_val, test_accel1_val, test_brake_val, test_brake_val, 1000);

std::cout << data.accelPressed <<std::endl;
std::cout << data.brakePressed <<std::endl;
EXPECT_TRUE(data.brakeAndAccelPressedImplausibility);
EXPECT_TRUE(data.brakePressed);
EXPECT_FALSE(data.implausibilityExceededMaxDuration);
Expand All @@ -301,16 +304,19 @@ TEST(PedalsSystemTesting, implausibility_latching_until_accel_released_double_br
{
AnalogConversion_s test_accel1_val = {2583, 0.37, AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};
AnalogConversion_s test_accel2_val = {1068, 0.37, AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};
AnalogConversion_s test_brake_val = {1510, get_pedal_conversion_val(BRAKE1_PEDAL_MIN, BRAKE1_PEDAL_MAX, 1510), AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};
AnalogConversion_s test_brake1_val = {((BRAKE1_PEDAL_MAX - BRAKE1_PEDAL_MIN) /2), get_pedal_conversion_val(BRAKE1_PEDAL_MIN, BRAKE1_PEDAL_MAX, ((BRAKE1_PEDAL_MAX- BRAKE1_PEDAL_MIN) /2)), AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};
AnalogConversion_s test_brake2_val = {((BRAKE1_PEDAL_MAX - BRAKE1_PEDAL_MIN) /2), get_pedal_conversion_val(BRAKE2_PEDAL_MIN, BRAKE2_PEDAL_MAX, ((BRAKE2_PEDAL_MAX- BRAKE2_PEDAL_MIN) /2)), AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};

PedalsSystem pedals(get_real_accel_pedal_params(), get_real_brake_pedal_params());

// should stay im
EXPECT_TRUE(get_result_of_double_brake_test(pedals, test_accel1_val, test_accel2_val, test_brake_val, test_brake_val));
EXPECT_TRUE(get_result_of_double_brake_test(pedals, test_accel1_val, test_accel2_val, test_brake1_val, test_brake2_val));

test_brake_val.raw = 870;
test_brake_val.conversion = 0.0;
auto data = pedals.evaluate_pedals(test_accel1_val, test_accel2_val, test_brake_val, test_brake_val, 1600);
test_brake1_val.raw = BRAKE1_PEDAL_MIN;
test_brake1_val.conversion = 0.0;
test_brake2_val.raw = BRAKE2_PEDAL_MIN;
test_brake2_val.conversion = 0.0;
auto data = pedals.evaluate_pedals(test_accel1_val, test_accel2_val, test_brake1_val, test_brake2_val, 1600);
// this should still be implause since accel is still pressed
EXPECT_TRUE(data.implausibilityExceededMaxDuration);

Expand All @@ -319,9 +325,10 @@ TEST(PedalsSystemTesting, implausibility_latching_until_accel_released_double_br
test_accel2_val.raw = ACCEL2_PEDAL_MIN;
test_accel1_val.conversion = 0.0;
test_accel2_val.conversion = 0.0;
data = pedals.evaluate_pedals(test_accel1_val, test_accel2_val, test_brake_val, test_brake_val, 1650);
data = pedals.evaluate_pedals(test_accel1_val, test_accel2_val, test_brake1_val, test_brake2_val, 1650);

EXPECT_FALSE(data.implausibilityExceededMaxDuration);
std::cout << data.accelImplausible << " " << data.brakeImplausible << " "<<std::endl;
EXPECT_FALSE(data.implausibilityExceededMaxDuration);
}

TEST(PedalsSystemTesting, implausibility_latching_until_accel_released_single_brake)
Expand All @@ -331,14 +338,14 @@ TEST(PedalsSystemTesting, implausibility_latching_until_accel_released_single_br
////////////////////
AnalogConversion_s test_accel1_val = {2583, 0.37, AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};
AnalogConversion_s test_accel2_val = {1068, 0.37, AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};
AnalogConversion_s test_brake_val = {1510, get_pedal_conversion_val(BRAKE1_PEDAL_MIN, BRAKE1_PEDAL_MAX, 1510), AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};
AnalogConversion_s test_brake_val = {((BRAKE1_PEDAL_MAX - BRAKE1_PEDAL_MIN) /2), get_pedal_conversion_val(BRAKE1_PEDAL_MIN, BRAKE1_PEDAL_MAX, ((BRAKE1_PEDAL_MAX - BRAKE1_PEDAL_MIN) /2)), AnalogSensorStatus_e::ANALOG_SENSOR_GOOD};

PedalsSystem pedals2(get_real_accel_pedal_params(), get_real_brake_pedal_params());

// first we fail
EXPECT_TRUE(get_result_of_single_brake_test(pedals2, test_accel1_val, test_accel2_val, test_brake_val));

test_brake_val.raw = 870;
test_brake_val.raw = BRAKE1_PEDAL_MIN;
test_brake_val.conversion = 0.0;
auto data2 = pedals2.evaluate_pedals(test_accel1_val, test_accel2_val, test_brake_val, 1600);
// this should still be implause since accel is still pressed
Expand Down

0 comments on commit 3bb36b4

Please sign in to comment.