ROS工作空间内利用rgbd_dataset_freiburg2_pioneer_360数据集配置ORB_SLAM2

本文主要是介绍ROS工作空间内利用rgbd_dataset_freiburg2_pioneer_360数据集配置ORB_SLAM2,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

ORB-SLAM2官方教程
一、准备工作:安装第三方依赖库
本人的依赖库均存放在文档目录里
在这里插入图片描述

1、安装Eigen

sudo apt install libeigen3-dev

在这里插入图片描述

2、安装Pangolin

git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
sudo apt install libgl1-mesa-dev libglew-dev cmake
sudo apt install libpython2.7-dev python-pip
git submodule init && git submodule update
sudo python -mpip install numpy pyopengl Pillow pybind11
sudo apt install pkg-config
sudo apt install libegl1-mesa-dev libwayland-dev libxkbcommon-dev wayland-protocols
mkdir build
cd build
cmake ..
cmake --build .
sudo make install

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3、安装Sophus

git clone https://github.com/strasdat/Sophus.git
cd Sophus
git checkout a621ff
mkdir build
cd build
cmake ..
make

在这里插入图片描述
在这里插入图片描述
报错问题:
在make过程中会出现如下的错误,需要修改Sophus/sophus中的so2.cpp文件,之后重新make即可
在这里插入图片描述
在这里插入图片描述

4、安装OpenCV

git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 3.4.3
sudo apt install build-essential
sudo apt install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

在这里插入图片描述
在这里插入图片描述
报错问题:
在安装相关依赖时可能会出现如下错误,执行下面的命令:
在这里插入图片描述

sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
接前面的步骤→

mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j8
sudo make install

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
报错问题:
在make -j8过程中会出现如下的错误,需要修改gen_java.py中的文件,之后重新make即可
在这里插入图片描述
在这里插入图片描述

修改内容:assert path[-3:]!=’.in’,path修改为assert path[-4:]!=’.in’,path
重新编译后如果还报错,将f.wrtite(buf)修改为f.write(buf.encode(‘utf-8’))

5、安装PCL

sudo apt install libpcl-dev
sudo apt install pcl-tools

在这里插入图片描述

6、安装Ceres Solver

git clone https://github.com/ceres-solver/ceres-solver.git
cd ceres-solver
sudo apt install cmake libeigen3-dev
sudo apt install libgoogle-glog-dev libatlas-base-dev libsuitesparse-dev
mkdir build
cd build
cmake ..
make -j4
sudo make install

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述在这里插入图片描述

7、安装g2o

git clone https://github.com/RainerKuemmerle/g2o.git
cd g2o
sudo apt install cmake libeigen3-dev
sudo apt install libsuitesparse-dev qtdeclarative5-dev qt5-qmake libqglviewer-dev

在这里插入图片描述
在这里插入图片描述

报错问题:
在安装相关依赖时可能会出现E:软件包libqglviewer-dev没有可安装候选的错误,执行下面的命令:

apt-cache search libqglviewer-dev
sudo apt-get install libqglviewer-dev-qt5

在这里插入图片描述
接前面的步骤→

mkdir build
cd build
cmake ..
make -j4
sudo make install

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

二、构建ORB-SLAM2库和示例
因为后期会将ORB_SLAM2和ROS关联运行,所以下述代码均存放在ros工作空间catkin_ws/src目录下进行相关测试,测试内容并没有涉及ROS相关功能,可以看成一个普通的文件夹
1、构建ORB-SLAM2库和示例

git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
cd ORB_SLAM2 && chmod +x build.sh && ./build.sh

在这里插入图片描述

