Ubuntu18.04
Ros Melodic
Cmake 3.10.2
首先卸载之前编译或者安装好的库.
如果你要更换新的版本,如gazebo11:
sudo apt-get remove '.*gazebo.*' '.*sdformat.*' '.*ignition-math.*' '.*ignition-msgs.*' '.*ignition-transport.*'
如果保持旧版本不变,编译旧版本,那么相应的依赖可以不用删除,避免重新安装。例如Ros Melodic默认的是gazebo9/
sudo apt-get remove '.*gazebo.*'
/usr/bin/gazebo
/usr/local/bin/gazebo
如果是ROS用户,建议不要source /opt/ros/*/setup.sh
,避免编译的时候将不正确的二进制文件加入到ros中。我试用了一下roscd
,发现已经有了。
cat ~/.bashrc
查看最后一行有这样一句:
source /opt/ros/melodic/setup.bash
注释掉这一行,再重启后输入roscd:
Command 'roscd' not found, did you mean:
很好。
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
sudo apt-get update
wget https://raw.githubusercontent.com/ignition-tooling/release-tools/master/jenkins-scripts/lib/dependencies_archive.sh -O /tmp/dependencies.sh
GAZEBO_MAJOR_VERSION=version ROS_DISTRO=dummy . /tmp/dependencies.sh
echo $BASE_DEPENDENCIES $GAZEBO_BASE_DEPENDENCIES | tr -d '\\' | xargs sudo apt-get -y install
DART(Dynamic Animation and Robotics Toolkit) 依赖:
# Only needed on Trusty. Ubuntu packages since Utopic.
sudo apt-add-repository ppa:libccd-debs
sudo apt-add-repository ppa:fcl-debs
# Main repository
sudo apt-add-repository ppa:dartsim
sudo apt-get update
sudo apt-get install libdart6-dev
# Optional DART utilities
sudo apt-get install libdart6-utils-urdf-dev
添加DART的ppa有可能与ROS出现冲突
GUI 回退测试支持:sudo apt-get install xsltproc
man-pages简体中文支持:sudo apt-get install ruby-ronn
一口气安装:sudo apt-get install xsltproc ruby-ronn
SDFormat
ignition-math,ignition-transport,ignition-msgs
用apt-cache search
搜索,发现只有sdformat6,看来还是需要重新安装啊。
首先安装依赖库。
sudo apt-get install ruby-dev build-essential libtinyxml-dev libboost-all-dev cmake mercurial pkg-config
使用Ubuntu distros 或者bionic之前的版本参考这里添加ppa和下载libdart:
sudo apt-get install lsb-release
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D2486D2DD83DB69272AFE98867170598AF249743
sudo apt-get update
链接内教程让你下载的是math4,我们可以查看有哪些版本,选择最新的直接下载:
apt-cache search libignition-math*
我选择了libignition-msgs6-dev
,libignition-math6-dev
,libignition-transport9-dev
,尽量选择dev版本。
sudo apt-get install libignition-transport9-dev libignition-math6-dev libignition-msgs6-dev
直接下载的话没有sdformat9,只好下载源码并编译,如果gazebo是从github上下载,那么sdformat也要从github上下载,我从网站上下载安装了sdformat9.0.0以后发现github的gazebo需要的是9.3版本,后续安装gazebo出了问题,必须卸载重装。
同时,sdformat也不能直接用git clone下载,因为这样会是最新版,比如11。所以最终要去github的release里面下载9.3版本。
Could not find a configuration file for package "sdformat9" that is
compatible with requested version "9.3".
The following configuration files were considered but not accepted:
/usr/lib/x86_64-linux-gnu/cmake/sdformat9/sdformat9-config.cmake, version: 9.0.0
Call Stack (most recent call first):
CMakeLists.txt:159 (include)
总之卸载方法如下:
cd build
sudo make uninstall
然后下载最新版:Github Release
解压。
mkdir sdformat9.3.0/build
cd sdformat9.3.0/build
cmake ../
sudo make install
mkdir workspace
cd workspace
git clone [https://github.com/osrf/gazebo.git](https://github.com/osrf/gazebo.git)
cd gazebo
mkdir build
cd build
cmake ../
cmake -DCMAKE_BUILD_TYPE=Debug ../
cmake ../
产生错误和警告。按照提示内容下载缺失的包。
例如:
尝试一口气下载
sudo apt-get install libignition-msgs5-dev libignition-transport8-dev libignition-common3-dev libignition-fuel-tools4-dev
如果还是找不到包,查看一下是否有漏装的,或者安装SDFormat那段漏掉了什么。
cmake 成功:
-- Gazebo version 11.2.0
-- Found CPack generators: DEB
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- High memory tests: enabled
--
make -j4
sudo make install
部署和安装到本地:
/usr/local/
,也可以更改为对应版本,如/usr/local/bin/gazebo11
,但我没有改。设置下载目录的方式是:cmake -DCMAKE_INSTALL_PREFIX=
echo "export LD_LIBRARY_PATH=/lib:/opt/qt/5.12.6/gcc_64/lib:$LD_LIBRARY_PATH" >> ~/.bashrc
echo "export PATH=/bin:$PATH" >> ~/.bashrc
echo "export PKG_CONFIG_PATH=/lib/pkgconfig:$PKG_CONFIG_PATH" >> ~/.bashrc
source ~/.bashrc
最后把.bashrc中关于ros的注释取消就可以了。