mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 09:53:33 +08:00
Improve offboard failsafe (#18160)
* state_machine_helper: improve offboard failsafe * state_machine_helper: add missing parameter to set_link_loss_nav_state * state_machine_helper: fix no rc and offboard reason * Fix offboard test by enabling rcl_except * mavros_test fix offboard_posctl_test with rcl_except * autopilot_tester make RcLossException bits explicit Co-authored-by: Julian Oes <julian@oes.ch> * autopilot_tester change rcl_except to rc_loss_exception Co-authored-by: Julian Oes <julian@oes.ch> * autopilot_tester fix rc_loss_exception renaming errors Co-authored-by: Julian Oes <julian@oes.ch>
This commit is contained in:
@@ -143,6 +143,22 @@ void AutopilotTester::set_height_source(AutopilotTester::HeightSource height_sou
|
||||
}
|
||||
}
|
||||
|
||||
void AutopilotTester::set_rc_loss_exception(AutopilotTester::RcLossException mask)
|
||||
{
|
||||
switch (mask) {
|
||||
case RcLossException::Mission:
|
||||
CHECK(_param->set_param_int("COM_RCL_EXCEPT", 1 << 0) == Param::Result::Success);
|
||||
break;
|
||||
|
||||
case RcLossException::Hold:
|
||||
CHECK(_param->set_param_int("COM_RCL_EXCEPT", 1 << 1) == Param::Result::Success);
|
||||
break;
|
||||
|
||||
case RcLossException::Offboard:
|
||||
CHECK(_param->set_param_int("COM_RCL_EXCEPT", 1 << 2) == Param::Result::Success);
|
||||
}
|
||||
}
|
||||
|
||||
void AutopilotTester::arm()
|
||||
{
|
||||
const auto result = _action->arm();
|
||||
|
||||
@@ -85,6 +85,12 @@ public:
|
||||
Gps
|
||||
};
|
||||
|
||||
enum class RcLossException {
|
||||
Mission = 0,
|
||||
Hold = 1,
|
||||
Offboard = 2
|
||||
};
|
||||
|
||||
AutopilotTester();
|
||||
~AutopilotTester();
|
||||
|
||||
@@ -96,6 +102,7 @@ public:
|
||||
void check_home_not_within(float min_distance_m);
|
||||
void set_takeoff_altitude(const float altitude_m);
|
||||
void set_height_source(HeightSource height_source);
|
||||
void set_rc_loss_exception(RcLossException mask);
|
||||
void arm();
|
||||
void takeoff();
|
||||
void land();
|
||||
|
||||
@@ -42,6 +42,7 @@ TEST_CASE("Offboard takeoff and land", "[multicopter][offboard]")
|
||||
tester.connect(connection_url);
|
||||
tester.wait_until_ready();
|
||||
tester.store_home();
|
||||
tester.set_rc_loss_exception(AutopilotTester::RcLossException::Offboard);
|
||||
tester.arm();
|
||||
std::chrono::seconds goto_timeout = std::chrono::seconds(90);
|
||||
tester.offboard_goto(takeoff_position, 0.1f, goto_timeout);
|
||||
@@ -60,6 +61,7 @@ TEST_CASE("Offboard position control", "[multicopter][offboard]")
|
||||
tester.connect(connection_url);
|
||||
tester.wait_until_ready();
|
||||
tester.store_home();
|
||||
tester.set_rc_loss_exception(AutopilotTester::RcLossException::Offboard);
|
||||
tester.arm();
|
||||
std::chrono::seconds goto_timeout = std::chrono::seconds(120);
|
||||
tester.offboard_goto(takeoff_position, 0.1f, goto_timeout);
|
||||
|
||||
Reference in New Issue
Block a user