Page tree
Skip to end of metadata
Go to start of metadata

A common task is to reuse a ROS package from a Git repository.  The goal of this tutorial is to step you through the process.

Example Repository

For this tutorial we'll consider the specific case of a ROS package available via git at https://github.com/bsb808/nre_p3at.  You'll need to substitude the appropriate values when setting up a different package/repository.  

We are also assuming that your catkin workspace is the ~/catkin_ws directory.

Git the Package

First we'll want to clone the package in our catkin workspace.  The location of the git repository can be found on the GitHub page

Which branch?

Often, the "master" git branch is the one you want.  However, you should check the available branches in the "Branch" pull down on the github web interface. 

  • If there is only a "master" branch listed, then there aren't probably aren't distribution dependent branches. 
  • If there are other branches available, then you will want to select the branch that for your ROS distribution - this allows for code that has small changes between different distributions.

If you are are checking out the master branch

You can use the HTTPS or SSH web URL as the location of the repository.  If you aren't sure which to use, use HTTPS.

cd ~/catkin_ws/src
git clone https://github.com/bsb808/nre_p3at.git

You should new see a directory ~/catkin_ws/src/nre_p3at and that directory should have the files package.xml and CMakeLists.txt which are the information that catkin needs to create the ROS package.

If you get an error like this...

It is likely because you already have cloned the package.  In this case, it is best to go into the repository and make sure it is at the latest version...

cd ~catkin_ws/src/nre_p3at
git pull origin master

If you are are checking out the distribution-dependent branch

For some packages it is necessary to have separate branches for different ROS distributions.  For example, for ROS Indigo, you might see a branch called "indigo-devel".  The only thing that will change from the instructions above is the clone command, which will look like this...

git clone -b <branch> <remote_repo>

As a complete example, if I want to checkout the indigo-devel branch of the kingfisher_gazebo package from https://github.com/bsb808/kingfisher_gazebo/tree/indigo-devel, I would do this...

cd ~/catkin_src
git clone -b indigo-devel https://github.com/bsb808/kingfisher_gazebo.git

Then to check that I have the correct branch, I would do...

cd kingfisher_gazebo
git branch -a

which would list all the branches and show which branch I'm working with, like this...

 

Indicating we are on the indigo-devel branch which we can assume is the branch appropriate for the ROS Indigo distribution.

Make the Package

We'll need to "make" everything in our catkin workspace so that the ROS environment knows about our new package.  (This will also compile any necessary code in the package.)

cd ~/catkin_ws
catkin_make

 

Reset ROS Environmental Variables

Now you should either re-source the bash setup file (source ~/catkin_ws/devel/setup.bash) or open a new terminal window.

Check that the Package is Installed

First, you should make sure that ROS knows about the new package.  

rospack find nre_p3at

Which, if successful, confirms that our ROS system knows about the new package.

 

You may also to run one of the launch files in the package...

roslaunch nre_p3at p3at.gazebo.launch 

If this executes error-free, we should be in good shape.

Optional: Dependencies

Often, but not always, a package depends upon other packages that may or may not be installed in your system.  If you get a dependency error when trying to catkin_make then you may have missing dependencies.

Let's check to see that everything we need to use this package is installed. (Note, if you have not yet run rosdep, you will need to run "sudo rosdep init".)

rosdep update
rosdep check nre_p3at

This should tell us if there are unmet dependencies. If so, we can install them with

rosdep update
rosdep install nre_p3at

Packages from source - you may get an error that looks something like this...

bsb@aku:~/catkin_ws/src$ rosdep check nre_p3at
All system dependencies have been satisified
ERROR[nre_p3at]: Cannot locate rosdep definition for [rosaria]
	rosdep key : rosaria
	OS name    : ubuntu
	OS version : trusty
	Data: <no data>

This is telling you that we need to install a package, but that rosdep doesn't know about that package. For this particular case, the rosaria package needs to be installed. Directions for doing so are here on Pioneer P3AT Checkout. In this case, that package is called rosaria and we'll have to install it by hand.

  • No labels