SLAM14讲-第二版-ch4-安装Sophus库-评估轨迹误差-Ubuntu20.04

1. 查询Eigen版本

vim /usr/include/eigen3/Eigen/src/Core/util/Macros.h 

在这里插入图片描述
Eigen版本是3.3.7

2.安装Sophus库

2.1安装fmt

git clone  https://github.com/fmtlib/fmt.git
cd fmt
mkdir build
cd build
cmake ..
make
sudo make install

2.2安装Sophus

git clone https://github.com/strasdat/Sophus.git
cd Sophus/

mkdir build
cd build
cmake ..
make
sudo make install

参考链接安装Sophus库

3.原文件目录

ch4--->example--->CMakeLists.txt
			  --->estimated.txt
			  --->groundtruth.txt
			  --->trajectoryError.cpp
	--->CMakeLists.txt
	--->useSophus.cpp

4.修改文件内容

4.1 ch4 —> CMakeLists.txt
添加内容

include_directories(${Sophus_INCLUDE_DIRS})

整体内容

cmake_minimum_required(VERSION 3.0)
project(useSophus)

# 为使用 sophus,需要使用find_package命令找到它
find_package(Sophus REQUIRED)
include_directories(${Sophus_INCLUDE_DIRS})
# Eigen
include_directories("/usr/include/eigen3")
add_executable(useSophus useSophus.cpp)
target_link_libraries(useSophus Sophus::Sophus)

add_subdirectory(example)

4.2 ch4—>example—>CMakeLists.txt
整体修改后的内容

#option(USE_UBUNTU_20 "Set to ON if you are using Ubuntu 20.04" OFF)
find_package(Pangolin REQUIRED)
find_package(fmt REQUIRED)
set(FMT_LIBRARIES fmt::fmt)
#if(USE_UBUNTU_20)
#    message("You are using Ubuntu 20.04, fmt::fmt will be linked")
#    find_package(fmt REQUIRED)
#    set(FMT_LIBRARIES fmt::fmt)
#endif()
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(trajectoryError trajectoryError.cpp)
target_link_libraries(trajectoryError ${Pangolin_LIBRARIES} ${FMT_LIBRARIES})

4.3 ch4—>example—>trajectoryError.cpp
string groundtruth_file和string estimated_file的路径修改成绝对路径

#include <iostream>
#include <fstream>
#include <unistd.h>
#include <pangolin/pangolin.h>
#include <sophus/se3.hpp>

using namespace Sophus;
using namespace std;

string groundtruth_file = "/home/yu/slam_learn/slambook2-master/ch4/example/groundtruth.txt";
string estimated_file = "/home/yu/slam_learn/slambook2-master/ch4/example/estimated.txt";

typedef vector<Sophus::SE3d, Eigen::aligned_allocator<Sophus::SE3d>> TrajectoryType;

void DrawTrajectory(const TrajectoryType &gt, const TrajectoryType &esti);

TrajectoryType ReadTrajectory(const string &path);

5.编译后运行

RMSE = 2.20728

在这里插入图片描述

  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值