复现YOLO_ORB_SLAM3_with_pointcloud_map项目记录


1.环境问题

首先环境大家就按照github上的指定环境安装即可
在这里插入图片描述
环境怎么安装网上大把的资源,自己去找。

2.遇到的问题

2.1编译问题1 monotonic_clock

在这里插入图片描述
这是因为C++版本不同导致的系统计时函数编译报错
解决方案是 搜索COMPILEDWITHC11
然后把monotonic_clock 换成 steady_clock
例如:

/*
#ifdef COMPILEDWITHC11
            std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();
#else
            std::chrono::monotonic_clock::time_point t1 = std::chrono::monotonic_clock::now();
#endif
*/
// 替换成下面的:
	std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();//修改替换的代码部分

这个问题会报很多次,至少十几次吧,因为很多文件都有这个东西,他报错了我们根据报错位置去改就可以了,就是比较麻烦。

当然我看到有人说只需要把COMPILEDWITHC11改为COMPILEDWITHC14就可以了,这个我没有尝试,我只用了上面的方法,大家可以自己尝试。

2.2 associate.py

数据集的下载地址:https://cvg.cit.tum.de/data/datasets/rgbd-dataset/download
在这里插入图片描述

associate.py是个啥,这个东西怎么用
这个就是把数据集转化成一个文件的东西
链接: 怎么用看这个

1.按照要求下载数据集,我下载的是rgbd_dataset_freiburg3_walking_xyz,将其解压到你喜欢的目录.我个人放在了evalution下

2.下载 associate.py.放在evalution目录下面.
在这里插入图片描述

3.打开终端,进入到associate.py所在目录
在这里插入图片描述

python associate.py rgb.txt depth.txt > associations.txt

4.命令解说

./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUMX.yaml PATH_TO_SEQUENCE_FOLDER ASSOCIATIONS_FILE

PATH_TO_SEQUENCE_FOLDER文件夹即为数据库所在文件夹,我的是在orbslam2工程下面,
ASSOCIATIONS_FILE即为第3步中生成的associations.txt,给出他的制定目录位置
例子:大家可以参考我的目录自行更改!

./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUM1.yaml /home/lvslam/YOLO_ORB_SLAM3_with_pointcloud_map/evaluation/rgbd_dataset_freiburg3_walking_xyz /home/lvslam/YOLO_ORB_SLAM3_with_pointcloud_map/evaluation/rgbd_dataset_freiburg3_walking_xyz/associations.txt 

2.3 associate.py问题

问题1:报错AttributeError: ‘dict_keys’ object has no attribute ‘remove’
由于Python2和python3语法的差别,需要将associate.py中第86行87行的

    first_keys = first_list.keys()
    second_keys = second_list.keys()

改为

    first_keys = list(first_list.keys())
    second_keys = list(second_list.keys())

问题2:TypeError: read_file_list() takes exactly 2 arguments (1 given)
所遇到的问题是因为read_file_list()函数需要两个参数,而你在调用时只传递了一个参数。我们需要向read_file_list()传递两个参数,即args.first_file和remove_bounds。从代码来看,remove_bounds应该是一个布尔值,具体是True还是False,可以根据需求来设定。
我们需要修改associate.py
改为:

import argparse
import sys
import os
import numpy


def read_file_list(filename, remove_bounds):
    """
    Reads a trajectory from a text file. 
    
    File format:
    The file format is "stamp d1 d2 d3 ...", where stamp denotes the time stamp (to be matched)
    and "d1 d2 d3.." is arbitary data (e.g., a 3D position and 3D orientation) associated to this timestamp. 
    
    Input:
    filename -- File name
    
    Output:
    dict -- dictionary of (stamp,data) tuples
    
    """
    file = open(filename)
    data = file.read()
    lines = data.replace(",", " ").replace("\t", " ").split("\n")
    if remove_bounds:
        lines = lines[100:-100]
    list = [[v.strip() for v in line.split(" ") if v.strip() != ""] for line in lines if len(line) > 0 and line[0] != "#"]
    list = [(float(l[0]), l[1:]) for l in list if len(l) > 1]
    return dict(list)


