激光SLAM7-基于已知位姿的构图算法

1. 通过覆盖栅格建图算法进行栅格地图的构建

1.1 Theory

激光SLAM7-基于已知位姿的构图算法_第1张图片
激光SLAM7-基于已知位姿的构图算法_第2张图片

1.2 code

这里没有判断idx和hitPtIndex是否有效:

//start of TODO 对对应的map的cell信息进行更新.(1,2,3题内容)
GridIndex hitPtIndex = ConvertWorld2GridIndex(world_x, world_y);
std::vector<GridIndex> freeIndexs = TraceLine(robotIndex.x, robotIndex.y, hitPtIndex.x, hitPtIndex.y);
for (const auto& idx : freeIndexs) {
    const auto& linIdx = GridIndexToLinearIndex(idx);
    if (pMap[linIdx] == 0) {
        continue;
    }

    pMap[linIdx] += mapParams.log_free;
}

const auto& linIdx = GridIndexToLinearIndex(hitPtIndex);
pMap[linIdx] += mapParams.log_occ;
if (pMap[linIdx] > mapParams.log_max) {
    pMap[linIdx] = mapParams.log_max;
}
//end of TODO

1.3 result

激光SLAM7-基于已知位姿的构图算法_第3张图片

2. 通过计数建图算法进行栅格地图的构建

2.1 Theory

激光SLAM7-基于已知位姿的构图算法_第4张图片
激光SLAM7-基于已知位姿的构图算法_第5张图片

2.2 Code

//start of TODO 对对应的map的cell信息进行更新.(1,2,3题内容)
GridIndex hitPtIndex = ConvertWorld2GridIndex(world_x, world_y);
std::vector<GridIndex> freeIndexs = TraceLine(robotIndex.x, robotIndex.y, hitPtIndex.x, hitPtIndex.y);
for (const auto& idx : freeIndexs) {
    if (!isValidGridIndex(idx)) {
        continue;
    }
    const auto& linIdx = GridIndexToLinearIndex(idx);
    pMapMisses[linIdx] += 1;
}

if (isValidGridIndex(hitPtIndex)) {
    const auto& linIdx = GridIndexToLinearIndex(hitPtIndex);
    pMapHits[linIdx] += 1;
}
//end of TODO
//start of TODO 通过计数建图算法或TSDF算法对栅格进行更新(2,3题内容)
for (uint32_t i = 0; i < mapParams.width * mapParams.height; ++i) {
    int visNum = pMapHits[i] + pMapMisses[i];
    if (visNum > 0) {
        pMap[i] = pMapHits[i] * 100 / (pMapHits[i] + pMapMisses[i]); 
    }
}
//end of TODO

2.3 Result

激光SLAM7-基于已知位姿的构图算法_第6张图片

3. TSDF建图算法

3.1 Theory

激光SLAM7-基于已知位姿的构图算法_第7张图片
激光SLAM7-基于已知位姿的构图算法_第8张图片

Ref

  1. 激光SLAM理论与实践(七)–基于已知定位的建图 ( 有课件)
  2. 激光SLAM理论与实践 - 第六期 第7章 基于已知定位的建图 作业与心得 (作业细节分析的不错)
  3. code

你可能感兴趣的:(SLAM,Auto,算法)