hku-mars / FAST_LIO

A computationally efficient and robust LiDAR-inertial odometry (LIO) package
GNU General Public License v2.0
2.78k stars 936 forks source link

there are any question in function lasermap_fov_segment(), it can not delete the old point in Real-Time #250

Closed 1091205886 closed 1 year ago

1091205886 commented 1 year ago

suggest use this code to displace the function lasermap_fov_segment(): `void lasermap_fov_segment() { cub_needrm.clear(); kdtree_delete_counter = 0; kdtree_delete_time = 0.0;
pointBodyToWorld(XAxisPoint_body, XAxisPoint_world); V3D pos_LiD = pos_lid; if (!Localmap_Initialized){ for (int i = 0; i < 3; i++){ LocalMap_Points.vertex_min[i] = pos_LiD(i) - cube_len / 2.0; LocalMap_Points.vertex_max[i] = pos_LiD(i) + cube_len / 2.0; } Localmap_Initialized = true; return; } float dist_to_map_edge[3][2]; bool need_move = false; for (int i = 0; i < 3; i++){ dist_to_map_edge[i][0] = fabs(pos_LiD(i) - LocalMap_Points.vertex_min[i]); dist_to_map_edge[i][1] = fabs(pos_LiD(i) - LocalMap_Points.vertex_max[i]); if (dist_to_map_edge[i][0] <= MOV_THRESHOLD DET_RANGE || dist_to_map_edge[i][1] <= MOV_THRESHOLD DET_RANGE) need_move = true; } if (!need_move) return; BoxPointType New_LocalMap_Points, tmp_boxpoints; New_LocalMap_Points = LocalMap_Points; //float mov_dist = max((cube_len - 2.0 MOV_THRESHOLD DET_RANGE) 0.5 0.9, double(DET_RANGE * (MOV_THRESHOLD -1)));

std::vector<double> mov_dist_;
bool retain = false;
for (int i = 0; i < 3; i++) 
{
    double dist;
    if (dist_to_map_edge[i][0] <= MOV_THRESHOLD * DET_RANGE)
    {
        dist = double(MOV_THRESHOLD * DET_RANGE - dist_to_map_edge[i][0]);
    }
    else if (dist_to_map_edge[i][1] <= MOV_THRESHOLD * DET_RANGE)
    {
        dist = double(MOV_THRESHOLD * DET_RANGE - dist_to_map_edge[i][1]);
    }
    else
        std::cout << "<<<<<<<<<<<< not thing" << std::endl;

    retain = retain || (dist >= 5);

    mov_dist_.push_back(dist);
}
if(!retain)
return ;

for (int i = 0; i < 3; i++){
    tmp_boxpoints = LocalMap_Points;
    if (dist_to_map_edge[i][0] <= MOV_THRESHOLD * DET_RANGE){
        New_LocalMap_Points.vertex_max[i] -= mov_dist_[i];
        New_LocalMap_Points.vertex_min[i] -= mov_dist_[i];
        tmp_boxpoints.vertex_min[i] = LocalMap_Points.vertex_max[i] - mov_dist_[i];
        cub_needrm.push_back(tmp_boxpoints);
    } else if (dist_to_map_edge[i][1] <= MOV_THRESHOLD * DET_RANGE){
        New_LocalMap_Points.vertex_max[i] += mov_dist_[i];
        New_LocalMap_Points.vertex_min[i] += mov_dist_[i];
        tmp_boxpoints.vertex_max[i] = LocalMap_Points.vertex_min[i] + mov_dist_[i];
        cub_needrm.push_back(tmp_boxpoints);
    }
}
LocalMap_Points = New_LocalMap_Points;

points_cache_collect();
double delete_begin = omp_get_wtime();
if(cub_needrm.size() > 0) kdtree_delete_counter = ikdtree.Delete_Point_Boxes(cub_needrm);
kdtree_delete_time = omp_get_wtime() - delete_begin;

}`

Ecstasy-EC commented 1 year ago

Could you please describe the problem you met in detail? The code you provided is also hard to see the difference.

1091205886 commented 1 year ago

1: the problem is that the odometry is moving forword and the map is getting bigger and bigger, the ikd-tree can not delete the old points, I check the problem is from the funciton lasermap_fov_segment().

2: the key different is that I insert the code below into the function

`std::vector movdist; bool retain = false; for (int i = 0; i < 3; i++) { double dist; if (dist_to_map_edge[i][0] <= MOV_THRESHOLD DET_RANGE) { dist = double(MOV_THRESHOLD DET_RANGE - dist_to_map_edge[i][0]); } else if (dist_to_map_edge[i][1] <= MOV_THRESHOLD DET_RANGE) { dist = double(MOV_THRESHOLD DET_RANGE - dist_to_map_edge[i][1]); } else std::cout << "<<<<<<<<<<<< not thing" << std::endl;

retain = retain || (dist >= 5);

mov_dist_.push_back(dist);

} if(!retain) return ;`

Ecstasy-EC commented 1 year ago

Thanks for your attention. However, this is not a bug. We design to do so.

In our design, we won't move our map when the odometry does not approach the edge of the local map. This is to achieve a lower frequency of map moving to guarantee high real-time performance. The high memory efficiency of kd-Tree is able to handle a map of over 2km, as described in the paper. For the methodology of our map region management, please check the mapping section in our T-RO paper.

1091205886 commented 1 year ago

I try to decrease the parameter cube_side_length in launch to 50, and ikdtree.Delete_Point_Boxes(cub_needrm) always return 0, that means even the local map is small, it cannot delete the old points.

Ecstasy-EC commented 1 year ago

I try to decrease the parameter cube_side_length in launch to 50, and ikdtree.Delete_Point_Boxes(cub_needrm) always return 0, that means even the local map is small, it cannot delete the old points.

How do you setup your detection range? Does it meet the requirements in the paper?

1091205886 commented 1 year ago

the det_range in yaml is set to 100.0

Ecstasy-EC commented 1 year ago

the det_range in yaml is set to 100.0

Please notice that the map size should be at least two times the detection range. Otherwise, it is impossible for the map region to move. Please carefully and thoroughly read our paper before you change the parameters. Please do not imagine the working principle and guess what we have done.