ubuntu20.04+slambook2+vscode实例配置(至第五章)

源文件链接

链接:https://pan.baidu.com/s/1il4i7L1RjNIHx5uXAtSfEg?pwd=1236 
提取码:1236

链接:https://pan.baidu.com/s/1SdE7sWlP26YiD5owymCJNQ?pwd=1236 
提取码:1236

20.04.5
sudo apt install gedit

sudo gedit /etc/apt/sources.list

首选阿里源,包比较全但更新可能比较慢

sudo apt-get update
sudo apt-get upgrade

    Ubuntu 22.04:jammy
    Ubuntu 20.04:focal
    Ubuntu 18.04:bionic
    Ubuntu 16.04:xenial

清华
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse


#focal
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

阿里源

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse


中科大源


deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

网易163源

deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse


#20.04zidai
#deb cdrom:[Ubuntu 20.04.5 LTS _Focal Fossa_ - Release amd64 (20220831)]/ focal main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal universe
deb http://us.archive.ubuntu.com/ubuntu/ focal-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://us.archive.ubuntu.com/ubuntu/ focal-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://security.ubuntu.com/ubuntu focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://security.ubuntu.com/ubuntu focal-security universe
# deb-src http://security.ubuntu.com/ubuntu focal-security universe
deb http://security.ubuntu.com/ubuntu focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu focal-security multiverse

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.


sudo apt install cmake 
sudo apt-get install fcitx
sudo apt -f install

#ubuntu汉化
先安装chinese,然后再选择语言为汉语,应用,重启即可


#设置fcitx为系统输入法后
sudo cp /usr/share/applications/fcitx.desktop /etc/xdg/autostart/

#进入语言设置将ibus改为fcitx后执行
sudo apt purge ibus

#中途可能需要该命令
sudo apt -f install


#安装搜狗
sudo dpkg -i 


#安装输入法依赖
sudo apt install libqt5qml5 libqt5quick5 libqt5quickwidgets5 qml-module-qtquick2
sudo apt install libgsettings-qt1

#重启配置激活输入法


#其他软件安装(拖拽进去)
sudo dpkg -i 

#微信调整界面(150)
WINEPREFIX=~/.ukylin-wine/wechat /usr/bin/ukylin-wine winecfg

#Ubuntu安装gcc和g++开发环境(不然cmake和make可能会报错)
sudo apt-get install build-essential

#如果中间存在依赖,先执行下面,再执行环境
sudo apt-get install aptitude


#chktex错误
ctrl + shift + p
settings json
(用户)
加上

"latex.linter.enabled": false,

#Ubuntu vscode Latex

sudo apt install texlive texlive-extra-utils texlive-binaries texlive-lang-cjk texlive-latex-base texlive-latex-extra texlive-xetex texlive-science texmaker texlive-publishers latexmk

#(前提是安装好vscode软件,vscode内的latex插件也要)

更新日志
sudo updatedb

以上是基本配置,下面slam的相关配置


sudo apt install git 

sudo apt install htop

sudo apt install terminator
同一个标签内操作
Alt+Up                          //移动到上面的终端
Alt+Down                        //移动到下面的终端
Alt+Left                        //移动到左边的终端
Alt+Right                       //移动到右边的终端
Ctrl+Shift+O                    //水平分割终端
Ctrl+Shift+E                    //垂直分割终端
Ctrl+Shift+Right                //在垂直分割的终端中将分割条向右移动
Ctrl+Shift+Left                 //在垂直分割的终端中将分割条向左移动
Ctrl+Shift+Up                   //在水平分割的终端中将分割条向上移动
Ctrl+Shift+Down                 //在水平分割的终端中将分割条向下移动
Ctrl+Shift+S                    //隐藏/显示滚动条
Ctrl+Shift+F                    //搜索
Ctrl+Shift+C                    //复制选中的内容到剪贴板
Ctrl+Shift+V                    //粘贴剪贴板的内容到此处
Ctrl+Shift+W                    //关闭当前终端
Ctrl+Shift+Q                    //退出当前窗口,当前窗口的所有终端都将被关闭
Ctrl+Shift+X                    //最大化显示当前终端
Ctrl+Shift+Z                    //最大化显示当前终端并使字体放大
Ctrl+Shift+N or Ctrl+Tab        //移动到下一个终端
Ctrl+Shift+P or Ctrl+Shift+Tab  //Crtl+Shift+Tab 移动到之前的一个终端