在编译过程中可能会出现的问题及解决方案:
(1)
问题:error: ‘usleep’ was not declared in this scope usleep(3000)
在这里插入图片描述
解决:在如下的文件中的头文件上分别加上#include<unistd.h>
ORB_SLAM2/src/LocalMapping.cc
ORB_SLAM2/src/LoopClosing.cc
ORB_SLAM2/src/System.cc
ORB_SLAM2/src/Tracking.cc
ORB_SLAM2/src/Viewer.cc
ORB_SLAM2/Examples/Monocular/mono_euroc.cc
ORB_SLAM2/Examples/Monocular/mono_kitti.cc
ORB_SLAM2/Examples/Monocular/mono_tum.cc
ORB_SLAM2/Examples/RGB-D/rgbd_tum.cc
ORB_SLAM2/Examples/Stereo/stereo_euroc.cc
ORB_SLAM2/Examples/Stereo/stereo_kitti.cc
在这里插入图片描述
在这里插入图片描述
(2)
问题:CMakeFiles/Stereo.dir/build.make:227:recipe for target ‘…/Stereo’ failed
CMakeFiles/RGBD.dir/build.make:197: recipe for target ‘…/RGBD’ failed
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/RGBD.dir/all’ failed
CMakeFiles/Makefile2:104:recipe for target ‘CMakeFiles/Stereo.dir/all’ failed
解决:把ORB_SLAM2/Examples/ROS/ORB_SLAM2/文件夹下的CMakeLists.txt文件进行修改,在set(LIBS的最后加上-lboost_system
在这里插入图片描述
(3)
问题:ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/AR/ViewerAR.cc:233:9: error: ‘usleep’ was not declared in this scope usleep(mT*1000)
解决:在文件ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/AR/ViewerAR.cc开始处加上#include<unistd.h>
在这里插入图片描述

2、下载公开数据集
以rgbd_dataset_freiburg2_pioneer_360为例,从TUM下载压缩包,后解压到ORB_SLAM2/data文件夹中

cd ORB_SLAM2
mkdir data
cd data
tar zxvf rgbd_dataset_freiburg2_pioneer_360.tgz

在这里插入图片描述

3、下载associate.py测试工具放在orb_slam2/Examples/RGB-D/目录下面

cd ..
cd Example/RGB-D

associate.py中的详细内容如下:

#!/usr/bin/python
# Software License Agreement (BSD License)
#
# Copyright (c) 2013, Juergen Sturm, TUM
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
#  * Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#  * Redistributions in binary form must reproduce the above
#    copyright notice, this list of conditions and the following
#    disclaimer in the documentation and/or other materials provided
#    with the distribution.
#  * Neither the name of TUM nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Requirements: 
# sudo apt-get install python-argparse"""
The Kinect provides the color and depth images in an un-synchronized way. This means that the set of time stamps from the color images do not intersect with those of the depth images. Therefore, we need some way of associating color images to depth images.For this purpose, you can use the ''associate.py'' script. It reads the time stamps from the rgb.txt file and the depth.txt file, and joins them by finding the best matches.
"""import argparse
import sys
import os
import numpydef read_file_list(filename):"""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 nameOutput:dict -- dictionary of (stamp,data) tuples"""file = open(filename)data = file.read()lines = data.replace(","," ").replace("\t"," ").split("\n") 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) tuplessecond_list -- second dictionary of (stamp,data) tuplesoffset -- time offset between both dictionaries (e.g., to model the delay between the sensors)max_difference -- search radius for candidate generationOutput:matches -- list of matched tuples ((stamp1,data1),(stamp2,data2))"""first_keys = first_list.keys()second_keys = 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 matchesif __name__ == '__main__':# parse command lineparser = 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)args = parser.parse_args()first_list = read_file_list(args.first_file)second_list = read_file_list(args.second_file)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])))           

4、运行时间戳关联函数associate.py
目的是将rgb 图像序列和depth深度图的序列,进行时间上的关联。运行结束后,orb_slam2/Examples/RGB-D/目录下面会生成associations.txt文件。

python associate.py ../../data/rgbd_dataset_freiburg2_pioneer_360/rgb.txt ../../data/rgbd_dataset_freiburg2_pioneer_360/depth.txt > associations.txt

5、运行ORB_SLAM2
在ORB_SLAM2主目录上运行执行指令

cd ..
cd ..
./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUM2.yaml data/rgbd_dataset_freiburg2_pioneer_360 Examples/RGB-D/associations.txt

在这里插入图片描述
在这里插入图片描述

这篇关于ROS工作空间内利用rgbd_dataset_freiburg2_pioneer_360数据集配置ORB_SLAM2的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



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

相关文章

找完工作该补充的东西

首先: 锻炼身体,包括乒乓球,羽毛球,都必须练习,学习,锻炼身体等是一个很重要的与人交际沟通的方式; 打牌,娱乐:会玩是一个人很重要的交际沟通的法宝; 摄影:这个是一个兴趣爱好,也是提高自己的审美,生活品质,当然也是与人沟通的重要途径; 做饭:这个的话就是对自己,对朋友非常有益的一件事情;

Linux 安装、配置Tomcat 的HTTPS

Linux 安装 、配置Tomcat的HTTPS 安装Tomcat 这里选择的是 tomcat 10.X ,需要Java 11及更高版本 Binary Distributions ->Core->选择 tar.gz包 下载、上传到内网服务器 /opt 目录tar -xzf 解压将解压的根目录改名为 tomat-10 并移动到 /opt 下, 形成个人习惯的路径 /opt/tomcat-10

uniapp接入微信小程序原生代码配置方案(优化版)

uniapp项目需要把微信小程序原生语法的功能代码嵌套过来,无需把原生代码转换为uniapp,可以配置拷贝的方式集成过来 1、拷贝代码包到src目录 2、vue.config.js中配置原生代码包直接拷贝到编译目录中 3、pages.json中配置分包目录,原生入口组件的路径 4、manifest.json中配置分包,使用原生组件 5、需要把原生代码包里的页面修改成组件的方

IDEA配置Tomcat远程调试

因为不想把本地的Tomcat配置改乱或者多人开发项目想测试,本文主要是记录一下,IDEA使用Tomcat远程调试的配置过程,免得一段时间不去配置到时候忘记(毕竟这次是因为忘了,所以才打算记录的…) 首先在catalina.sh添加以下内容 JAVA_OPTS="-Dcom.sun.management.jmxremote=-Dcom.sun.management.jmxremote.port

【服务器运维】MySQL数据存储至数据盘

查看磁盘及分区 [root@MySQL tmp]# fdisk -lDisk /dev/sda: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical)

工作流Activiti初体验—流程撤回【二】

已经玩工作流了,打算还是研究一下撤回的功能。但是流程图里面并不带撤回的组件,所以需要自己动态改造一下,还是延续上一个流程继续试验撤回功能。《工作流Activiti初体验【一】》 完整流程图 我们研究一下分发任务撤回到发起任务,其他环节的撤回类似 撤回的原理大概如下: 将分发任务后面的方向清空,把发起任务拼接到原来的判断网关,然后结束分发任务,这样流程就到发起任务了 此时的流程如上图,

工作流Activiti初体验【一】

在这里记录一下我的Activiti历程:(以下示例不涉及真实业务,所有逻辑均建立在学习的基础上) bpmn图 发起任务我设置了一个权限组user1,只要是这个权限的用户都可以发起任务 分发任务我设置了一个用户组,用户组中每个用户都可以处理这步流程,只要有一个人处理这步任务,分发的流程就算结束了 分发任务这一环节还有个判断,允许任务下发和不允许任务下发 任务分发完成则来到子流程,每个被分

ROS话题通信流程自定义数据格式

ROS话题通信流程自定义数据格式 需求流程实现步骤定义msg文件编辑配置文件编译 在 ROS 通信协议中,数据载体是一个较为重要组成部分,ROS 中通过 std_msgs 封装了一些原生的数据类型,比如:String、Int32、Int64、Char、Bool、Empty… 但是,这些数据一般只包含一个 data 字段,结构的单一意味着功能上的局限性,当传输一些复杂的数据,比如:

SQL Server中,查询数据库中有多少个表,以及数据库其余类型数据统计查询

sqlserver查询数据库中有多少个表 sql server 数表:select count(1) from sysobjects where xtype='U'数视图:select count(1) from sysobjects where xtype='V'数存储过程select count(1) from sysobjects where xtype='P' SE

Steam邮件推送内容有哪些?配置教程详解!

Steam邮件推送功能是否安全?如何个性化邮件推送内容? Steam作为全球最大的数字游戏分发平台之一,不仅提供了海量的游戏资源,还通过邮件推送为用户提供最新的游戏信息、促销活动和个性化推荐。AokSend将详细介绍Steam邮件推送的主要内容。 Steam邮件推送:促销优惠 每当平台举办大型促销活动,如夏季促销、冬季促销、黑色星期五等,用户都会收到邮件通知。这些邮件详细列出了打折游戏、