Skip to content

Commit c1108e7

Browse files
added fix for all-nan messages on boot
1 parent 235b239 commit c1108e7

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

urg_node/include/uam/uam_driver_ros.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ class UamROS
204204
nullptr;
205205

206206
std::vector<std::pair<size_t, float>> ranges_in_safety_area;
207+
size_t finite_ranges_count = 0;
207208

208209
for (size_t idx = 0; idx < reply.ranges.size(); idx++)
209210
{
@@ -217,6 +218,10 @@ class UamROS
217218
if (within_fov)
218219
{
219220
msg.ranges.push_back(range_m);
221+
if (!std::isnan(range_m))
222+
{
223+
finite_ranges_count++;
224+
}
220225
}
221226

222227
if (safety_area != nullptr && !std::isnan(range_m))
@@ -229,6 +234,16 @@ class UamROS
229234
}
230235
}
231236

237+
if (finite_ranges_count == 0) {
238+
// This driver/lidar combination will periodically boot up and publish all nan ranges for a moment.
239+
// If this happens after a lidar power cycle (when the rest of the system is initilized), it breaks the
240+
// laser filtering pipeline. The likleyhood of nominally receiving all nan readings in our usecase is so
241+
// infinitesimally small we can just skip publishing in this case.
242+
ROS_WARN_STREAM_THROTTLE(5.0, "All ranges are infinite, skipping scan publish!");
243+
// We return early to avoid publishing mis-leading scans or area information.
244+
return;
245+
}
246+
232247
if constexpr (is_detected<detected_intensities, T>::value)
233248
{
234249
msg.intensities.reserve(number_of_readings);

0 commit comments

Comments
 (0)