The code used in this tutorial is available!

Code can be found at industrial_training repository in doc folder. Use kinetic-devel branch.

Installing Packages

Motivation

Many of the coolest and most useful capabilities of ROS already exist somewhere in its community. Often, stable resources exist as easily downloadable debian packages. Alternately, some resources are less tested or more "cutting edge" and have not reached a stable release state; you can still access many of these resources by downloading them from their repository (usually housed on Github). Getting these git packages takes a few more steps than the debian packages. In this module we will access both types of packages and install them on our system.

Reference Example

apt-get usage

Scan-N-Plan Application: Problem Statement

We have a good installation of ROS, and we have an idea of some packages that exist in ROS that we would like to use within our program. We have found a package which is stable and has a debian package we can download. We've also found a less stable git package that we are interested in. Go out into the ROS world and download these packages!

  1. A certain message type exists which you want to use. The stable ROS package is called: calibration_msgs
  2. You are using an AR tag, but for testing purposes you would like a node to publish similar info : fake_ar_publisher

Your goal is to have access to both of these packages' resources within your package/workspace:

  1. calibration_msgs (using apt-get)
  2. fake_ar_publisher (from git)

Scan-N-Plan Application: Guidance

Install Package from apt Repository

  1. Open a terminal window. Type roscd calibration_msgs.

    roscd calibration_msgs
    
    • This command changes the working directory to the directory of the ROS calibration_msgs package.
    • You should see an error message `No such package/stack 'calibration_msgs' .
    • This package is not installed on the system, so we will install it.
  2. Type apt install ros-kinetic-calibration-msgs.

    apt install ros-kinetic-calibration-msgs
    
    • The program will say it cannot install the package, and suggests that we must run the program as root.
    • Try pressing the TAB key while typing the package name.
      • The system will try to automatically complete the package name, if possible.
      • Frequent use of the TAB key will help speed up entry of many typed commands.
  3. Type sudo apt install ros-kinetic-calibration-msgs.

    sudo apt install ros-kinetic-calibration-msgs
    
    • Note the use of the sudo command to run a command with "root" (administrator) privileges.
    • Enter your password, and (if asked) confirm you wish to install the program.
  4. Type roscd calibration_msgs again.

    roscd calibration_msgs
    
    • This time, you will see the working directory change to /opt/ros/kinetic/share/calibration_msgs.
  5. Type sudo apt remove ros-kinetic-calibration-msgs to remove the package.

    sudo apt remove ros-kinetic-calibration-msgs
    
    • Don't worry. We won't be needing this package for any future exercises, so it's safe to remove.
  6. Type cd ~ to return to your home directory.

    cd ~
    

Download and Build a Package from Source

  1. Identify the source repository for the desired package:

    1. Go to github.
    2. Search for fake_ar_publisher.
    3. Click on this repository, and look to the right for the Clone or Download, then copy to clipboard.
  2. Clone the fake_ar_publisher repository into the catkin workspace's src directory.

    cd ~/catkin_ws/src
    git clone https://github.com/jmeyer1292/fake_ar_publisher.git
    
    • Use Ctrl-Shift-V to paste within the terminal, or use your mouse to right-click and select paste
    • Git commands are outside of the scope of this class, but there are good tutorials available here
  3. Build the new package using catkin build
    The build command can be issued from anywhere inside the catkin workspace

  4. Once the build completes, notice the instruction to "re-source setup files to use them".

    • In the previous exercise, we added a line to our ~/.bashrc file to automatically re-source the catkin setup files in each new terminal.

    • This is sufficient for most development activities, but you may sometimes need to re-execute the source command in your current terminal (e.g. when adding new packages):

      source ~/catkin_ws/devel/setup.bash
      
  5. Once the build completes, explore the build and devel directories to see what files were created.

  6. Run rospack find fake_ar_publisher to verify the new packages are visible to ROS.

    rospack find fake_ar_publisher
    
    • This is a helpful command to troubleshoot problems with a ROS workspace.
    • If ROS can't find your package, try re-building the workspace and then re-sourcing the workspace's setup.bash file.

Open Source Feedback

See something that needs improvement? Please open a pull request on this GitHub page