标签间操作
F11                             //全屏开关
Ctrl+Shift+T                    //打开一个新的标签
Ctrl+PageDown                   //移动到下一个标签
Ctrl+PageUp                     //移动到上一个标签
Ctrl+Shift+PageDown             //将当前标签与其后一个标签交换位置
Ctrl+Shift+PageUp               //将当前标签与其前一个标签交换位置
Ctrl+Plus (+)                   //增大字体
Ctrl+Minus (-)                  //减小字体
Ctrl+Zero (0)                   //恢复字体到原始大小
Ctrl+Shift+R                    //重置终端状态
Ctrl+Shift+G                    //重置终端状态并clear屏幕
Super+g                         //绑定所有的终端,以便向一个输入能够输入到所有的终端
Super+Shift+G                   //解除绑定
Super+t                         //绑定当前标签的所有终端,向一个终端输入的内容会自动输入到其他终端
Super+Shift+T                   //解除绑定
Ctrl+Shift+I                    //打开一个窗口,新窗口与原来的窗口使用同一个进程
Super+i                         //打开一个新窗口,新窗口与原来的窗口使用不同的进程


剪贴板共用
sudo apt install open-vm-tools
 
sudo apt install open-vm-tools-desktop

Vmware虚拟机Ubuntu文件共享、共享剪切板以及自动挂载
https://blog.csdn.net/weixin_63505616/article/details/126202925


若有引用的git库,则要git clone --recursive + 网址

安装ros一键(第二讲下)
https://blog.csdn.net/LNSTOP/article/details/126599501


时间同步
https://blog.csdn.net/fu_zhongyuan/article/details/89672116?ops_request_misc=&request_id=&biz_id=102&utm_term=%E8%99%9A%E6%8B%9F%E6%9C%BA%E6%97%B6%E9%97%B4%E4%B8%8E%E4%B8%BB%E6%9C%BA%E5%90%8C%E6%AD%A5&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-1-89672116.nonecase&spm=1018.2226.3001.4187

vscode字体大小:设置
vscode侧边栏字体大小:ctrl+=,ctrl+-

定位包/文件
sudo apt install mlocate

定位头文件命令
locate Core |grep eigen
Core库,eigen是其下的头文件

vscode添加编译库
ctrl + shift + p
c++ Edit..

