写在前面
前几天尝试编译knowrob项目,中途遇到很多问题,最后仍未成功编译。不过还是想把遇到的问题晒出来,希望能或多或少帮助到其他小伙伴。当然,如果有人编过了,也劳烦指点一下我,哈哈~
创建catkin工作空间:
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make
执行完catkin_make指令后,会在src下创建一个CMakeLists.txt文件,在catkin_ws下创建两个子文件夹:build和devel。在devel下会有一些setup.*sh文件,source任一文件可将ROS_PACKAGE_PATH 环境变量覆盖到当前工作空间。
按照knowrob安装提示,进行安装
$ rosdep update
$ cd ~/catkin_ws/src
wstool这个工具依赖.rosinstall,直接wstool merge会报出没有.rosinstall文件的错误。这里参考网上,先在没有rosinstall文件的情况下初始化工作区,再merge。
$ wstool init src
$ wstool merge https://raw.github.com/knowrob/knowrob/master/rosinstall/knowrob-base.rosinstall
$ wstool update
$ rosdep install --ignore-src --from-paths .
$ cd ~/catkin_ws
$ catkin_make
在最后的catkin_make时遇到错误:找不到libmongocxx_ros-config.cmake
解决:凡是提示 xxConfig.cmake 找不到的
一般通过查找上一行 …provided by “xx”
再sudo apt-get install ros-ROS版本-xx 即可
我们用apt-get install 来安装缺少的包(可以按tab补全)
sudo apt-get install ros-indigo-libmongocxx-ros
但是,进度就卡在0%:
等待1分钟后出现 404 NoT Found[IP: xxxxx] ,
这个问题网上有几种说法,我先用浏览器访问存放ROS包的官网:
http://packages.ros.org/ros/ubuntu/pool/main/r
找到了相应的amd64.deb包,但是名字却和命令行中出现的不太一样,猜测这导致了404错误
怎么办呢?我按照这篇博客的做法,准备用sudo dpkg -i 命令安装新版本的包。
首先通过浏览器下载了上图第一个deb包,之后进入下载后的文件夹,右键在终端中打开,输入:
sudo dpkg -i ros-indigo-libmongocxx-ros_0.4.2-0trusty-20190604-105735-0800_amd64.deb
完成这步,再接着sudo apt-get install ros-indigo-libmongocxx-ros
时,提示ros-indigo-libmongocxx-ros 已经是最新的版本,说明方法成功了。之后我又尝试了博客中第二部分说修改源地址,貌似不太顶用。
回到主线,我们进入 cd ~/catkin_ws/ 后执行catkin_make,又提示designator_integration_cpp-config.cmake包没安装:
按照总结的规律,查找上一行 …provided by "designator_integration_cpp"我们知道,要安装的包是designator_integration。但是sudo apt-get install ros-indigo-designator-integration
时又出现了大片的404错误。我目前还不清楚为什么会产生这个、怎么才能根治,只能按照笨方法,通过浏览器到相应网站手动下载,再dkpg安装。
更换Ubuntu系统源
真是受不了龟速的网速啊,下个软件慢的要死,于是添加了一些国内源
a) 首先备份一下原来的源,以备不时之需:
sudo cp /etc/apt/sources.list /etc/apt/sources_init.list
b) 更换源,用vim将下面的阿里源复制进去,保存
sudo vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
c)更新源、更新软件
sudo apt-get update
sudo apt-get upgrade
换完之后继续回到catkin_ws进行编译,陆续出现了各种错误- -!,下面直接把错误和解决方法写上了。
No package ‘swipl’ found
原因是没有安装prolog…解决:
sudo apt-get install swi-prolog
有关prolog语言的博客:
http://www.ruanyifeng.com/blog/2019/01/prolog.html
No package ‘json-glib-1.0’ found
sudo apt-get install libjson-glib-dev
Could not find the required component ‘rosjava_build_tools’.
sudo apt-get install ros-indigo-rosjava
ImportError: No module named rdflib
原因是没安装rdflib这个库。于是找到了rdflib的github网站
https://github.com/RDFLib/rdflib。
按照教程,提示使用$ pip install rdflib
安装,但是!我的会报错(Cannot fetch index base URL https://pypi.python.org/simple/)。于是,手动下载安装吧!
- 进入手动下载页面:https://pypi.org/project/rdflib/#files
- 选择”rdflib-4.2.2.tar.gz “,下载后解压
sudo python setup.py install
(自动联的是python2.7)
然后等了很久,一直卡在下图的地方:
等了得有15分钟仍然丝毫未动,我就想是不是得换个pip源?毕竟国外的太慢了,国内没准会快一些?也算是瞎尝试吧…
更换Python的pip源
$ cd /home
$ mkdir ~/.pip
$ vim pip.conf
把下列代码拷到pip.conf中。这里换的清华的源
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
保存退出。
ImportError: No module named isodate
pip install isodate
未解决:mongodb_log_desig.cpp:35:36:fatal error:designators/Designator.h:没有那个文件或目录
编译时报错的截图如下: