LeGO-LOAM源码解析1 : 算法整体框架和utility.h

算法整体框架和utility.h解析

loam源码地址:https://github.com/RobustFieldAutonomyLab/LeGO-LOAM.

论文学习:【论文阅读】LeGO-LOAM: Lightweight and Ground-Optimized Lidar Odometry and Mapping on Variable Terrain.

LeGO-LOAM源码解析汇总:



一、算法框架与流程

在这里插入图片描述

回顾论文,我们可以将整个代码的流程分为10HZ点云输入部分、五个处理部分和10HZ位姿估计输出部分。五个处理部分由点云分割、特征提取、高频激光里程计、低频激光建图和变换融合组成。

在代码中包含imageProjection、featureAssociation、mapOptmization、transformFusion四个cpp文件和一个头文件:utility.h。

在这里插入图片描述
通过对节点和话题关系图的查看,我们可以大概看出代码的执行逻辑如下:

imageProjection
featureAssociation
mapOptmization
transformFusion

所以我们的代码分析也会按照这个逻辑逐一展开。在这里提供一份大佬注释好的LeGo-LOAM的代码,链接如下: https://github.com/wykxwyc/LeGO-LOAM_NOTED。接下来我们的工作都会以这个为基础展开。

二、utility.h分析

utility.h作为代码中唯一的头文件,它的意义在于定义一些基本的使用变量和结构体。

首先为了简化代码,将常用的带强度信息的点云类型pcl::PointXYZI定义为PointType

typedef pcl::PointXYZI  PointType;

定义点云和imu的话题名称:

extern const string pointCloudTopic = "/velodyne_points";
extern const string imuTopic = "/imu/data";

在新的代码中作者提供了CloudRing 的使用标志以帮助进行点云投影(如 VLP-32C、VLS-128)。 Velodyne 点云具有“环”通道,可直接给出范围图像中的点行 id。 其他激光雷达可能具有相同类型的通道,即 Ouster 中的“r”。 如果您使用的是非 Velodyne 激光雷达,但它具有类似的“环形”通道,则可以更改 Utility.h 中的 PointXYZIR 定义和 imageProjection.cpp 中的相应代码:

extern const bool useCloudRing = true; // if true, ang_res_y and ang_bottom are not used

接下来作者提供了多种类型激光雷达的使用配置如VLP-16、HDL-32E、VLS-128、Ouster OS1-16等等,默认使用VLP-16。具体注释如下:

// VLP-16
//激光线束
extern const int N_SCAN = 16;
//水平方向激光点 360/水平分辨率
extern const int Horizon_SCAN = 1800;
//水平分辨率
extern const float ang_res_x = 0.2;
//垂直分辨率
extern const float ang_res_y = 2.0;
//与与水平方向的夹角
extern const float ang_bottom = 15.0+0.1;
//扫描到地面的激光线数
extern const int groundScanInd = 7;

// HDL-32E
// extern const int N_SCAN = 32;
// extern const int Horizon_SCAN = 1800;
// extern const float ang_res_x = 360.0/float(Horizon_SCAN);
// extern const float ang_res_y = 41.33/float(N_SCAN-1);
// extern const float ang_bottom = 30.67;
// extern const int groundScanInd = 20;

默认关闭回环:

extern const bool loopClosureEnableFlag = false;

建图处理时间间隔,只有时间间隔大于这个值才能进行建图优化:

extern const double mappingProcessInterval = 0.3;

处理频率0.1s(10HZ)及IMU队列长度

extern const float scanPeriod = 0.1;
extern const int systemDelay = 0;
extern const int imuQueLength = 200;

点云分割的一些设置:

extern const float sensorMinimumRange = 1.0;
extern const float sensorMountAngle = 0.0;
//点云分割的跨度60度,在imageProjection中用于判断平面
extern const float segmentTheta = 60.0/180.0*M_PI; // decrese this value may improve accuracy
//检查上下左右连续5个点做为分割的特征依据
extern const int segmentValidPointNum = 5;
extern const int segmentValidLineNum = 3;
extern const float segmentAlphaX = ang_res_x / 180.0 * M_PI;
extern const float segmentAlphaY = ang_res_y / 180.0 * M_PI;

特征点选取的一些设置:

//点特征数
extern const int edgeFeatureNum = 2;
//面特征数
extern const int surfFeatureNum = 4;
//总特征数
extern const int sectionsTotal = 6;
extern const float edgeThreshold = 0.1;
extern const float surfThreshold = 0.1;
//特征选取间隔
extern const float nearestFeatureSearchSqDist = 25;

