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.
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
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
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.
You should new see a directory
~/catkin_ws/src/nre_p3at and that directory should have the files
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...
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...
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...
Then to check that I have the correct branch, I would do...
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.)
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.
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...
If this executes error-free, we should be in good shape.
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".)
This should tell us if there are unmet dependencies. If so, we can install them with
Packages from source - you may get an error that looks something like this...
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.