ROS By Example_hydro_volume1_CN_5

5. INSTALLING THE ROS-BY-EXAMPLE CODE


5.1 Installing the Prerequisites
    Before installing the ROS By Example code itself, it will save some time if we install most of the additional ROS packages we will need later. (Instructions will also be provided for installing individual packages as needed throughout the book.) Simply copy and paste the following command (without the $ sign) into a terminal window to install the Debian packages we will need. The \ character at the end of each line makes the entire block appear like a single line to Linux when doing a copy-and-paste:

$ sudo apt-get install ros-hydro-turtlebot-* \
ros-hydro-openni-camera ros-hydro-openni-launch \
ros-hydro-openni-tracker ros-hydro-laser-* \
ros-hydro-audio-common ros-hydro-joystick-drivers \
ros-hydro-orocos-kdl ros-hydro-python-orocos-kdl \
ros-hydro-dynamixel-motor-* ros-hydro-pocketsphinx \
gstreamer0.10-pocketsphinx python-setuptools python-rosinstall \
ros-hydro-opencv2 ros-hydro-vision-opencv \
ros-hydro-depthimage-to-laserscan ros-hydro-arbotix-* \
git subversion mercurial


5.2 Cloning the Hydro ros-by-example Repository


    IMPORTANT: If you have installed previous versions of the ros-by-example repository for ROS Electric, Fuerte or Groovy, follow the appropriate instructions below to replace or override your installation with the Hydro version. Note that all three previous versions of the ros-by-example code used the rosbuild system whereas
the Hydro version now uses catkin. If this is your first time installing the ros-by-example code, you can skip the first two sections and go straight to section 5.2.3.

    重要提示:如果您已经安装了ros-by-example的ROS lectric,Fuerte或Groovy的早期版本,请按照下面的相应说明,用hydro取代或覆盖您之前安装版本。需要注意的是的ros-by-example代码,所有三个以前的版本中使用的rosbuild系统,而hydro使用catkin。如果这是你第一次安装的ROS按示例代码,你可以跳过前两个部分,直接进入第5.2.3节。


5.2.1 Upgrading from Electric or Fuerte
    The ros-by-example stack for ROS Electric and Fuerte is distributed as an SVN repository called rbx_vol_1 on Google Code. Either remove the this old stack from your ~/ros_workspace directory or, if you've made modifications you don't want to lose, move the old rbx_vol_1 directory out of your ROS_PACKAGE_PATH before
installing the new repository.

    The ros-by-example stack for ROS Electric and Fuerte是名为rbx_vol_1的SVN库分布在谷歌代码中。要么从您的〜/ ros_workspace目录中删除这个旧堆栈,或者,如果你已经做了你不想失去的修改,在安装新仓库之前将旧RBX_vol_1目录从你的ROS_PACKAGE_PATH路径中移除。


5.2.2 Upgrading from Groovy
    The ros-by-example packages for ROS Groovy and Hydro are distributed as a Git repository called rbx1 on GitHub. The default branch is called groovy-devel and it is a rosbuild version of the repository used with the Groovy version of the book. For ROS Hydro, you need to use the hydro-devel branch of the repository which as been converted to the newer catkin build system. This means you also need to install the code in your personal ~/catkin_ws/src directory rather than ~/ros_workspace.

    The ros-by-example packages for ROS Groovy and Hydro分布在GitHub上名为rbx1的Git库。默认的分支为groovy-devel,它是Groovy的版本书中使用的rosbuild版本库。对于ROS hydro,你需要使用hydro-devel软件包分支,这个软件包已经转换为新的catkin构建系统。这意味着你还需要在你的个人〜/ catkin_ws/ src目录中安装代码,而不是〜/ ros_workspace。


    If you have been using the Groovy version of the rbx1 code, either delete the old repository from your ~/ros_workspace directory or, if you've made modifications you don't want to lose, move the old rbx1 directory out of your ROS_PACKAGE_PATH before installing the new repository.

5.2.3 Cloning the rbx1 repository for Hydro
    To clone the rbx1 repository for Hydro, follow these steps:
$ cd ~/catkin_ws/src
$ git clone https://github.com/pirobot/rbx1.git
$ cd rbx1
$ git checkout hydro-devel
$ cd ~/catkin_ws
$ catkin_make
$ source ~/catkin_ws/devel/setup.bash



    NOTE 1: The fourth command above (git checkout hydro-devel) is critical—this is where you select the Hydro branch of the repository. (By default, the clone operation checks out the Groovy branch for the benefit of those still using Groovy.)

    注1:上述(git checkout hydro-devel)第四条命令是至关重要的,这是你选择的hydro包分支所在地。 (默认情况下,克隆操作检出Groovy的分支那些仍然使用Groovy。)


    NOTE 2: The last line above should be added to the end of your ~/.bashrc file if you haven't done so already. This will ensure that your catkin packages are added to your ROS_PACKAGE_PATH whenever you open a new terminal. If you will be running a mix of rosbuild and catkin packages, refer back to section 4.7 in Chapter 4 on how to set up your ~/.bashrc file so that both types of packages can be found.


    If the ROS By Example code is updated at a later time, you can merge the updates with
your local copy of the repository by using the following commands:
    如果ROS通过示例代码在之后更新,您可以使用以下命令存储库的本地副本与更新的代码合并:

$ cd ~/catkin_ws/src/rbx1
$ git pull
$ cd ~/catkin_ws
$ catkin_make
$ source devel/setup.bash



    Staying Up-To-Date: If you'd like to receive notifications of updates to both the book and the accompanying code, please join the ros-by-example Google Group.
    All of the ROS By Example packages begin with the letters rbx1. To list the packages, move into the parent of the rbx1 meta-package and use the Linux ls command:

$ roscd rbx1
$ cd ..
$ ls -F



    which should result in the following listing:
rbx1/
rbx1_apps/
rbx1_bringup/
rbx1_description/
rbx1_dynamixels/
rbx1_experimental/
rbx1_nav/
rbx1_speech/
rbx1_vision/
README.md
    Throughout the book we will be using the roscd command to move from one package to another. For example, to move into the rbx1_speech package, you would use the command:

$ roscd rbx1_speech



    Note that you can run this command from any directory and ROS will find the package. IMPORTANT: If you are using two computers to control or monitor your robot, such as a laptop on the robot together with a second computer on your desktop, be sure to
clone and build the Hydro branch of the rbx1 repository on both machines.

5.3 About the Code Listings in this Book


    For the benefit of those who would like to work from a printed version of the book instead of or in addition to the PDF version, most of the sample programs are displayed in their entirety as well as broken down line-by-line for analysis. At the top of each sample script is a link to the online version of the file as found in the ROS By Example repository. If you are reading the PDF version of the book, clicking on the link will bring you to a nicely formatted and color coded version of the program. Be aware though that the line numbers in the online version will not match those in the book since the printed version leaves out some extraneous comments to save space and make things easier to read. Of course, once you have downloaded the code from the ROS By Example repository, `you can also bring up your local copy of the same files in your favorite editor.
    As with most programming code, there is usually more than one way to solve a problem. The sample programs described here are no exception and if you can think of a better way to accomplish the same goal, great. The code included in the ROS By Example
repository is meant only as a guide and certainly does not represent the best or only way to accomplish a given task using ROS.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值