Gazebo 源码安装(Ubuntu+Mac)

Gazebo源码安装的好处是,可以手动改动Gazebo的源代码,并测试,Gazebo安装可以有几种方式,按照 ros-kinetic-desktop-full安装的gazebo,是看不到Gazebo的源码,也就不能修改源码和调试源码。当然Gazebo也可以以apt-get 的形式安装,安装成功后,也看不到Gazebo的源码,所以要对gazebo 的源码进行修改和调试的话,只能源码安装。
源码安装过程:官网源码安装地址是http://gazebosim.org/tutorialstut=install_from_source&cat=install


 Ubuntu源码安装Gazebo

一、Prerequisites

  •   For compiling the latest version of gazebo you will need an Ubuntu distribution equal to 16.04 (Xenial) or newer.

Make sure you have removed the Ubuntu pre-compiled binaries before installing from source:

sudo apt-get remove '.*gazebo.*' '.*sdformat.*' '.*ignition-math.*' '.*ignition-msgs.*' '.*ignition-transport.*'
  • If you have previously installed from source, be sure you are installing to the same path location or that you have removed the previous installation from source version manually.

As a side note, default install locations:

  1.      Pre-compiled Ubuntu Binaries : /usr/bin/gazebo
  2.      Default source install : /usr/local/bin/gazebo

