Skip to content

Commit a716b05

Browse files
committed
feat(min_range): set a default filter out near-ego-points.
* as lots of users report that some SLAM package will include few ego points exactly on the pose location etc. We set a min_range filter out these points. related issues: #30, #20 --- TODO: * update video presentation. * I will try to update the data process to make it easy for both ROS1 and ROS2 users.
1 parent 5b2884f commit a716b05

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

assets/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ inflate_hits_dist = 0.2 # d_s in the paper, default 0.2
1212
inflate_unknown_compensation = true
1313
ray_passthrough_hits = false
1414
down_sampling_method = "center" # ["none", "center", "centroid", "uniform"]
15+
min_range = 0.2 # For filter out the ego points (some SLAM algorithm will include a pose point etc.
1516
max_range = -1 # Maximum range to integrate
1617
only_valid = false # Only do ray casting for points within 'max_range'
1718
hit_depth = 0 # Level of the octree to integrate hits

main.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ def inv_pose_matrix(pose):
2222
inv_pose[:3, :3] = pose[:3, :3].T
2323
inv_pose[:3, 3] = -pose[:3, :3].T.dot(pose[:3, 3])
2424
return inv_pose
25+
26+
MIN_AXIS_RANGE = 0.2 # HARD CODED: remove ego vehicle points
27+
MAX_AXIS_RANGE = 50 # HARD CODED: remove far away points
28+
2529
class DynamicMapData:
2630
def __init__(self, directory):
2731
self.scene_id = directory.split("/")[-1]
@@ -44,6 +48,7 @@ def __getitem__(self, index_):
4448

4549
def main_vis(
4650
data_dir: str = "/home/kin/data/00",
51+
voxel_map: bool = True, # output voxel-level map or raw point-level.
4752
):
4853
dataset = DynamicMapData(data_dir)
4954

@@ -54,17 +59,20 @@ def main_vis(
5459
data = dataset[data_id]
5560
now_scene_id = data['scene_id']
5661
pbar.set_description(f"id: {data_id}, scene_id: {now_scene_id}, timestamp: {data['timestamp']}")
57-
62+
norm_pc0 = np.linalg.norm(data['pc'][:, :3] - data['pose'][:3], axis=1)
63+
range_mask = (
64+
(norm_pc0>MIN_AXIS_RANGE) &
65+
(norm_pc0<MAX_AXIS_RANGE)
66+
)
67+
# STEP 1: integrate point cloud into dufomap
68+
mydufo.run(data['pc'][range_mask], data['pose'], cloud_transform = False)
5869
# STEP 1: integrate point cloud into dufomap
59-
mydufo.run(data['pc'], data['pose'], cloud_transform = False) # since pc already in world frame
6070
cloud_acc = np.concatenate((cloud_acc, data['pc']), axis=0)
6171

6272
# STEP 2: propagate
6373
mydufo.oncePropagateCluster(if_propagate=True, if_cluster=False)
64-
# STEP 3: Map results
65-
mydufo.outputMap(cloud_acc, voxel_map=False)
66-
# NOTE(Qingwen): You can also save voxeled map directly based on the resolution we set before:
67-
# mydufo.outputMap(cloud_acc, voxel_map=True)
74+
# STEP 3: Map results; You can save the voxel map directly based on the resolution we set before:
75+
mydufo.outputMap(cloud_acc, voxel_map=voxel_map)
6876

6977
mydufo.printDetailTiming()
7078

src/dufomap.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,15 @@ void cluster(Map& map, Clustering const& clustering)
326326
}
327327
}
328328

329+
template <class PointCloud>
330+
void filterminDistance(PointCloud& cloud, ufo::Point origin, float min_distance)
331+
{
332+
float sqrt_dist = min_distance * min_distance;
333+
std::erase_if(cloud, [origin, sqrt_dist](auto const& point) {
334+
return origin.squaredDistance(point) < sqrt_dist;
335+
});
336+
}
337+
329338
int main(int argc, char* argv[])
330339
{
331340
if (1 >= argc) {
@@ -390,6 +399,9 @@ int main(int argc, char* argv[])
390399
ufo::readPointCloudPCD(path / "pcd" / filename, cloud, viewpoint);
391400
timing[1].stop();
392401

402+
// NOTE(Qingwen): lots of user facing about ego points inside data, we filterminDistance around ego agent.
403+
filterminDistance(cloud, viewpoint.translation, config.integration.min_range);
404+
393405
cloud_acc.insert(std::end(cloud_acc), std::cbegin(cloud), std::cend(cloud));
394406

395407
ufo::insertPointCloud(map, cloud, viewpoint.translation, config.integration,

0 commit comments

Comments
 (0)