Skip to content

Commit 88477d2

Browse files
committed
fix: make nan utls generic
1 parent 05703af commit 88477d2

File tree

4 files changed

+25
-24
lines changed

4 files changed

+25
-24
lines changed

include/am_utils/am_pcl_utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class AMPCLUtils
1414
static pcl::PointCloud<pcl::PointXYZIR>::ConstPtr convertToPointXYZIR(
1515
const sensor_msgs::PointCloud2::ConstPtr pc2,
1616
pcl::PointCloud<pcl::PointXYZIR>::Ptr &pcl);
17+
static bool isSetToNaN(pcl::PointXYZIR &point);
18+
static void setNaN(pcl::PointXYZIR &point);
1719
};
1820

1921
}

include/am_utils/dust_filter.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ class DustFilter
3434
float outside_min_z_m_;
3535
float outside_max_z_m_;
3636

37-
bool isSetToNaN(pcl::PointXYZIR &point);
38-
void setNaN(pcl::PointXYZIR &point);
3937
void printInsideParams();
4038
void printOutsideParams();
4139

src/am_utils/am_pcl_utils.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,25 @@ pcl::PointCloud<pcl::PointXYZIR>::ConstPtr AMPCLUtils::convertToPointXYZIR(
3131
return pcl;
3232
}
3333

34+
bool AMPCLUtils::isSetToNaN(pcl::PointXYZIR &point)
35+
{
36+
if (std::isnan(point.x) || std::isnan(point.y) || std::isnan(point.z) ||
37+
std::isnan(point.intensity) || std::isnan(point.intensity))
38+
{
39+
setNaN(point);
40+
return true;
41+
}
42+
return false;
43+
}
44+
45+
void AMPCLUtils::setNaN(pcl::PointXYZIR &point)
46+
{
47+
point.x = std::nanf("");
48+
point.y = std::nanf("");
49+
point.z = std::nanf("");
50+
point.intensity = std::nanf("");
51+
point.range = std::nanf("");
52+
}
53+
3454
} // namespace
3555

src/am_utils/dust_filter.cpp

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <pcl_conversions/pcl_conversions.h>
44
#include <pcl_ros/point_cloud.h>
55

6+
#include <am_utils/am_pcl_utils.h>
67
#include <am_utils/dust_filter.h>
78
#include <am_utils/point_types.h>
89
#include <vb_util_lib/frame_names.h>
@@ -91,7 +92,7 @@ int DustFilter::process(pcl::PointCloud<pcl::PointXYZIR> &pcl, bool skip_dust_fi
9192
pcl::PointXYZIR &point = pcl.points[index];
9293

9394
// if already nan, continue
94-
if(isSetToNaN(point))
95+
if(AMPCLUtils::isSetToNaN(point))
9596
{
9697
nan_mask[index] = true;
9798
continue;
@@ -175,7 +176,7 @@ int DustFilter::process(pcl::PointCloud<pcl::PointXYZIR> &pcl, bool skip_dust_fi
175176
pcl::PointXYZIR &point = pcl.points[index];
176177
if(nan_mask[index])
177178
{
178-
setNaN(point);
179+
AMPCLUtils::setNaN(point);
179180
points_removed++;
180181
is_dense = false;
181182
}
@@ -192,26 +193,6 @@ int DustFilter::process(pcl::PointCloud<pcl::PointXYZIR> &pcl, bool skip_dust_fi
192193
return points_removed;
193194
}
194195

195-
bool DustFilter::isSetToNaN(pcl::PointXYZIR &point)
196-
{
197-
if (std::isnan(point.x) || std::isnan(point.y) || std::isnan(point.z) ||
198-
std::isnan(point.intensity) || std::isnan(point.intensity))
199-
{
200-
setNaN(point);
201-
return true;
202-
}
203-
return false;
204-
}
205-
206-
void DustFilter::setNaN(pcl::PointXYZIR &point)
207-
{
208-
point.x = std::nanf("");
209-
point.y = std::nanf("");
210-
point.z = std::nanf("");
211-
point.intensity = std::nanf("");
212-
point.range = std::nanf("");
213-
}
214-
215196
void DustFilter::setInsideFilter(float min_x_m_, float max_x_m_, float min_y_m_, float max_y_m_, float min_z_m_, float max_z_m_)
216197
{
217198
inside_min_x_m_ = min_x_m_;

0 commit comments

Comments
 (0)