mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-31 04:41:35 +08:00
mavsdk_tests: ensure motor is stopped for motor failure test
This commit is contained in:
@@ -78,3 +78,23 @@ void AutopilotTesterFailure::inject_failure(mavsdk::Failure::FailureUnit failure
|
|||||||
{
|
{
|
||||||
CHECK(_failure->inject(failure_unit, failure_type, instance) == expected_result);
|
CHECK(_failure->inject(failure_unit, failure_type, instance) == expected_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AutopilotTesterFailure::enable_actuator_output_status()
|
||||||
|
{
|
||||||
|
CHECK(getTelemetry()->set_rate_actuator_output_status(20.f) == Telemetry::Result::Success);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AutopilotTesterFailure::ensure_motor_stopped(unsigned index, unsigned num_motors)
|
||||||
|
{
|
||||||
|
const Telemetry::ActuatorOutputStatus &status = getTelemetry()->actuator_output_status();
|
||||||
|
CHECK(status.active >= num_motors);
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < num_motors; ++i) {
|
||||||
|
if (i == index) {
|
||||||
|
CHECK(status.actuator[i] <= 901.f);
|
||||||
|
|
||||||
|
} else { // ensure all others are still running
|
||||||
|
CHECK(status.actuator[i] >= 999.f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ public:
|
|||||||
void set_param_ca_failure_mode(int value);
|
void set_param_ca_failure_mode(int value);
|
||||||
void set_param_com_act_fail_act(int value);
|
void set_param_com_act_fail_act(int value);
|
||||||
|
|
||||||
|
void enable_actuator_output_status();
|
||||||
|
void ensure_motor_stopped(unsigned index, unsigned num_motors);
|
||||||
|
|
||||||
void inject_failure(mavsdk::Failure::FailureUnit failure_unit, mavsdk::Failure::FailureType failure_type, int instance,
|
void inject_failure(mavsdk::Failure::FailureUnit failure_unit, mavsdk::Failure::FailureType failure_type, int instance,
|
||||||
mavsdk::Failure::Result expected_result);
|
mavsdk::Failure::Result expected_result);
|
||||||
void connect(const std::string uri);
|
void connect(const std::string uri);
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ TEST_CASE("Control Allocation - Remove one motor", "[controlallocation]")
|
|||||||
tester.set_rtl_altitude(flight_altitude);
|
tester.set_rtl_altitude(flight_altitude);
|
||||||
tester.check_tracks_mission(5.f);
|
tester.check_tracks_mission(5.f);
|
||||||
tester.store_home();
|
tester.store_home();
|
||||||
|
tester.enable_actuator_output_status();
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(
|
std::this_thread::sleep_for(std::chrono::seconds(
|
||||||
1)); // This is necessary for the takeoff altitude to be applied properly
|
1)); // This is necessary for the takeoff altitude to be applied properly
|
||||||
|
|
||||||
@@ -74,12 +75,15 @@ TEST_CASE("Control Allocation - Remove one motor", "[controlallocation]")
|
|||||||
// Motor failure mid-air
|
// Motor failure mid-air
|
||||||
tester.start_checking_altitude(altitude_tolerance);
|
tester.start_checking_altitude(altitude_tolerance);
|
||||||
const int motor_instance = 1;
|
const int motor_instance = 1;
|
||||||
|
const unsigned num_motors = 6; // TODO: get from model
|
||||||
tester.inject_failure(mavsdk::Failure::FailureUnit::SystemMotor, mavsdk::Failure::FailureType::Off, motor_instance,
|
tester.inject_failure(mavsdk::Failure::FailureUnit::SystemMotor, mavsdk::Failure::FailureType::Off, motor_instance,
|
||||||
mavsdk::Failure::Result::Success);
|
mavsdk::Failure::Result::Success);
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
tester.ensure_motor_stopped(motor_instance - 1, num_motors);
|
||||||
|
|
||||||
tester.execute_mission();
|
tester.execute_mission();
|
||||||
tester.stop_checking_altitude();
|
tester.stop_checking_altitude();
|
||||||
|
tester.ensure_motor_stopped(motor_instance - 1, num_motors); // just to be sure
|
||||||
|
|
||||||
// RTL
|
// RTL
|
||||||
tester.execute_rtl();
|
tester.execute_rtl();
|
||||||
|
|||||||
Reference in New Issue
Block a user