Skip to content

Commit

Permalink
[Foxy] adding fix for 360 inclusive bound lidars (#296)
Browse files Browse the repository at this point in the history
* adding fix for 360 inclusive bound lidars

* adding std::round

* Update laser_utils.cpp

* Update laser_utils.cpp
  • Loading branch information
SteveMacenski authored Oct 1, 2020
1 parent d9a8a86 commit 77337f4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/laser_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,17 @@ karto::LaserRangeFinder * LaserAssistant::makeLaser(const double & mountingYaw)
laser->SetAngularResolution(scan_.angle_increment);

bool is_360_lidar = false;
if (std::fabs(scan_.angle_max - scan_.angle_min - 2.0 * M_PI) < (scan_.angle_increment - (std::numeric_limits<float>::epsilon() * 2.0f*M_PI))) {
const float angular_range = std::fabs(scan_.angle_max - scan_.angle_min);
if (std::fabs(angular_range - 2.0 * M_PI) < (scan_.angle_increment - (std::numeric_limits<float>::epsilon() * 2.0f*M_PI))) {
is_360_lidar = true;
}

// Check if we have a 360 laser, but incorrectly setup as to produce
// measurements in range [0, 360] rather than appropriately as [0, 360)
if (angular_range > 6.10865 /*350 deg*/ && std::round(angular_range / scan_.angle_increment) + 1 == scan_.ranges.size()) {
is_360_lidar = false;
}

laser->SetIs360Laser(is_360_lidar);

double max_laser_range = 25;
Expand Down

0 comments on commit 77337f4

Please sign in to comment.