VirtualBox虚拟机Ubuntu18.04安装hdl_localization保姆级教程
VirtualBox虚拟机Ubuntu18.04安装hdl_localization保姆级教程
序言
多说一句,好久没登陆csdn,有些文章被设置为VIP什么的,我都不知道,恶心人,这个网站权当是学习记录分享,我本人所有的材料和文章都是开放的,我全给改回来了。
-
首先通过虚拟机安装系统,这一步非常简单跳过。
-
如果开机遇到时间乱码和终端无法打开的情况,没有直接去3
-
这是由于系统字符编码设置不正确或语言环境配置错误引起的,老版的bug就是多,处理步骤如下
-
开机或者进入桌面之后,按下Ctrl + Alt + F3进入命令行界面。
-
#修改编码 sudo nano /etc/default/locale
-
将
LANG="en_US
"修改为LANG="en_US.UTF-8"
-
Ctrl+O写入 然后回车,然后Ctrl+X退出即可
-
还有一件事,默认创建的用户是没有sudo权限的,你需要给用户添加sudo权限
sudo usermod -aG sudo 用户名 #执行完以后重启系统
-
-
-
给ubuntu配置国内镜像源 或者配置终端代理,不然很慢,可以自己找教程,也可以看我的这个提供一个参考
-
替换为国内的镜像源
#首先备份原来的镜像源文件 sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak#编辑sources.list,nano或者vim都行,有些没装 我就用nano sudo nano /etc/apt/sources.list#将以下内容粘贴到 sources.list 文件中# 清华大学开源软件镜像站 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse#粘贴完成后,保存并退出文件(在 nano 中,按 Ctrl + X,然后按 Y,最后按 Enter)#最后到终端 sudo apt update
-
给终端配置代理,这个直接在~/.bashrc里面导入代理配置就好,但是ubuntu18时候会有bug,sudo的时候不会继承配置文件里面的变量,直接清掉了。所以最好直接给apt配置代理,操作如下。
#编辑~/.bashrc里面,在末尾添加如下,具体看你自己的代理配置# HTTP/HTTPS代理 export http_proxy="http://192.168.124.9:7897" export https_proxy="http://192.168.124.9:7897"
如果这时候sudo apt install 没有超时那就可以,如果不行就需要给apt配置代理。这大概sudo的时候没走这个代理,但如果你切换root就可以,但我们不希望这样。我们给apt配置代理 一劳永逸
#编辑apt的代理文件,如果没有就自己创建这个 sudo nano /etc/apt/apt.conf.d/proxy.conf#里面添加如下内容,具体的代理根据自己的配置 Acquire::http::Proxy "http://127.0.0.1:7890"; Acquire::https::Proxy "http://127.0.0.1:7890";
-
-
OK,如果安装软件没问题的话,下面的都给装上
sudo apt install git make cmake gcc g++
-
按照
koide3/hdl_localization
的指示,创建文件夹,并下载好这几个git仓库-
mkdir -p catkin_ws/srcgit clone https://github.com/koide3/ndt_omp git clone https://github.com/SMRT-AIST/fast_gicp --recursive git clone https://github.com/koide3/hdl_localization git clone https://github.com/koide3/hdl_global_localizationcd catkin_wscatkin_make -DCMAKE_BUILD_TYPE=Release
-
-
执行完上面的命令,不出意外应该会报错,大概是下面的这个样子,执行提示的命令没有用,其实就是ros没装好,我们安装ros
#可能是这样 Unable to handle package.xml format version '3', please update catkin_pkg (e.g. on Ubuntu/Debian use: sudo apt-get update && sudo apt-get install --only-upgrade python-catkin-pkg)
-
安装ROS
-
添加ros源
-
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu bionic main" > /etc/apt/sources.list.d/ros-latest.list'
-
添加ros公钥
-
sudo apt install curl -y curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
-
-
更新apt并安装ros
-
sudo apt install ros-melodic-desktop-full
-
-
如果安装的时候出现报错,下面这样的话,这是大概率是依赖冲突
-
Errors were encountered while processing:/tmp/apt-dpkg-install-PLnypS/0692-python-catkin-pkg-modules_0.5.2-1_all.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
-
可以这样解决
-
#清理apt的缓存 sudo apt clean sudo apt update#修复损坏依赖 sudo apt --fix-broken install#一般执行完上面应该没啥问题,不过还不行 直接强制安装 sudo apt install --reinstall python-catkin-pkg-modules
-
-
-
-
-
结束之后查看ros是否安装,如果没有输出,请查看前面是不是哪里没搞对
-
dpkg -l | grep ros-melodic-catkin
这时候还是不可以直接catkin,需要先加载一下ros环境
#加载ros环境 source /opt/ros/melodic/setup.bash#我们可以直接写入bashrc,不然每次都得source很麻烦 echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrc
这个时候catkin_make -DCMAKE_BUILD_TYPE=Release编译就没啥问题了,如果遇到这个问题,就是内存不够了,减少编译的线程数就可以了,这样操作
catkin_make -DCMAKE_BUILD_TYPE=Release -j2
make[1]: *** Waiting for unfinished jobs.... [ 75%] Linking CXX executable /home/dpf/Workspace/catkin_ws/devel/lib/hdl_global_localization/hdl_global_localization_node [ 75%] Built target hdl_global_localization_node [ 77%] Linking CXX shared library /home/dpf/Workspace/catkin_ws/devel/lib/libfast_gicp.so [ 77%] Built target fast_gicp Makefile:140: recipe for target 'all' failed make: *** [all] Error 2 Invoking "make -j14 -l14" failed
-