Skip to content

Commit

Permalink
Simplify condition
Browse files Browse the repository at this point in the history
  • Loading branch information
f0reachARR committed Apr 18, 2024
1 parent 99f7276 commit 745ba9d
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,13 @@ const std::vector<std::string> OccupancyGridSensorBase::getDetectedObjects(
std::vector<std::string> detected_entities;
const auto pose = getSensorPose(status);
for (const auto & s : status) {
if (const auto has_detected =
std::find(lidar_detected_entities.begin(), lidar_detected_entities.end(), s.name()) !=
lidar_detected_entities.end();
!has_detected) {
continue;
}

double distance = std::hypot(
const bool has_detected =
std::find(lidar_detected_entities.begin(), lidar_detected_entities.end(), s.name()) !=
lidar_detected_entities.end();
const double distance = std::hypot(
s.pose().position().x() - pose.position().x(), s.pose().position().y() - pose.position().y(),
s.pose().position().z() - pose.position().z());
if (s.name() != configuration_.entity() && distance <= configuration_.range()) {
if (has_detected && s.name() != configuration_.entity() && distance <= configuration_.range()) {
detected_entities.emplace_back(s.name());
}
}
Expand Down

0 comments on commit 745ba9d

Please sign in to comment.