ROS学习笔记(一)安装与配置ROS with ubuntu16.04LTS

    xiaoxiao2022-07-13  147

    Contents

    Install ROS

    Managing Your Environment

    Create a ROS Workspace

     

    1. Install ROS

    Before starting these tutorials please complete installation as described in the ROS installation instructions.

     

    Note: If you installed ROS from a package manager like apt, then those packages will not be write accessible and should not be edited by you the user. When working with ROS packages from source or when creating a new ROS package, you should always work in a directory that you have access to, like your home folder.

     

     

    Installation

    ROS Kinetic ONLY supports Wily (Ubuntu 15.10), Xenial (Ubuntu 16.04) and Jessie (Debian 8) for debian packages.

     

     

    Configure your Ubuntu repositories

    Configure your Ubuntu repositories to allow "restricted," "universe," and "multiverse." You can follow the Ubuntu guide for instructions on doing this.

     

    Setup your sources.list

    Setup your computer to accept software from packages.ros.org.

    sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

     

    Set up your keys

    sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

     

    If you experience issues connecting to the keyserver, you can try substituting hkp://pgp.mit.edu:80 or hkp://keyserver.ubuntu.com:80 in the previous command.

     

    Installation

    First, make sure your Debian package index is up-to-date:

    sudo apt-get update

     

    There are many different libraries and tools in ROS. We provided four default configurations to get you started. You can also install ROS packages individually.

    In case of problems with the next step, you can use following repositories instead of the ones mentioned above ros-shadow-fixed

    Desktop-Full Install: (Recommended) : ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators, navigation and 2D/3D perception

    sudo apt-get install ros-kinetic-desktop-full

    or click here

    Desktop Install: ROS, rqt, rviz, and robot-generic libraries

    sudo apt-get install ros-kinetic-desktop

    or click here

    ROS-Base: (Bare Bones) ROS package, build, and communication libraries. No GUI tools.

    sudo apt-get install ros-kinetic-ros-base

    or click here

    Individual Package: You can also install a specific ROS package (replace underscores with dashes of the package name):

    sudo apt-get install ros-kinetic-PACKAGE e.g. sudo apt-get install ros-kinetic-slam-gmapping

    To find available packages, use:

    apt-cache search ros-kinetic

     

    Initialize rosdep

    Before you can use ROS, you will need to initialize rosdep. rosdep enables you to easily install system dependencies for source you want to compile and is required to run some core components in ROS.

     

    sudo rosdep init rosdep update

    Environment setup

    It's convenient if the ROS environment variables are automatically added to your bash session every time a new shell is launched:

     

    echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc source ~/.bashrc

    If you have more than one ROS distribution installed, ~/.bashrc must only source the setup.bash for the version you are currently using.

    If you just want to change the environment of your current shell, instead of the above you can type:

     

    source /opt/ros/kinetic/setup.bash

    If you use zsh instead of bash you need to run the following commands to set up your shell:

     

    echo "source /opt/ros/kinetic/setup.zsh" >> ~/.zshrc source ~/.zshrc

     

    Dependencies for building packages

    Up to now you have installed what you need to run the core ROS packages. To create and manage your own ROS workspaces, there are various tools and requirements that are distributed separately. For example, rosinstall is a frequently used command-line tool that enables you to easily download many source trees for ROS packages with one command.

    To install this tool and other dependencies for building ROS packages, run:

     

    sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

     


    2. Managing Your Environment

    During the installation of ROS, you will see that you are prompted to source one of several setup.*sh files, or even add this 'sourcing' to your shell startup script. This is required because ROS relies on the notion of combining spaces using the shell environment. This makes developing against different versions of ROS or against different sets of packages easier.

    If you are ever having problems finding or using your ROS packages make sure that you have your environment properly setup. A good way to check is to ensure that environment variables like ROS_ROOT and ROS_PACKAGE_PATH are set:

    $ printenv | grep ROS

    If they are not then you might need to 'source' some setup.*sh files.

    Environment setup files are generated for you, but can come from different places:

    ROS packages installed with package managers provide setup.*sh files

    rosbuild workspaces provide setup.*sh files using tools like rosws

    Setup.*sh files are created as a by-product of building or installing catkin packages

     

    Note: Throughout the tutorials you will see references to rosbuild and catkin. These are the two available methods for organizing and building your ROS code. rosbuild is not recommended or maintained anymore but kept for legacy. catkin is the recommended way to organise your code, it uses more standard CMake conventions and provides more flexibility especially for people wanting to integrate external code bases or who want to release their software. For a full break down visit catkin or rosbuild.

    If you just installed ROS from apt on Ubuntu then you will have setup.*sh files in '/opt/ros/<distro>/', and you could source them like so:

     

    $ source /opt/ros/<distro>/setup.bash

    Using the short name of your ROS distribution instead of <distro>

    If you installed ROS Kinetic, that would be:

     

    $ source /opt/ros/kinetic/setup.bash

    You will need to run this command on every new shell you open to have access to the ROS commands, unless you add this line to your .bashrc. This process allows you to install several ROS distributions (e.g. indigo and kinetic) on the same computer and switch between them.

    On other platforms you will find these setup.*sh files wherever you installed ROS.


    3. Create a ROS Workspace

    When working with ROS source code, it is often useful to do so in a "workspace". For the following ROS tutorials you will need an area for working on tutorials and creating new ROS stacks and packages.

    rosws is a tool that provides a uniform interface to various version control systems such as SVN, Git and Mercurial and for managing all packages installed in a ROS overlay. An extensive tutorial on rosws can be found here.

     

    Creating a new workspace

    The following command creates a new workspace in ~/fuerte_workspace which extends the set of packages installed in /opt/ros/fuerte:

    rosws init ~/fuerte_workspace /opt/ros/fuerte

    Note: rosws is part of the rosinstall package, which is not installed by default. The following command downloads it using the Ubuntu package manager:

    sudo apt-get install python-rosinstall

     

    Creating a sandbox directory for new packages

    New packages need to be put in a path that is in the variable ROS_PACKAGE_PATH. All directories that are managed by rosws, i.e. that have been added using rosws are automatically added to the ROS_PACKAGE_PATH when the file setup.bash of the corresponding workspace is sourced. Although new packages should always be put in repositories that have been installed using rosws, it can be very convenient to have a sandbox directory where for instance packages created during the tutorials can be put without requiring any additional rosws commands. For that we create a new directory sandbox and add it to the hidden .rosinstall file with rosws:

    mkdir ~/fuerte_workspace/sandbox rosws set ~/fuerte_workspace/sandbox

    Every time the entries in the workspace change, it is necessary to re-source ~/fuerte_workspace/setup.bash to make sure that the updated ROS_PACKAGE_PATH is used.

     

    source ~/fuerte_workspace/setup.bash

    It is very common to replace the line source /opt/ros/fuerte/setup.bash to source the setup.bash in ~/fuerte_workspaceor whichever workspace you use most often.

    A more complete ROS Workspace tutorial can be found here.

     

    Confirmation

    To confirm that your package path has been set, echo the ROS_PACKAGE_PATH variable.

     

    $ echo $ROS_PACKAGE_PATH

    You should see something similar to:

     

    /home/your_user_name/fuerte_workspace/sandbox:/opt/ros/fuerte/share:/opt/ros/fuerte/stacks

     

    最新回复(0)