工程(一)Lego_Loam安装调试及运行

2023-11-11 12:50

本文主要是介绍工程(一)Lego_Loam安装调试及运行,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、LeGO _LOAM安装

# 下载gtsam

cd ~
git clone https://bitbucket.org/gtborg/gtsam.git

#编译

cd ~/gtsam
mkdir build
cd build
cmake ..
make check   #可选的,运行单元测试,我没执行这个命令,因为在TX2上编译太慢了,太慢了,太慢了
make install

#下载编译Lego_loam

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
git clone https://github.com/RobustFieldAutonomyLab/LeGO-LOAM.git
cd ..
catkin_make -j1

 当第一次编译代码时,需要在“catkin_make”后面添加“-j1”以生成一些消息类型。将来的编译不需要“-j1”。

编译时出现错误,找不到Cmake文件,则需要在路径中添加相应的环境变量

catkin_make编译错误_weixin_30485291的博客-CSDN博客

Ubuntu下三种方法设置环境变量 - cv_gordon - 博客园

二、运行

运行lego_loam程序

roslaunch lego_loam run.launch

运行数据包

一定要加--clock时间,这样才能生成完整的全局地图

rosbag play 3-1.bag --clock

#转存为PCD文件

在代码建图过程中保存数据

rosbag record -o out /laser_cloud_surround

转化为pcd文件

rosrun pcl_ros bag_to_pcd input.bag /laser_cloud_surround pcd

查看pcd文件

pcl_viewer xxxxxx.pcd

三、LeGO _LOAM调试

utility文件修改

//1、激光雷达选型
// VLP-16
extern const int N_SCAN = 16;
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;//pandar-40
extern const int N_SCAN =40;
extern const int Horizon_SCAN = 1800;
extern const float ang_res_x = 0.2;
extern const float ang_res_y = 0.33;
extern const float ang_bottom = 3.0+0.1;
extern const int groundScanInd = 10;//VLP-64
extern const int N_SCAN = 64;
extern const int Horizon_SCAN = 1800;
extern const float ang_res_x = 0.2;
extern const float ang_res_y = 0.427;
extern const float ang_bottom = 24.9;
extern const int groundScanInd = 20;// 2、特征点提取分割
extern const int edgeFeatureNum = 6;
extern const int surfFeatureNum = 10;
extern const int sectionsTotal = 2;
extern const float edgeThreshold = 0.1;
extern const float surfThreshold = 0.1;
extern const float nearestFeatureSearchSqDist = 25;//3、输入点云类型定义
struct EIGEN_ALIGN16 PointXYZRGBI
{PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4])PCL_ADD_RGB;float intensity;     //intensityEIGEN_MAKE_ALIGNED_OPERATOR_NEW
};POINT_CLOUD_REGISTER_POINT_STRUCT(PointXYZRGBI,(float,x,x)(float,y,y)(float,z,z)(uint8_t,rgb,rgb)(float,intensity,intensity)
)
typedef PointXYZRGBI  PointType;

4. Ubuntu20.04遇到的问题

1、编译错误在CMakelists.txt中添加

set( CMAKE_CXX_STANDARD 14)

2、20.04的openCV自带的是opencv4,所以需要将utility.h中的#include <opencv/cv.h>

#include <opencv2/opencv.hpp>

3、编译不报错,能够正常运行,但不显示地图和轨迹,只看到坐标系移动

原因:ubuntu20.04的rostopic格式更加严格,之前版本/rostopic和rostopic发出消息均是/rostopic。ubuntu20.04/rostopic发出消息是//rostopic。

在mapOptmization.cpp文件中将以下代码中的/camera_init更改为camera_init,去除/

    void publishKeyPosesAndFrames(){if (pubKeyPoses.getNumSubscribers() != 0){sensor_msgs::PointCloud2 cloudMsgTemp;pcl::toROSMsg(*cloudKeyPoses3D, cloudMsgTemp);cloudMsgTemp.header.stamp = ros::Time().fromSec(timeLaserOdometry);cloudMsgTemp.header.frame_id = "/camera_init";pubKeyPoses.publish(cloudMsgTemp);}if (pubRecentKeyFrames.getNumSubscribers() != 0){sensor_msgs::PointCloud2 cloudMsgTemp;pcl::toROSMsg(*laserCloudSurfFromMapDS, cloudMsgTemp);cloudMsgTemp.header.stamp = ros::Time().fromSec(timeLaserOdometry);cloudMsgTemp.header.frame_id = "/camera_init";pubRecentKeyFrames.publish(cloudMsgTemp);}if (pubRegisteredCloud.getNumSubscribers() != 0){pcl::PointCloud<PointType>::Ptr cloudOut(new pcl::PointCloud<PointType>());PointTypePose thisPose6D = trans2PointTypePose(transformTobeMapped);*cloudOut += *transformPointCloud(laserCloudCornerLastDS,  &thisPose6D);*cloudOut += *transformPointCloud(laserCloudSurfTotalLast, &thisPose6D);sensor_msgs::PointCloud2 cloudMsgTemp;pcl::toROSMsg(*cloudOut, cloudMsgTemp);cloudMsgTemp.header.stamp = ros::Time().fromSec(timeLaserOdometry);cloudMsgTemp.header.frame_id = "/camera_init";pubRegisteredCloud.publish(cloudMsgTemp);} }

