Skip to content

Commit

Permalink
navigator: add failure enum
Browse files Browse the repository at this point in the history
  • Loading branch information
bresch committed Aug 14, 2024
1 parent 25fcb3c commit 4ed3e9e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
5 changes: 4 additions & 1 deletion msg/NavigatorStatus.msg
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
uint64 timestamp # time since system start (microseconds)

uint8 nav_state # Source mode (values in VehicleStatus)
bool failure # True when the current mode cannot continue
uint8 failure # Navigator failure enum

uint8 FAILURE_NONE = 0
uint8 FAILURE_HAGL = 1 # Target altitude exceeds maximum height above ground
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ void NavigatorChecks::checkAndReport(const Context &context, Report &reporter)
}

if (context.status().nav_state == status.nav_state) {
reporter.failsafeFlags().navigator_failure = status.failure;

reporter.failsafeFlags().navigator_failure = (status.failure != navigator_status_s::FAILURE_NONE);

if (status.failure == navigator_status_s::FAILURE_HAGL) {
/* EVENT
*/
reporter.armingCheckFailure(NavModes::All,
health_component_t::system,
events::ID("check_navigator_failure_hagl"),
events::Log::Error,
"Waypoint above maximum height");
}
}
}
2 changes: 1 addition & 1 deletion src/modules/navigator/navigator.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class Navigator : public ModuleBase<Navigator>, public ModuleParams

void sendWarningDescentStoppedDueToTerrain();

void trigger_failsafe(uint8_t nav_state);
void trigger_hagl_failsafe(uint8_t nav_state);

private:

Expand Down
8 changes: 4 additions & 4 deletions src/modules/navigator/navigator_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1358,10 +1358,10 @@ void Navigator::set_mission_failure_heading_timeout()
}
}

void Navigator::trigger_failsafe(const uint8_t nav_state)
void Navigator::trigger_hagl_failsafe(const uint8_t nav_state)
{
if (!_navigator_status.failure || _navigator_status.nav_state != nav_state) {
_navigator_status.failure = true;
if ((_navigator_status.failure != navigator_status_s::FAILURE_HAGL) || _navigator_status.nav_state != nav_state) {
_navigator_status.failure = navigator_status_s::FAILURE_HAGL;
_navigator_status.nav_state = nav_state;

_navigator_status_updated = true;
Expand All @@ -1378,7 +1378,7 @@ void Navigator::publish_navigator_status()

if (_navigator_status.nav_state != current_nav_state) {
_navigator_status.nav_state = current_nav_state;
_navigator_status.failure = false;
_navigator_status.failure = navigator_status_s::FAILURE_NONE;
_navigator_status_updated = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/navigator/rtl_direct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void RtlDirect::set_rtl_item()
mavlink_log_info(_navigator->get_mavlink_log_pub(), "RTL: return alt higher than max HAGL\t");
events::send(events::ID("rtl_fail_max_hagl"), events::Log::Error, "RTL: return alt higher than max HAGL");

_navigator->trigger_failsafe(getNavigatorStateId());
_navigator->trigger_hagl_failsafe(getNavigatorStateId());
_rtl_state = RTLState::IDLE;
}

Expand Down

0 comments on commit 4ed3e9e

Please sign in to comment.