在工作路径下一行加上库的路径,注意双引号和逗号。
/**是所有头文件都包含进去(但可能会影响运行速度)

eigen库的使用
Block operations
Dense matrix and array manipulation

http://eigen.tuxfamily.org/dox/


Matrix求导网站(梯子)
https://en.wikipedia.org/wiki/Matrix_calculus


#配置eigen,参考这个,不然后续第四章会版本出错
https://blog.csdn.net/weixin_44684139/article/details/104803225?app_version=5.14.2&code=app_1562916241&csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22104803225%22%2C%22source%22%3A%22mengshenglo%22%7D&uLinkId=usr1mkqgl919blen&utm_source=app

如果你有以前的eigen版本,则先卸载
(1)如何判断有老版本

sudo updatedb  
locate eigen3  

(2)进行卸载
sudo rm -rf /usr/include/eigen3 /usr/lib/cmake/eigen3 /usr/share/doc/libeigen3-dev /usr/share/pkgconfig/eigen3.pc /var/lib/dpkg/info/libeigen3-dev.list /var/lib/dpkg/info/libeigen3-dev.md5sums  


安装eigen3.3以上版本(这里我选用最新的3.3.7,注意3.2系列的不可以!!!)
正确方法:
(1)在官网(http://eigen.tuxfamily.org/index.php?title=Main_Page)下载安装包:eigen-3.3.7.tar.bz2 ,然后提取到此处
(2)进入文件夹eigen-3.3.7,右键在终端打开。
(3)进行安装

mkdir build

cd build

cmake ..

sudo make install


注意,新版的eigen路径是/usr/local/include/eigen3,跟以前的不一样。
所以要修改cmakelist.txt
include_directories("/usr/local/include/eigen3")


#配置Pangolin 
sudo apt-get install libglew-dev  
sudo apt-get install cmake  
sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev

#在slam实例包里
sudo apt install git
git clone https://github.com/stevenlovegrove/Pangolin.git
 
cd Pangolin  
mkdir build  
cd build  
cmake .. 
make

sudo make install

sudo ldconfig

不存在用户定义的从 "pangolin::OpenGlMatrix" 到 "Eigen::Matrix" 的适当转换C/C++(312)

上面报错还是无法解决,但是修改CMakeList.txt中c++版本就行,这是因为下载的pangolin的版本比较高,可以考虑用高翔的,如果用github最新的就修改下面就可以make,但是报错不会消失

set(CMAKE_CXX_FLAGS "-std=c++17")

example例子

plotTrajectory.cpp(文件路径问题,代码爆红问题)
string trajectory_file = "./examples/trajectory.txt";

修改为
string trajectory_file = "../trajectory.txt";

并添加头文件
#include

上面是前三章的


#配置sophus
现如今sophus需要依赖fmt库,因此优先安装fmt:

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

主目录下
git clone https://github.com/strasdat/Sophus.git
cd Sophus/


(注,下面的make不要多线程,cmake中有顺序逻辑,并行会出错)
mkdir build
cd build
cmake ..
make
sudo make install


不要回滚git checkout a621ff!!!否则会装成老版本的非模板sophus


ch4
CMakeList.txt ( 同时加入eigen和sophus的依赖 )


cmake_minimum_required(VERSION 3.0)
project(useSophus)

# 为使用 sophus,需要使用find_package命令找到它
find_package(Sophus REQUIRED)
include_directories(${Sophus_INCLUDE_DIRS})

# Eigen
include_directories("/usr/local/include/eigen3")
add_executable(useSophus useSophus.cpp)
target_link_libraries(useSophus ${Sophus_LIBRARIES} fmt)

add_subdirectory(example)

c++ json 自动配置
"/usr/local/include/eigen3"


example中的cpp文件修改为以下路径
string groundtruth_file = "../../example/groundtruth.txt";
string estimated_file = "../../example/estimated.txt";


example下的cmakelist.txt的off改为ON
option(USE_UBUNTU_20 "Set to ON if you are using Ubuntu 20.04" ON)

mkdir build 
cd build/
cmake ..
make

cd example/

./trajectoryError 


第四章完


#安装OpenCV
sudo apt-get install  make

sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg-dev libswscale-dev libtiff5-dev
sudo apt-get install libcanberra-gtk-module
sudo apt-get install pkg-config

#下载OpenCV版本(盘里有4.7.0版本)
https://opencv.org/releases/

#解压后在文件夹里
mkdir build
cd build

cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=ON -D CMAKE_INSTALL_PREFIX=/usr/local .. 


sudo make -j8

sudo make install

#配置环境变量
sudo gedit /etc/ld.so.conf

#下一行加上
include /usr/local/lib

sudo ldconfig

sudo gedit /etc/bash.bashrc 

#末尾加上
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

 source /etc/bash.bashrc

pkg-config opencv4 --modversion

#任意一个测试文件夹
touch test.cpp

#测试代码
#include
#include

using namespace cv;
using namespace std;

int main(int argc, char** argv )
{

  Mat image = imread("123.jpg");

  namedWindow("SSJ",WINDOW_FREERATIO);

  imshow("SSJ", image);

  waitKey(0);

  return 0;
}


#编译
g++ test.cpp -o test.out $(pkg-config --cflags --libs opencv4)


#实例测试
c++ json 自动配置

                "/usr/local/include/eigen3",
                "/usr/local/include/opencv4"

#cmakelist.txt文件 3  修改为  4

find_package( OpenCV 4 REQUIRED )


#下面ch5 joinMap 点云库的实例修改
#pcl安装,建议不用
sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl
#上面命令会报错,然后后续的更新会受到影响,在软件与更新中的其他软件,删除对应的ppa即可正常更新


#执行这两个即可
sudo apt install libpcl-dev
sudo apt update

#版本原因下面包找不到
sudo apt install libpcl-all

#这个工具可以下
sudo apt install pcl-tools

rgbd下的CMakelist.txt修改为
find_package(Sophus REQUIRED)
include_directories(${Sophus_INCLUDE_DIRS})
find_package(Pangolin REQUIRED)

add_executable(joinMap joinMap.cpp)
target_link_libraries(joinMap ${OpenCV_LIBS} ${Pangolin_LIBRARIES} fmt)


undistortImage.cpp
string image_file = "./distorted.png";   // 请确保路径正确
修改为

string image_file = "../../imageBasics/distorted.png";   // 请确保路径正确


joinMap.cpp的路径改为
        ifstream fin("../../rgbd/pose.txt");

        boost::format fmt("../../rgbd/%s/%d.%s"); //图像文件格式

stereoVision.cpp的路径改为
string left_file = "../../stereo/left.png";
string right_file = "../../stereo/right.png";

修改后,
mkdir build 
cd build/
cmake ..
make

cd imageBasics/
./imageBasics ../../imageBasics/ubuntu.png
./undistortImage

cd ..
cd rgbd/
./joinMap

cd ..
cd stereo/
./stereoVision

#以上就是ch5


更新时间2023.03.22

你可能感兴趣的:(slam学习分享,ubuntu,linux,slam)