系统:
ubuntu: | Description: Ubuntu 18.04.6 LTS
architecture: | 64-bit
gcc: | gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
cmake: | cmake version 3.10.2 CMake suite maintained and supported by Kitware (kitware.com/cmake).
ros-melodic
查看系统及软件版本脚本参考:https://blog.csdn.net/BIT_HXZ/article/details/125120168
cd xx/LT_mapper_ws/src
git clone https://github.com/gisbi-kim/lt-mapper.git
catkin_make
/home/meng/subject/LT_mapper_ws/src/lt-mapper/ltslam/include/ltslam/utility.h:88:10: fatal error: filesystem: 没有那个文件或目录
#include // requires gcc version >= 8
/home/meng/subject/LT_mapper_ws/src/lt-mapper/ltremovert/include/removert/utility.h:70:10: fatal error: filesystem: 没有那个文件或目录
#include // requires gcc version >= 8
#include
替换#include
参考:https://stackoverflow.com/questions/39231363/fatal-error-filesystem-no-such-file-or-directory
发现还是报错,报错如下:
/home/meng/subject/LT_mapper_ws/src/lt-mapper/ltremovert/include/removert/utility.h:73:21: error: ‘filesystem’ is not a namespace-name
namespace fs = std::filesystem;
^~~~~~~~~~
/home/meng/subject/LT_mapper_ws/src/lt-mapper/ltremovert/include/removert/utility.h:73:31: error: expected namespace-name before ‘;’ token
namespace fs = std::filesystem;
--------------
/home/meng/subject/LT_mapper_ws/src/lt-mapper/ltremovert/src/Session.cpp:87:24: error: ‘fs’ has not been declared
for(auto& _entry : fs::directory_iterator(_scan_dir)) {
--------------
/home/meng/subject/LT_mapper_ws/src/lt-mapper/ltremovert/src/Removerter.cpp:8:10: error: ‘fs’ has not been declared
if (!fs::is_directory(_path) || !fs::exists(_path))
解决思路与解决方案,按上面的报错逻辑来看,应该是filesystem
这个命令空间及空间内的函数没有引用对,前面不是用#include
替换#include
嘛,这里也尝试用替换如下所示,这里仅仅修改下面的位置:
// namespace fs = std::filesystem;
namespace fs = std::experimental::filesystem;//hxz
编译通过
cd xx/LT_mapper_ws/src
git clone https://github.com/irapkaist/file_player_mulran.git
catkin_make
cd xx/LT_mapper_ws/src
git clone https://github.com/gisbi-kim/SC-LIO-SAM.git
catkin_make
github地址:https://github.com/CloudCompare/CloudCompare
安装参考:https://blog.csdn.net/magic_ll/article/details/120780593
sudo apt-get update
sudo apt install snap
sudo snap install cloudcompare
cloudcompare.CloudCompare
loudcompare.ccViewer
sudo snap remove cloudcompare
LT-mapper ParkingLot 数据集包含在三天内的六个序列,用于同一空间地点,但初始姿势不同。LT-SLAM 自动将它们对齐在共享坐标中。
下载链接:https://drive.google.com/drive/folders/1FNIU691AR2g04NlKBFCDL4APpxpzkfQp
全部下载即可
下载如下:
解压到任意一个文件夹,这里命名为data文件夹下:
cd xx/LT_mapper_ws
source devel/setup.bash
roslaunch file_player file_player.launch
点击load,加载数据:
点击play会播放话题,点击end会结束播放话题
需要设置文件保存路径:
修改:xx/LT_mapper_ws/src/SC-LIO-SAM/SC-LIO-SAM/config/params_mulran.yaml 文件内路径为自己创建的路径:
# savePCDDirectory: "/home/user/Desktop/scliosam/data/" # use global path, and end with "/"
savePCDDirectory: "/media/meng/T7/dataset/LT_mapper/data_parsed/01/" # use global path, and end with "/"
启动lio-sam:
cd xx/LT_mapper_ws
source devel/setup.bash
roslaunch lio_sam run_mulran.launch
第一次启动可能会遇到这个,应该不影响:
接着发布话题数据:
cd xx/LT_mapper_ws
source devel/setup.bash
roslaunch file_player file_player.launch
效果如下,如果rviz不显示,可以再启动一次run_mulran.launch
;如果中间出现定位崩了,重新启动上面两个launch
批量化查看pcd文件:https://blog.csdn.net/BIT_HXZ/article/details/122090880
01和02数据起点具有不同的位姿。
参考上面的操作,重新来一遍。效果如下:
打开cloudcompare软件,终端输入:
cloudcompare.CloudCompare
将01、02数据的trajectory.pcd
文件用cloudcompare软件打开,进行轨迹比较
可以看出,01和02的起始位姿不同,所以轨迹并没有对齐。
注:如果trajectory.pcd
文件在外接硬盘上,我这里在三星T7硬盘上,直接用cloudcompare打开会出现包权限不允许的错误,如下所示:
[pcl::PCDReader::readHeader] Could not open file '/media/meng/T7/dataset/LT_mapper/data_parsed/01/trajectory.pcd'! Error : Permission denied
[pcl::PassThrough::applyFilter] Input dataset doesn't have x-y-z coordinates!
解决办法为将两个trajectory.pcd
文件复制到自己电脑硬盘的文件加下,如/home/Desktop/
。
指定需要对齐数据序列的路径,打开xx/LT_mapper_ws/src/lt-mapper/ltslam/config/params.yaml
,修改对应路径,下面的修改应该是让02数据的轨迹向01数据对齐
ltslam:
# sessions_dir: "/home/user/Documents/catkin2021/catkin_LTslam/data_kitti/in/" # end with /
sessions_dir: "/media/meng/T7/dataset/LT_mapper/data_parsed/" # end with / ###hxz
central_sess_name: "01" # should be same as the directory name of that session ##hxz
query_sess_name: "02" # should be same as the directory name of that session ##hxz
# save_directory: "/home/user/Documents/catkin2021/catkin_LTslam/data_kitti/out/011-02-manyloops/" # end with "/"
save_directory: "/media/meng/T7/dataset/LT_mapper/data_ltslam/0102/" # end with "/" ##hxz
is_display_debug_msgs: false
loopFitnessScoreThreshold: 0.7
kNumSCLoopsUpperBound: 1000 # if you use an enough number, use all the detected loops
kNumRSLoopsUpperBound: 0 # if you use an enough number, use all the detected loops
numberOfCores: 16 # currently hard-coded in the utility.cpp
cd xx/LT_mapper_ws
source devel/setup.bash
roslaunch ltslam run.launch
LT-SLAM首先检测并缝合(detect and sticth)基于背景扫描的回环(scan context-based loops),并得到大致的初始位姿转换。然后,使用基于半径(radius-search)的搜索精细地缝合两个轨迹。
最终输出:
/media/meng/T7/dataset/LT_mapper/data_ltslam/0102/01_central_aft_intersession_loops.txt
/media/meng/T7/dataset/LT_mapper/data_ltslam/0102/02_central_aft_intersession_loops.txt
注意:上一步得到的最终文件01_central_aft_intersession_loops.txt
和02_central_aft_intersession_loops.txt
如果在移动硬盘上,也需要移动到电脑本机硬盘上,否则可能打不开或打开失败。
直接拖如cloudcompare软件即可。
调整第1、4、8、12列的属性,点击apply all(这样拖入另一个txt时就不用调整了)
发现01和02数据对应的轨迹被很好地对齐了。
注:python环境:python3.7,之前配置的环境:https://blog.csdn.net/BIT_HXZ/article/details/123444769
注:出现报错查看目录3 找到对应的报错
分别将01_central_aft_intersession_loops.txt
和02_central_aft_intersession_loops.txt
放在xx/data_parsed/01
和xx/data_parsed/02
下
使用SL-LIO-SLAM的python工具xx/LT_mapper_ws/src/SC-LIO-SAM/SC-LIO-SAM/tools/python/makeMergedMap.py
,修改该py文件的下面4处:
# data_dir = "/home/user/Desktop/data/scliosam/mytest1/" # should end with /
# scan_idx_range_to_stack = [0, 100] # if you want a whole map, use [0, len(scan_files)]
data_dir = "/media/meng/T7/dataset/LT_mapper/data_parsed/01/" # should end with / ##hxz
scan_idx_range_to_stack = [0, 571] # if you want a whole map, use [0, len(scan_files)] ##hxz
# f = open(data_dir+"optimized_poses.txt", 'r') ##hxz
f = open(data_dir+"01_central_aft_intersession_loops.txt", 'r')
# if( nodes_count % node_skip is not 0):
if( nodes_count % node_skip != 0): ##hxz
第4行的571是Scans
文件夹里面的项目数目
终端输入:
cd xx/LT_mapper_ws/src/SC-LIO-SAM/SC-LIO-SAM/tools/python
python3 makeMergedMap.py
open3d中鼠标滚轮前滑是缩小,后滑是放大,按住滚轮移动鼠标是移动,鼠标左键可以移动视角
同样,针对02数据,修改xx/LT_mapper_ws/src/SC-LIO-SAM/SC-LIO-SAM/tools/python/makeMergedMap.py
中对应位置,参考如上,输入命令python3 makeMergedMap.py
直接看的话,需要放大才可以看出区别
现在我们得到了在相同坐标系下的两个点云地图
运行python3 makeMergedMap.py
时,在程序执行到保存pcd地图阶段时可能会报错:三个报错对应三个位置,相应修改如下。
TypeError: sequence item 0: expected str instance, bytes found
# uncompressed = ''.join(uncompressed_lst)
uncompressed = ''.join(str(uncompressed_lst)) #hxz
TypeError: write() argument must be str, not bytes
# fileobj.write(struct.pack(fmt, compressed_size, uncompressed_size))
fileobj.write(str(struct.pack(fmt, compressed_size, uncompressed_size)) ) ##hxz
TypeError: write() argument must be str, not bytes
# fileobj.write(buf)
fileobj.write(str(buf)) ##hxz
makeMergedMap.py
文件中保存pcd的相关代码如下
最终01和02序列数据分别得到:map_0_to_609_with_intensity.pcd
、map_0_to_571_with_intensity.pcd
,但二者都比较大
数据量比较大,暂时先不再ubuntu下用cloudcompare打开,如果用cloudcompare打开会报错,如下所示:
[pcl::PCDReader::read] The estimated cloud.data size (377341728) is different than the saved uncompressed value (1550071928)! Data corruption?
[pcl::PCDReader::read] Size of decompressed lzf data (0) does not match value stored in PCD header (1550071928). Errno: 22
注:如果可以打开比较观察,会发现有动态鬼点和较小的偏移,在使用LT-removert
处理完动态鬼点后,LT-removert
通过检查变化进行偏差对齐
ModuleNotFoundError: No module named 'pypcd'
解决步骤:
pip install pypcd
我这里pypcd.py文件安装在/home/meng/anaconda3/envs/yolov5py37/lib/python3.7/site-packages/pypcd/pypcd.py
下面这个github代码针对篇pypcd在python3.x版本上的兼容性,写了针对python3.6的版本的pypcd,感谢感谢感谢。
https://github.com/weidezhang/pypcd_python3.6
将上面pip安装的/home/meng/anaconda3/envs/yolov5py37/lib/python3.7/site-packages/pypcd/pypcd.py
备份后直接全部替换,备份参考命令如下:
cp /home/meng/anaconda3/envs/yolov5py37/lib/python3.7/site-packages/pypcd/pypcd.py /home/meng/anaconda3/envs/yolov5py37/lib/python3.7/site-packages/pypcd/pypcd.py.old
ModuleNotFoundError: No module named 'cStringIO'
原因在于python3.X已经取消了cStringIO模块,但是可以在io模块中找到StringIO。参考:https://blog.csdn.net/S20144144/article/details/100518249
gedit /home/meng/anaconda3/envs/yolov5py37/lib/python3.7/site-packages/pypcd/pypcd.py
观察pypcd.py
文件,相关调用函数的语句如下所示:
fileobj = sio.StringIO(buf)
--------------
fileobj = sio.StringIO()
且StringIO()函数在python3中在io头文件中,故修改如下:
# import cStringIO as sio
import io as sio #hxz
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
参考:https://github.com/ansible/tower-cli/issues/300
修改如下:
# if ln.startswith('DATA'):
if ln.startswith(b'DATA'): ##hxz
# if ln.startswith('#') or len(ln) < 2:
if ln.startswith(b'#') or len(ln) < 2: ##hxz
TypeError: cannot use a string pattern on a bytes-like object
修改如下:
# match = re.match('(\w+)\s+([\w\s\.]+)', ln)
match = re.match('(\w+)\s+([\w\s\.]+)'.decode('utf-8'), ln) ##hxz
ModuleNotFoundError: No module named 'open3d'
(注:之前尝试时,在python3.10
的环境下一直安装不进去open3d
,调整为python3.7
环境就安装进去了。)
直接安装:pip install open3d
ERROR: Could not find a version that satisfies the requirement open3d (from versions: none)
ERROR: No matching distribution found for open3d
使用conda安装:
conda install open3d
报错:
PackagesNotFoundError: The following packages are not available from current channels:
到anaconda(https://anaconda.org/) 查看open3d这个包的下载链接:
输入命令:
conda install -c open3d-admin open3d
,安装成功
ModuleNotFoundError: No module named 'addict'
pip install addict