def associate(first_list, second_list, offset, max_difference):
    """
    Associate two dictionaries of (stamp,data). As the time stamps never match exactly, we aim 
    to find the closest match for every input tuple.
    
    Input:
    first_list -- first dictionary of (stamp,data) tuples
    second_list -- second dictionary of (stamp,data) tuples
    offset -- time offset between both dictionaries (e.g., to model the delay between the sensors)
    max_difference -- search radius for candidate generation

    Output:
    matches -- list of matched tuples ((stamp1,data1),(stamp2,data2))
    
    """
    first_keys = list(first_list.keys())
    second_keys = list(second_list.keys())
    potential_matches = [(abs(a - (b + offset)), a, b)
                         for a in first_keys
                         for b in second_keys
                         if abs(a - (b + offset)) < max_difference]
    potential_matches.sort()
    matches = []
    for diff, a, b in potential_matches:
        if a in first_keys and b in second_keys:
            first_keys.remove(a)
            second_keys.remove(b)
            matches.append((a, b))

    matches.sort()
    return matches


if __name__ == '__main__':
    # parse command line
    parser = argparse.ArgumentParser(description='''
    This script takes two data files with timestamps and associates them   
    ''')
    parser.add_argument('first_file', help='first text file (format: timestamp data)')
    parser.add_argument('second_file', help='second text file (format: timestamp data)')
    parser.add_argument('--first_only', help='only output associated lines from first file', action='store_true')
    parser.add_argument('--offset', help='time offset added to the timestamps of the second file (default: 0.0)', default=0.0)
    parser.add_argument('--max_difference', help='maximally allowed time difference for matching entries (default: 0.02)', default=0.02)
    parser.add_argument('--remove_bounds', help='remove first and last 100 entries', action='store_true')
    args = parser.parse_args()

    first_list = read_file_list(args.first_file, args.remove_bounds)
    second_list = read_file_list(args.second_file, args.remove_bounds)

    matches = associate(first_list, second_list, float(args.offset), float(args.max_difference))

    if args.first_only:
        for a, b in matches:
            print("%f %s" % (a, " ".join(first_list[a])))
    else:
        for a, b in matches:
            print("%f %s %f %s" % (a, " ".join(first_list[a]), b - float(args.offset), " ".join(second_list[b])))

3.运行问题

rgbd_tum: /tmp/llvm/lib/Support/BranchProbability.cpp:41:llvm::BranchProbability::BranchProbability(uint32_t, uint32_t): 假设 ‘Numerator <= Denominator && “Probability cannot be bigger than 1!”’ 失败。
已放弃 (核心已转储)
在这里插入图片描述
在这里插入图片描述
运行出来两秒就闪退的问题!
切换刚开始的libtorch版本
https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.3.1%2Bcpu.zip
这个时2.3.1版本的,我们只需要将上面的数字换掉,然后直接浏览器粘贴就可以下对对应的版本!!

经过测试使用1.7.1版本的libtorch可以解决这个问题
也就是
https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.7.1%2Bcpu.zip
重新安装号新的1.7.1版本的libtorch后重新编译,./build.sh
又会遇到下面的问题:
version `GOMP_4.5’ not found (required by /lib/x86_64-linux-gnu/libpcl_common.so.1.10)

在这里插入图片描述
我们需要链接动态库解决这个问题:

ln -sf /usr/lib/x86_64-linux-gnu/libgomp.so.1 /YOLO_ORB_SLAM3_with_pointcloud_map/Thirdparty/libtorch/lib/libgomp-75eea7e8.so.1

之后应该就是可以运行了,不过有可能有人会碰到别的问题
之后如果报错:libORB_SLAM3.so: undefined symbol: _ZN5DBoW24FORB1LE,查看下面的博客就可以
https://blog.csdn.net/qq_41035283/article/details/128301376

然后我们就成功复现这个项目了!!!!
在这里插入图片描述

评论 19
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Chris·Bosh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值