mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 15:03:33 +08:00
engine_failure flag
Added engine_failure flag to behicle status, alsoset_nav_state in the state machine helper takes this flag into account
This commit is contained in:
@@ -490,9 +490,12 @@ bool set_nav_state(struct vehicle_status_s *status, const bool data_link_loss_en
|
|||||||
|
|
||||||
case MAIN_STATE_AUTO_MISSION:
|
case MAIN_STATE_AUTO_MISSION:
|
||||||
/* go into failsafe
|
/* go into failsafe
|
||||||
|
* - if we have an engine failure
|
||||||
* - if either the datalink is enabled and lost as well as RC is lost
|
* - if either the datalink is enabled and lost as well as RC is lost
|
||||||
* - if there is no datalink and the mission is finished */
|
* - if there is no datalink and the mission is finished */
|
||||||
if (((status->data_link_lost && data_link_loss_enabled) && status->rc_signal_lost) ||
|
if (status->engine_failure) {
|
||||||
|
status->nav_state = NAVIGATION_STATE_AUTO_LANDENGFAIL;
|
||||||
|
} else if (((status->data_link_lost && data_link_loss_enabled) && status->rc_signal_lost) ||
|
||||||
(!data_link_loss_enabled && status->rc_signal_lost && mission_finished)) {
|
(!data_link_loss_enabled && status->rc_signal_lost && mission_finished)) {
|
||||||
status->failsafe = true;
|
status->failsafe = true;
|
||||||
|
|
||||||
@@ -532,8 +535,10 @@ bool set_nav_state(struct vehicle_status_s *status, const bool data_link_loss_en
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MAIN_STATE_AUTO_LOITER:
|
case MAIN_STATE_AUTO_LOITER:
|
||||||
/* go into failsafe if datalink and RC is lost */
|
/* go into failsafe on a engine failure or if datalink and RC is lost */
|
||||||
if ((status->data_link_lost && data_link_loss_enabled) && status->rc_signal_lost) {
|
if (status->engine_failure) {
|
||||||
|
status->nav_state = NAVIGATION_STATE_AUTO_LANDENGFAIL;
|
||||||
|
} else if ((status->data_link_lost && data_link_loss_enabled) && status->rc_signal_lost) {
|
||||||
status->failsafe = true;
|
status->failsafe = true;
|
||||||
|
|
||||||
if (status->condition_global_position_valid && status->condition_home_position_valid) {
|
if (status->condition_global_position_valid && status->condition_home_position_valid) {
|
||||||
@@ -586,8 +591,12 @@ bool set_nav_state(struct vehicle_status_s *status, const bool data_link_loss_en
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MAIN_STATE_AUTO_RTL:
|
case MAIN_STATE_AUTO_RTL:
|
||||||
/* require global position and home */
|
/* require global position and home, also go into failsafe on an engine failure */
|
||||||
if ((!status->condition_global_position_valid || !status->condition_home_position_valid)) {
|
|
||||||
|
if (status->engine_failure) {
|
||||||
|
status->nav_state = NAVIGATION_STATE_AUTO_LANDENGFAIL;
|
||||||
|
} else if ((!status->condition_global_position_valid ||
|
||||||
|
!status->condition_home_position_valid)) {
|
||||||
status->failsafe = true;
|
status->failsafe = true;
|
||||||
|
|
||||||
if (status->condition_local_position_valid) {
|
if (status->condition_local_position_valid) {
|
||||||
|
|||||||
@@ -201,8 +201,10 @@ struct vehicle_status_s {
|
|||||||
bool rc_signal_lost; /**< true if RC reception lost */
|
bool rc_signal_lost; /**< true if RC reception lost */
|
||||||
bool rc_input_blocked; /**< set if RC input should be ignored */
|
bool rc_input_blocked; /**< set if RC input should be ignored */
|
||||||
|
|
||||||
bool data_link_lost; /**< datalink to GCS lost */
|
bool data_link_lost; /**< datalink to GCS lost */
|
||||||
uint8_t data_link_lost_counter; /**< counts unique data link lost events */
|
uint8_t data_link_lost_counter; /**< counts unique data link lost events */
|
||||||
|
|
||||||
|
bool engine_failure; /** Set to true if an engine failure is detected */
|
||||||
|
|
||||||
bool offboard_control_signal_found_once;
|
bool offboard_control_signal_found_once;
|
||||||
bool offboard_control_signal_lost;
|
bool offboard_control_signal_lost;
|
||||||
|
|||||||
Reference in New Issue
Block a user