这篇关于工程(一)Lego_Loam安装调试及运行的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/390184

相关文章

利用Python调试串口的示例代码

《利用Python调试串口的示例代码》在嵌入式开发、物联网设备调试过程中,串口通信是最基础的调试手段本文将带你用Python+ttkbootstrap打造一款高颜值、多功能的串口调试助手,需要的可以了... 目录概述:为什么需要专业的串口调试工具项目架构设计1.1 技术栈选型1.2 关键类说明1.3 线程模

最详细安装 PostgreSQL方法及常见问题解决

《最详细安装PostgreSQL方法及常见问题解决》:本文主要介绍最详细安装PostgreSQL方法及常见问题解决,介绍了在Windows系统上安装PostgreSQL及Linux系统上安装Po... 目录一、在 Windows 系统上安装 PostgreSQL1. 下载 PostgreSQL 安装包2.

Python如何精准判断某个进程是否在运行

《Python如何精准判断某个进程是否在运行》这篇文章主要为大家详细介绍了Python如何精准判断某个进程是否在运行,本文为大家整理了3种方法并进行了对比,有需要的小伙伴可以跟随小编一起学习一下... 目录一、为什么需要判断进程是否存在二、方法1:用psutil库(推荐)三、方法2:用os.system调用

Maven如何手动安装依赖到本地仓库

《Maven如何手动安装依赖到本地仓库》:本文主要介绍Maven如何手动安装依赖到本地仓库问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、下载依赖二、安装 JAR 文件到本地仓库三、验证安装四、在项目中使用该依赖1、注意事项2、额外提示总结一、下载依赖登

Python运行中频繁出现Restart提示的解决办法

《Python运行中频繁出现Restart提示的解决办法》在编程的世界里,遇到各种奇怪的问题是家常便饭,但是,当你的Python程序在运行过程中频繁出现“Restart”提示时,这可能不仅仅是令人头疼... 目录问题描述代码示例无限循环递归调用内存泄漏解决方案1. 检查代码逻辑无限循环递归调用内存泄漏2.

如何在Mac上安装并配置JDK环境变量详细步骤

《如何在Mac上安装并配置JDK环境变量详细步骤》:本文主要介绍如何在Mac上安装并配置JDK环境变量详细步骤,包括下载JDK、安装JDK、配置环境变量、验证JDK配置以及可选地设置PowerSh... 目录步骤 1:下载JDK步骤 2:安装JDK步骤 3:配置环境变量1. 编辑~/.zshrc(对于zsh

如何在pycharm安装torch包

《如何在pycharm安装torch包》:本文主要介绍如何在pycharm安装torch包方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录在pycharm安装torch包适http://www.chinasem.cn配于我电脑的指令为适用的torch包为总结在p

在PyCharm中安装PyTorch、torchvision和OpenCV详解

《在PyCharm中安装PyTorch、torchvision和OpenCV详解》:本文主要介绍在PyCharm中安装PyTorch、torchvision和OpenCV方式,具有很好的参考价值,... 目录PyCharm安装PyTorch、torchvision和OpenCV安装python安装PyTor

Python Transformer 库安装配置及使用方法

《PythonTransformer库安装配置及使用方法》HuggingFaceTransformers是自然语言处理(NLP)领域最流行的开源库之一,支持基于Transformer架构的预训练模... 目录python 中的 Transformer 库及使用方法一、库的概述二、安装与配置三、基础使用:Pi

如何解决mmcv无法安装或安装之后报错问题

《如何解决mmcv无法安装或安装之后报错问题》:本文主要介绍如何解决mmcv无法安装或安装之后报错问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录mmcv无法安装或安装之后报错问题1.当我们运行YOwww.chinasem.cnLO时遇到2.找到下图所示这里3.