Skip to content

Commit

Permalink
ADSB: replace last excess hrt_absolute_time() in the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
MaEtUgR authored and sfuhrer committed Dec 19, 2024
1 parent 30e51cb commit c69f96e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/lib/adsb/AdsbConflict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ void AdsbConflict::remove_icao_address_from_conflict_list(int traffic_index)
PX4_INFO("icao_address removed. Buffer Size: %d", (int)_traffic_buffer.timestamp.size());
}

void AdsbConflict::add_icao_address_from_conflict_list(uint32_t icao_address)
void AdsbConflict::add_icao_address_from_conflict_list(uint32_t icao_address, hrt_abstime now)
{
_traffic_buffer.timestamp.push_back(hrt_absolute_time());
_traffic_buffer.timestamp.push_back(now);
_traffic_buffer.icao_address.push_back(icao_address);
PX4_INFO("icao_address added. Buffer Size: %d", (int)_traffic_buffer.timestamp.size());
}
Expand All @@ -133,7 +133,7 @@ void AdsbConflict::get_traffic_state(hrt_abstime now)
}

if (new_traffic && _conflict_detected && !_traffic_buffer_full) {
add_icao_address_from_conflict_list(_transponder_report.icao_address);
add_icao_address_from_conflict_list(_transponder_report.icao_address, now);
_traffic_state = TRAFFIC_STATE::ADD_CONFLICT;

} else if (new_traffic && _conflict_detected && _traffic_buffer_full) {
Expand Down
5 changes: 2 additions & 3 deletions src/lib/adsb/AdsbConflict.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class AdsbConflict

void remove_icao_address_from_conflict_list(int traffic_index);

void add_icao_address_from_conflict_list(uint32_t icao_address);
void add_icao_address_from_conflict_list(uint32_t icao_address, hrt_abstime now);

void get_traffic_state(hrt_abstime now);

Expand All @@ -129,8 +129,7 @@ class AdsbConflict
float hor_velocity, float ver_velocity, int emitter_type, uint32_t icao_address, double lat_uav, double lon_uav,
float &alt_uav);

void run_fake_traffic(double &lat_uav, double &lon_uav,
float &alt_uav);
void run_fake_traffic(double &lat_uav, double &lon_uav, float &alt_uav);

void remove_expired_conflicts();

Expand Down

0 comments on commit c69f96e

Please sign in to comment.