建图参数:

//选取关键帧的范围(不使用回环)
extern const float surroundingKeyframeSearchRadius = 50.0; // key frame that is within n meters from current pose will be considerd for scan-to-map optimization (when loop closure disabled)
//子图关键帧数目(使用回环)
extern const int   surroundingKeyframeSearchNum = 50; // submap size (when loop closure enabled)

// history key frames (history submap for loop closure)
//考虑回环成立的阈值
extern const float historyKeyframeSearchRadius = 7.0; // key frame that is within n meters from current pose will be considerd for loop closure
//回环子图的构建关键帧数目2n+1
extern const int   historyKeyframeSearchNum = 25; // 2n+1 number of hostory key frames will be fused into a submap for loop closure

extern const float historyKeyframeFitnessScore = 0.3; // the smaller the better alignment
extern const float globalMapVisualizationSearchRadius = 500.0; // key frames with in n meters will be visualized

自定义 PointTypePose类型指的是具备姿态角的特定点:

struct PointXYZIRPYT
{
	// 该点类型有4个元素
    PCL_ADD_POINT4D
    PCL_ADD_INTENSITY;
    float roll;
    float pitch;
    float yaw;
    double time;
    // 确保new操作符对齐操作
    EIGEN_MAKE_ALIGNED_OPERATOR_NEW
} EIGEN_ALIGN16;// 强制SSE对齐

POINT_CLOUD_REGISTER_POINT_STRUCT (PointXYZIRPYT,
                                   (float, x, x) (float, y, y)
                                   (float, z, z) (float, intensity, intensity)
                                   (float, roll, roll) (float, pitch, pitch) (float, yaw, yaw)
                                   (double, time, time)
)

typedef PointXYZIRPYT  PointTypePose;
### SC-LEGO-LOAM Evo GitHub Project Documentation SC-LeGO-LOAM 是由 KAIST 开源的一个激光雷达里程计建图框架,它结合了 Scan Context LeGO-LOAM 的优点[^3]。SC-LeGO-LOAM 主要用于处理 LiDAR 数据并实现高效的 SLAM 功能。而 SC-LeGO-LOAM Evo 则是对该框架的一种改进版本或者特定应用扩展。 以下是关于 SC-LeGO-LOAM Evo 可能涉及的内容及其相关文档说明: #### 1. **项目背景** SC-LeGO-LOAM Evo 很可能是基于原始 SC-LeGO-LOAM 进一步优化后的版本,可能针对某些硬件设备(如 Ouster 或 Velodyne 激光雷达)进行了适配,并增强了算法性能。其核心功能仍然围绕着 LOAM 家族的核心思想展开——通过特征提取、匹配以及姿态估计完成实时定位与地图构建[^2]。 #### 2. **安装指南** 对于 SC-LeGO-LOAM Evo 的安装过程,可以参考以下步骤: - 修改 `utility.h` 文件中的雷达参数以适应所使用的传感器型号。 - 如果需要运行实际机器人上的系统,则可以在配置文件中调整 RVIZ 显示设置,例如注释掉不必要的可视化话题[^4]。 #### 3. **代码结构分析** 类似于其他 LOAM 类型的项目,SC-LeGO-LOAM Evo 的主要模块通常包括以下几个部分: - **Feature Extraction**: 提取边缘平面点作为关键特征[^1]。 - **Pose Estimation**: 使用 ICP (Iterative Closest Point) 方法或其他优化技术来计算当前帧的姿态变化。 - **Global Map Management**: 构建全局地图并通过回环检测消除累计误差。 #### 4. **依赖项** 为了成功编译部署 SC-LeGO-LOAM Evo,需确保满足以下依赖条件: - ROS (Robot Operating System): 推荐使用 Melodic 或 Noetic 版本。 - PCL (Point Cloud Library): 处理三维点云数据的关键库。 - Eigen: 数学运算支持。 如果遇到任何依赖缺失的情况,请按照官方文档指示逐一解决。 #### 5. **测试环境搭建** 建议在 Ubuntu 虚拟机或真实物理机器上创建独立的工作空间来进行调试。具体操作如下所示: ```bash mkdir -p ~/sc_lego_loam_ws/src && cd ~/sc_lego_loam_ws/src git clone https://github.com/YourRepoNameHere/sc-lego-loam-evo.git . cd .. catkin_make source devel/setup.bash roslaunch sc_lego_loam system_real_robot.launch ``` 上述命令假设您已经克隆了正确的仓库地址;请替换为实际项目的 URL。 ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值