@Ubuntu 16.04 LTS 环境下的Player/stage安装记录
Player v.3.0.2
player安装包的下载方法有两种,一种是直接下载https://sourceforge.net/projects/playerstage/files/,一种是用svn( https://sourceforge.net/p/playerstage/svn/HEAD/tree/)。使用svn下载的安装包时间比较近,但是我的一直下载不下来,因此我采用第一种直接下载。但是直接下载的包发布时间很早,我猜后续出现的诸多问题也和版本有关。
依赖项有很多,具体如下:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install autotools-dev
sudo apt-get install build-essential
sudo apt-get install cmake
sudo apt-get install cpp
####
sudo apt-get install libboost-signals1.58.0
sudo apt-get install libboost-signals1.58-dev
sudo apt-get install libboost-thread1.58.0
sudo apt-get install libboost-thread1.58-dev
sudo apt-get install libcv2.4
####
sudo apt-get install libcv-dev
sudo apt-get install libgdk-pixbuf2.0-0
sudo apt-get install libgdk-pixbuf2.0-dev
sudo apt-get install libgnomecanvas2-0
sudo apt-get install libgnomecanvas2-dev
sudo apt-get install libgsl0-dev
sudo apt-get install libgtk2.0-dev
sudo apt-get install libjpeg62-dev
sudo apt-get install libtool
sudo apt-get install libxmu-dev swig
sudo apt-get install python2.7-dev
sudo apt-get install libcv-dev
sudo apt-get install libcvaux-dev
sudo apt-get install libhighgui-dev
sudo apt-get install freeglut3
sudo apt-get install freeglut3-dev
sudo apt-get install libfltk1.1
sudo apt-get install libfltk1.1-dev
sudo apt-get install libltdl7
sudo apt-get install libltdl-dev
sudo apt-get install libpng12-dev
sudo apt-get install libpng12-0
sudo apt-get update
sudo apt-get upgrade
以上代码来源于网址http://wiki.nps.edu/display/RC/。该网址中的代码适用的ubuntu版本较老,安装###与####之间的依赖时会出现无法定位软件包的问题。因此我们在网页https://packages.ubuntu.com//查询适用于ubuntu 16的依赖版本,相应地更改了###与####之间的代码,使其能够适用于ubuntu 16。
首先创建一个文件夹,我的是~/bin/。将前面下载的安装包放入该文件夹里,解压得到player-3.0.2文件夹,然后建立build文件夹,开始编译安装。
cd player-3.0.2
mkdir build #Create a build directory
cd build
cmake ../
make
sudo make install
以上过程可能会遇到无数问题,别慌。大部分问题都能在本文里查到,查不到的在goole或其他上找,有耐心点,一定能解决。
问题1:cmake …/出现error,和Time_UTC有关。
解决方法:进入*…/ client_libs/libplayerc++文件夹,打开playerclient.cc,将Time_UTC替换成Time_UTC_*。
问题2:编译时会出现以下error
/home/bin/player-3.0.2/server/drivers/shell/readlog.cc:668:43: error: cannot convert ‘FILE* {aka _IO_FILE*}’ to ‘gzFile {aka gzFile_s*}’ for argument ‘1’ to ‘off_t gzseek(gzFile, off_t, int)’
ret = gzseek(this->file,0,SEEK_SET);
/home/bin/player-3.0.2/server/drivers/shell/readlog.cc:668:43: error: cannot convert ‘FILE* {aka _IO_FILE*}’ to ‘gzFile {aka gzFile_s*}’ for argument ‘1’ to ‘off_t gzseek(gzFile, off_t, int)’
ret = gzseek(this->file,0,SEEK_SET);
以上问题是文件*home/bin/player-3.0.2/server/drivers/shell/readlog.cc:*第668行和714行有问题,修改即可。
修改前:第一行为readlog.cc的668行内容,第二行为714行内容。
ret = gzseek(this->file,0,SEEK_SET);
ret = (gzgets( this->file, this->line, this->line_size) == NULL);
修改后:
ret = gzseek( (gzFile) this->file,0,SEEK_SET);
ret = (gzgets( (gzFile) this->file, this->line, this->line_size) == NULL);
该问题goole上有详细解释,可自行搜索。
问题3:编译时error2
examples/libplayerc++/CMakeFiles/sonarobstacleavoid.dir/build.make:100: recipe for target 'examples/libplayerc++/sonarobstacleavoid' failed
make[2]: *** [examples/libplayerc++/sonarobstacleavoid] Error 1
解决方法:找到sonarobstacleavoid.dir文件夹。该文件夹内部包含有link.txt,,在第一个-lm tag 旁边加入-lboost_system,然后从新make。这样的问题会遇到很多次,每次找到对应的文件夹,按照相同的方法进行修正就可以。
问题4:error3
Package playercore was not found in the pkg-config search path.
Perhaps you should add the directory containing `playercore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'playercore' found
解决办法:将/usr/local/lib/pkgconfig添加到变量PKG_CONFIG_PATH上。lib/lib64对应32位和64位系统,为了保险,我把两个都加上啦。
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH
问题5:
~/bin/player-3.0.2/build$ pkg-config --modversion playercore
Package playercore was not found in the pkg-config search path.
Perhaps you should add the directory containing `playercore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'playercore' found
解决方法
ThinkCentre-M920t-N000:~/bin/player-3.0.2/build$ pkg-config -libs playercore
Unknown option -libs
ThinkCentre-M920t-N000:~/bin/player-3.0.2/build$ export PKG_CONFIG_PATH=/home/lilin/bin/player-3.0.2/build/libplayercore:$PKG_CONFIG_PATH
问题6:出现与路径相关的erorr时,将以下代码加入~/.bashrc文件
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig":"/usr/local/lib64/pkgconfig":$PKG_CONFIG_PATH
export PATH=$PATH:"/usr/local/lib64"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/usr/local/lib":"/usr/local/lib64"
export PLAYERPATH="/usr/local/lib":"/usr/local/lib64"
export STAGEPATH="/usr/local/lib":"/usr/local/lib64"
然后
source ~/.bashrc
sudo ldconfig
stage版本最好选用最新的,老版本编译时会出现不可知的问题,我用的是Stage 4.3.0,链接github.com/rtv/stage/releases/。
Ps: Ros在安装时其实自带stage安装包,但是不知道为甚我们还要单独安装一次。有明白的同学可以给我解惑一下。
安装代码如下,
cd Stage-4.3.0
mkdir build #Create a build directory
cd build
cmake ../
make
sudo make install
可以看到和player的安装很类似。stage版本如果比较新,那么安装过程问题就少。我
安装完毕以后,我们首先测试player和stage。
ThinkCentre-M920t-N000:~/bin/Stage-4.3.0/worlds$ which player
/usr/local/bin/player
ThinkCentre-M920t-N000:~/bin/Stage-4.3.0/worlds$ which stage
/usr/local/bin/stage
可以看到打印出了地址。接下来我们测试player和stage是否能正常工作,出现以下error,提示不能load stageplugin。
error : Failed to load plugin stageplugin.
error : libtool reports error: file not found
很明显出现了问题。网上有方法https://blog.csdn.net/qq_32005213/article/details/80232864,通过以下命令:
sudo ldconfig
这个命令的作用是重新连接动态库,如果你的stageplguin.so库是新安装的,需要运行这个指令或者重新启动计算机才会生效。
我尝试了该方法,却没能解决问题。观察发现,我在ubuntu中找不到stageplugin.so文件,因此我猜想我的安装不完全,我尝试从新安装了一次stage,问题解决了。弹出了stage窗口,同时打印数据如下:
ThinkCentre-M920t-N000:~/bin/Stage-4.3.0/worlds$ stage simple.world
Stage 4.3.0
[Loading simple.world][Include pioneer.inc][Include map.inc][Include sick.inc][Image "bitmaps/cave.png"]
Wander ctrl for robot r0:
looking for a suitable ranger at "r0:ranger:0" ... no.
looking for a suitable ranger at "r0:ranger:1" ... yes.
Wander ctrl for robot r1:
looking for a suitable ranger at "r1:ranger:0" ... no.
looking for a suitable ranger at "r1:ranger:1" ... yes.
Stage: User closed window
[Stage: done]
ThinkCentre-M920t-N000:~/bin/Stage-4.3.0/worlds$ player simple.cfg
Registering driver
Player v.3.0.2
* Part of the Player/Stage/Gazebo Project [http://playerstage.sourceforge.net].
* Copyright (C) 2000 - 2009 Brian Gerkey, Richard Vaughan, Andrew Howard,
* Nate Koenig, and contributors. Released under the GNU General Public License.
* Player comes with ABSOLUTELY NO WARRANTY. This is free software, and you
* are welcome to redistribute it under certain conditions; see COPYING
Player/stage的安装太麻烦啦,问题太多,中间一度想放弃。但是最后还是克服了,以后遇到问题,多到网上搜一下,可能有意外的惊喜。