Skip to content

Commit

Permalink
Commander: make last_fail_time_us parameter a reference instead of po…
Browse files Browse the repository at this point in the history
…inter
  • Loading branch information
MaEtUgR authored and dagar committed Mar 23, 2022
1 parent eee4aae commit e6ed595
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/modules/commander/Commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3237,7 +3237,7 @@ Commander::control_status_leds(bool changed, const uint8_t battery_warning)
}

bool Commander::check_posvel_validity(const bool data_valid, const float data_accuracy, const float required_accuracy,
const hrt_abstime &data_timestamp_us, hrt_abstime *last_fail_time_us,
const hrt_abstime &data_timestamp_us, hrt_abstime &last_fail_time_us,
const bool was_valid)
{
bool valid = was_valid;
Expand All @@ -3250,7 +3250,7 @@ bool Commander::check_posvel_validity(const bool data_valid, const float data_ac
if (level_check_pass) {
if (!was_valid) {
// check if probation period has elapsed
if (hrt_elapsed_time(last_fail_time_us) > 1_s) {
if (hrt_elapsed_time(&last_fail_time_us) > 1_s) {
valid = true;
}
}
Expand All @@ -3262,7 +3262,7 @@ bool Commander::check_posvel_validity(const bool data_valid, const float data_ac
valid = false;
}

*last_fail_time_us = hrt_absolute_time();
last_fail_time_us = hrt_absolute_time();
}

if (was_valid != valid) {
Expand Down Expand Up @@ -4097,15 +4097,15 @@ void Commander::estimator_check()

_status_flags.global_position_valid =
check_posvel_validity(xy_valid, gpos.eph, _param_com_pos_fs_eph.get(), gpos.timestamp,
&_last_gpos_fail_time_us, _status_flags.global_position_valid);
_last_gpos_fail_time_us, _status_flags.global_position_valid);

_status_flags.local_position_valid =
check_posvel_validity(xy_valid, lpos.eph, lpos_eph_threshold_adj, lpos.timestamp,
&_last_lpos_fail_time_us, _status_flags.local_position_valid);
_last_lpos_fail_time_us, _status_flags.local_position_valid);

_status_flags.local_velocity_valid =
check_posvel_validity(v_xy_valid, lpos.evh, _param_com_vel_fs_evh.get(), lpos.timestamp,
&_last_lvel_fail_time_us, _status_flags.local_velocity_valid);
_last_lvel_fail_time_us, _status_flags.local_velocity_valid);
}


Expand Down
2 changes: 1 addition & 1 deletion src/modules/commander/Commander.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Commander : public ModuleBase<Commander>, public ModuleParams
void battery_status_check();

bool check_posvel_validity(const bool data_valid, const float data_accuracy, const float required_accuracy,
const hrt_abstime &data_timestamp_us, hrt_abstime *last_fail_time_us,
const hrt_abstime &data_timestamp_us, hrt_abstime &last_fail_time_us,
const bool was_valid);

void control_status_leds(bool changed, const uint8_t battery_warning);
Expand Down

0 comments on commit e6ed595

Please sign in to comment.