Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obstacle Avoidance prearm checks and log health status #11638

Merged
merged 10 commits into from
Mar 27, 2019
7 changes: 3 additions & 4 deletions src/modules/commander/Commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3834,7 +3834,6 @@ bool Commander::preflight_check(bool report)
void Commander::data_link_check(bool &status_changed)
{
bool updated = false;
static bool print_msg_once = false;

orb_check(_telemetry_status_sub, &updated);

Expand Down Expand Up @@ -3968,9 +3967,9 @@ void Commander::data_link_check(bool &status_changed)
//if avoidance never started
if (_datalink_last_heartbeat_avoidance_system == 0
&& hrt_elapsed_time(&_datalink_last_heartbeat_avoidance_system) > _oa_boot_timeout.get() * 1_s) {
if (!print_msg_once) {
if (!_print_msg_once) {
mavlink_log_critical(&mavlink_log_pub, "Avoidance system not available!");
print_msg_once = true;
_print_msg_once = true;

}
}
Expand All @@ -3981,7 +3980,7 @@ void Commander::data_link_check(bool &status_changed)
_avoidance_system_lost = true;
mavlink_log_critical(&mavlink_log_pub, "Avoidance system lost");
status_flags.avoidance_system_valid = false;
print_msg_once = false;
_print_msg_once = false;
}

//if status changed
Expand Down
3 changes: 2 additions & 1 deletion src/modules/commander/Commander.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ class Commander : public ModuleBase<Commander>, public ModuleParams

hrt_abstime _datalink_last_heartbeat_avoidance_system{0};
bool _avoidance_system_lost{false};
hrt_abstime _avoidance_system_not_started{0};

bool _avoidance_system_status_change{false};
uint8_t _datalink_last_status_avoidance_system{telemetry_status_s::MAV_STATE_UNINIT};
Expand All @@ -204,6 +203,8 @@ class Commander : public ModuleBase<Commander>, public ModuleParams
systemlib::Hysteresis _auto_disarm_landed{false};
systemlib::Hysteresis _auto_disarm_killed{false};

bool _print_msg_once{false};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rename it to _print_avoidance_msg_once otherwise it's not clear what this is referring to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 384cfc3


// Subscriptions
Subscription<estimator_status_s> _estimator_status_sub{ORB_ID(estimator_status)};
Subscription<mission_result_s> _mission_result_sub{ORB_ID(mission_result)};
Expand Down