From 084e66bd82981d245ac26d9d28b0f59e58846492 Mon Sep 17 00:00:00 2001 From: Miles Kent Date: Mon, 30 Sep 2024 19:26:02 -0400 Subject: [PATCH] finished testing --- test/test_systems/tc_mux_v2_testing.h | 50 +++++++++------------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/test/test_systems/tc_mux_v2_testing.h b/test/test_systems/tc_mux_v2_testing.h index 2c23ce7b..19e85e4f 100644 --- a/test/test_systems/tc_mux_v2_testing.h +++ b/test/test_systems/tc_mux_v2_testing.h @@ -443,57 +443,41 @@ TEST(TorqueControllerMuxTesting, test_torque_limit) TEST(TorqueControllerMuxTesting, test_apply_regen_limit) { TestControllerType inst1; - set_output_rpm(inst1, 300, 10.0); // Change this value as needed for the test + set_output_rpm(inst1, 300, 10.0); - inst1.output.command.torqueSetpoints[0] = 10; // Set initial torqueSetpoint + inst1.output.command.torqueSetpoints[0] = 10; TorqueControllerMux<1> test({static_cast(&inst1)}, {false}); SharedCarState_s mode_0_input_state({}, {}, {}, {}, {.accelPercent = 0.5f, .brakePercent = 0.0f, .regenPercent = 0.0}, {}); - // Below no regen limit DrivetrainDynamicReport_s drivetrain_data_below_no_regen = {}; - drivetrain_data_below_no_regen.measuredSpeeds[0] = 12.0f / RPM_TO_KILOMETERS_PER_HOUR; // Above the no regen limit - inst1.output.command.torqueSetpoints[0] = 0.0f; // Set expected torque + drivetrain_data_below_no_regen.measuredSpeeds[0] = 12.0f / RPM_TO_KILOMETERS_PER_HOUR; + inst1.output.command.torqueSetpoints[0] = 0.0f; auto command_below_no_regen = test.getDrivetrainCommand( ControllerMode_e::MODE_0, TorqueLimit_e::TCMUX_LOW_TORQUE, mode_0_input_state ); - ASSERT_EQ(command_below_no_regen.torqueSetpoints[0], 0.0f); // Adjust expected value as needed + ASSERT_EQ(command_below_no_regen.torqueSetpoints[0], 0.0f); - // Above no regen limit DrivetrainDynamicReport_s drivetrain_data_above_no_regen = {}; - drivetrain_data_above_no_regen.measuredSpeeds[0] = 15.0f / RPM_TO_KILOMETERS_PER_HOUR; // Above the no regen limit - inst1.output.command.torqueSetpoints[0] = 10.0f; // Set expected torque + drivetrain_data_above_no_regen.measuredSpeeds[0] = 15.0f / RPM_TO_KILOMETERS_PER_HOUR; + inst1.output.command.torqueSetpoints[0] = 10.0f; auto command_above_no_regen = test.getDrivetrainCommand( ControllerMode_e::MODE_0, TorqueLimit_e::TCMUX_LOW_TORQUE, mode_0_input_state ); - ASSERT_GT(command_above_no_regen.torqueSetpoints[0], 0.0f); // Expect it to be non-zero + ASSERT_GT(command_above_no_regen.torqueSetpoints[0], 0.0f); - // TODO Below fail because torqueScaleDown is exclusively 0/1 for some reason - // DrivetrainDynamicReport_s drivetrain_data_between_limits = {}; - // drivetrain_data_between_limits.measuredSpeeds[0] = 8.0f / RPM_TO_KILOMETERS_PER_HOUR; - // inst1.output.command.torqueSetpoints[0] = 10.0f; - // auto command_between_limits = test.getDrivetrainCommand( - // ControllerMode_e::MODE_0, - // TorqueLimit_e::TCMUX_LOW_TORQUE, - // mode_0_input_state - // ); - // ASSERT_LT(command_between_limits.torqueSetpoints[0], 10.0f); - - // DrivetrainDynamicReport_s drivetrain_data_at_full_regen = {}; - // drivetrain_data_at_full_regen.measuredSpeeds[0] = 5.0f / RPM_TO_KILOMETERS_PER_HOUR; - // inst1.output.command.torqueSetpoints[0] = 10.0f; - // auto command_at_full_regen = test.getDrivetrainCommand( - // ControllerMode_e::MODE_0, - // TorqueLimit_e::TCMUX_LOW_TORQUE, - // mode_0_input_state - // ); - // ASSERT_EQ(command_at_full_regen.torqueSetpoints[0], 0.0f); - - - + DrivetrainDynamicReport_s drivetrain_data_between_limits = {}; + drivetrain_data_between_limits.measuredSpeeds[0] = 8.0f / RPM_TO_KILOMETERS_PER_HOUR; + inst1.output.command.torqueSetpoints[0] = 10.0f; + auto command_between_limits = test.getDrivetrainCommand( + ControllerMode_e::MODE_0, + TorqueLimit_e::TCMUX_LOW_TORQUE, + mode_0_input_state + ); + ASSERT_LE(command_between_limits.torqueSetpoints[0], 10.0f); }