ROS Users

    When building Gazebo, we recommend you do not have your /opt/ros/*/setup.sh file sourced, as it has been seen to add the wrong libraries to the Gazebo build.

二、Install Required Dependencies

In a clean Ubuntu installation you can install pre-compiled versions of all dependencies:

  1. Setup your computer to accept software from packages.osrfoundation.org.

    Note: there is a list of available mirrors for this repository which could improve the download speed.

    sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
    
  2. Setup keys and update

    wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
    sudo apt-get update
    
  3. Install prerequisites. A clean Ubuntu system will need the following (replace version with the major version of gazebo you intend to build, eg: 7, 8, 9. And if using ROS, replace dummy with your ROS version, eg: indigo, jade, kinetic...):

    wget https://bitbucket.org/osrf/release-tools/raw/default/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
    

三、Optional Physics Engines

  • Release Note: in order to use DART, a full compilation of Gazebo from source is needed (as detailed in this document). The .deb packages are shipping the ODE, Bullet, and Simbody physics engines.

DART Support

  • Support for DART version 6 is integrated into the default branch. In an Ubuntu system, several Personal Package Archives (PPA's) can be used to install the proper package and dependencies. Note that adding these PPA's may cause conflicts with ROS.
# 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

Optional Dependencies

  • GUI test Support

       To correctly parse the results of GUI regression tests, the xsltproc package is needed.

sudo apt-get install xsltproc
  • Man Page Support

      To generate man-pages for the Gazebo executables, the ruby-ronn package is needed.

sudo apt-get install ruby-ronn
  • Player Support
sudo apt-get install robot-player-dev*

四、Dependencies managed by OSRF

Gazebo development is tightly linked to the development of a few other libraries:

   (一定要安装上,有些需要通过源码安装),通过安装的,在卸载Gazebo时,同样需要进入build(sudo make uninstall卸载),在这里特别的注意版本的问题。

  • SDFormat     (在连接中下载相应的版本,源码安装,【cmake ..   /  make -j4  /  sudo make install 】)
  • ignition-math     (sudo apt-get install libignition-math4-dev)
  • ignition-transport   (sudo apt-get install libignition-transport4-dev)
  • ignition-msgs           (sudo apt-get install libignition-msgs-dev)

      If you've installed all required dependencies following the instructions above, you already have the latest release of these libraries installed in your system. However, when working on new features, you often need to build these libraries from source.

     If you don't need a special version of these libraries, you can skip this section. If you're not sure if you need to build these from source, you can ask for guidance at Gazebo Answers, explaining your specific use case.

      To build these libraries from source, first go through the Build dependencies from source tutorial and then come back here.

五、Build And Install Gazebo

  1. Clone the repository into a directory and go into it:

    // 也可以不用hg下载,我们手动下载源码,同样的方式安装
    
    hg clone https://bitbucket.org/osrf/gazebo /tmp/gazebo
    cd /tmp/gazebo
    

    Note: the default branch is the development branch where you'll find the bleeding edge code, your cloned repository should be on this branch by default but we recommend you switch to the gazebo6 branch if you desire more stability

  2. Create a build directory and go there:

    mkdir build
    cd build
    
  3. Configure Gazebo (choose either method a or b below):(注意下面的a,b中只能选择一种,且只能选择一种cmake 命令,活着cmake ../  或者  cmake -DCMAKE_INSTALL_PREFIX=<install_path> ../,区别时安装的远程不同而已,cmake  ../时默认的安装路径  )

    a. Release mode: This will generate optimized code, but will not have debug symbols. Use this mode if you don't need to use GDB.

    cmake ../
    
    // 出错时,解决errors提示的问题,先忽略warning的错误,继续安装

    Note: You can use a custom install path to make it easier to switch between source and debian installs. We recommend using /home/$USER/local as the value for <install_path>:

    cmake -DCMAKE_INSTALL_PREFIX=<install_path> ../
    

    b. Debug mode: This will generate code with debug symbols. Gazebo will run slower, but you'll be able to use GDB.

    cmake -DCMAKE_BUILD_TYPE=Debug ../
    
    cmake ../
    
  4. The output from  cmake ../  may generate a number of errors and warnings about missing packages. You must install the missing packages that have errors and re-run  cmake ../.  Make sure all the build errors are resolved before continuing (they should be there from the earlier step in which you installed prerequisites). Warnings alert of optional packages that are missing.

  5. Make note of your install path, which is output from cmake and will either be the default install location or the one specified as <install_path> above, e.g.:

    // 是安装的显示路径,不是命令
    -- Install path: /home/$USER/local
  6. Build Gazebo:

    make -j4
    
  7. Install Gazebo:

    sudo make install
    
  8. Setup environment variables

Optional tests suite compilation

     The generic call to make won't compile any of the different types of tests present in Gazebo. While this saves a lot of time in compilations, there are many reasons to compile and run the testing suite: submitting changes to gazebo repository, packaging for linux distributions, etc. In order to compile the whole gazebo test suite you'll need to run:

// 这一步可以略过去
make tests

Local Install

  • If you decided to install gazebo in a local directory you'll need to modify some of your PATHs:
echo "export LD_LIBRARY_PATH=<install_path>/lib:$LD_LIBRARY_PATH" >> ~/.bashrc

echo "export PATH=<install_path>/bin:$PATH" >> ~/.bashrc

echo "export PKG_CONFIG_PATH=<install_path>/lib/pkgconfig:$PKG_CONFIG_PATH" >> ~/.bashrc

source ~/.bashrc

  • Now try running gazebo:
gazebo

If Gazebo runs successfully, you're done!.

If Gazebo was installed to /usr/local/ and running gazebo throws an error similar to:

gazebo: error while loading shared libraries: libgazebo_common.so.1: cannot open shared object file: No such file or directory

, then /usr/local/lib is not in load path (default behavior for Ubuntu). Run the following commands and then try running gazebo again:

echo '/usr/local/lib' | sudo tee /etc/ld.so.conf.d/gazebo.conf

sudo ldconfig
  1. If you are interested in using Gazebo with ROS, see Installing gazebo_ros_pkgs.

Install in a catkin workspace

    Another method for installing to a local directory is to use a catkin workspace, which supports plain cmake packages as well as catkin packages. This allows multiple versions of gazebo to be installed side-by-side. Environment variables do not need to be added to the ~/.bashrc; rather they are set by sourcing the appropriate setup script. Using catkin requires the some extra python packages to be installed. If you are using Ubuntu and have configured your system to use the ROS package repository (see here for instructions), then you can use the following apt-get commands:

sudo apt-get install python-catkin-pkg python-catkin-tools

For other platforms, you can use pip (you can also use pip with Ubuntu, but apt-get is recommended):

sudo pip install catkin-pkg catkin-tools

Here is an example for building gazebo against custom versions of sdformat, bullet, and DART.

First, create a workspace folder. Since it is easy to use multiple catkin workspaces, it is convenient to place them in a single folder, such as ~/ws. For this tutorial, the bash variable WS will be used to refer to the absolute path of the workspace folder. In this case, we will name the folder gazebo_dart:

export WS=$HOME/ws/gazebo_dart
mkdir -p ${WS}/src

Clone catkin and the packages you want to build into this folder:

cd ${WS}/src
git clone https://github.com/ros/catkin.git
git clone https://github.com/bulletphysics/bullet3.git
git clone https://github.com/dartsim/dart.git
hg clone https://bitbucket.org/osrf/sdformat
hg clone https://bitbucket.org/osrf/gazebo

Checkout the appropriate branch for each repository. For example, gazebo5 doesn't support dart5.

cd ${WS}/src/gazebo
hg up default
cd ${WS}/src/dart
git checkout release-6.2

Add package.xml files for the plain cmake packages:

curl https://bitbucket.org/scpeters/unix-stuff/raw/master/package_xml/package_bullet.xml    > ${WS}/src/bullet3/package.xml
curl https://bitbucket.org/scpeters/unix-stuff/raw/master/package_xml/package_dart-core.xml > ${WS}/src/dart/package.xml
curl https://bitbucket.org/scpeters/unix-stuff/raw/master/package_xml/package_gazebo.xml    > ${WS}/src/gazebo/package.xml
curl https://bitbucket.org/scpeters/unix-stuff/raw/master/package_xml/package_sdformat.xml  > ${WS}/src/sdformat/package.xml

Initialize the catkin workspace:

cd ${WS}
catkin init

Then build the workspace using catkin build. Note that bullet and DART have several important cmake options. Using bullet with gazebo requires BUILD_SHARED_LIBS=ON and has better accuracy if USE_DOUBLE_PRECISION=ON. Using DART with Gazebo is compatible with BUILD_CORE_ONLY=ON, which requires many fewer dependencies to be installed. For now, these options do not overlap, so they can be sent to all the packages:

cd ${WS}
catkin build -vi --cmake-args \
  -DBUILD_CORE_ONLY=ON \
  -DBUILD_SHARED_LIBS=ON \
  -DUSE_DOUBLE_PRECISION=ON

This will build all the packages in order with verbose output. Omit the -vi option to see less console output.

Once the build has completed, source the setup file located in ${WS}/devel/setup.bash to run gazebo:

. ${WS}/devel/setup.bash
gazebo -e bullet
gazebo -e dart

Other packages can be added to the catkin workspace as long as they have a package.xml that lists their dependencies.

Uninstalling Source-based Install

If you need to uninstall Gazebo or switch back to a debian-based install of Gazebo when you currently have installed Gazebo from source, navigate to your source code directory's build folders and run make uninstall:

cd ~/gazebo/build
sudo make uninstall
cd ~/sdformat/build
sudo make uninstall

Compiling From Source (Mac OS X)

Gazebo and several of its dependencies can be compiled on OS X with Homebrew using the osrf/simulation tap. Here are the instructions:

  1. Install homebrewruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  2. Install XQuartz, which provides X11 support and is required by Gazebo and OGRE

  3. For 10.8 and earlier, install Xcode command-line tools by downloading them from Apple. For 10.9 and later, they should prompt you to install them when you install Homebrew in step 1.

  4. Run the following commands:

    brew tap osrf/simulation
    brew install default
    gazebo
    

Optional dependencies

The gazebo formula has two optional dependencies: the Bullet and Simbody physics engines. To install with these physics engines:

brew install default --with-bullet --with-simbody
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值