0
$\begingroup$

I am new with ROS, just started few days ago basically. I have one question regarding my workspace and packages.

Let's say I created my workspace catkin_ws and I cloned in src folder git repository. That git repository have multiple packages. Each package has some dependencies (i.e. other packages that he depends on). There is big probability that I will not have all of those dependencies installed and that I will need to install some.

Let's say that I have run now catkin_make in my catkin_ws directory. Because I do not have specific packages (i.e. dependencies) installed, error will be generated. At this point I am confused. I found three ways of dealing this problem, and I will describe them now and possible issues:

  1. Cloning git repository of that specific dependency (i.e. package) that is missing into the src folder of my workspace.

    • This would mean that I would have to clone every git repository for every dependency that I am missing, and this can go nested. So in my opinion this solution is not optimal.
  2. Installing each specific dependency (i.e. package) that is missing into using apt-get.

    • Also this would require to install every dependency that is missing manually, and also this can go nested.
    • But all dependencies that are needed for certain ros project are given by manufacturer so I could simple install them in one go.
  3. Installing all missing dependencies using rosdep as follows: rosdep install --from-paths src --ignore-src -r -y from my workspace folder catkin_ws

    • So this command would go to my src folder, look at each package's package.xml file and install dependencies that are missing (theoreticaly).
    • But apparently even if I run this command, and then catkin_make there are still some dependencies missing that cannot be installed with this command. Then I applied 1st method and it worked.

Also is it better to install dependencies in my workspace rather than in system directory /opt/ros/noetic/share? But I do not know how to install them in my workspace using method number 3 (rosdep). Even though I run that command in my workspace folder dependencies are installed in system directory.

Also I did not used method number 2 so far, because I wanted to try to install dependencies in my workspace, and this method number 2 is installing somewhere else I suppose, but not in my directory obviously.

Can someone explain me these things, and tell me is my understanding of this correct? Can you tell me also how to install dependencies in most secure and convenient way.

All these things I was experimenting when I tried to run gmapping SLAM with turtlebot3.

$\endgroup$

1 Answer 1

3
$\begingroup$

It looks like you have a question about best practicies for managing dependencies in ROS 1. Using rosdep is the prefferred route during development (option 3). However, option 1 (building everything from source) is viable when you need to patch one of your dependencies.

The reason rosdep is preferred is because will use the right package manager on your operating system. If you use Ubuntu it will use apt-get. If you (or someone else) uses Fedora, then rosdep will use dnf or yum.

You're correct that rosdep install --from-paths src --ignore-src -r -y will look at all packages in your src folder, look at each package.xml, and install the missing dependencies. If there are any missing dependencies after running that command, then it wasn't specified in any package.xml file in the workspace.

The fix is to add the dependency to the package.xml of the package that needs it, but how you do that depends on what type of dependency it is. There are two kinds of dependencies:

  • ROS packages (packages installed from http://packages.ros.org)
  • System dependencies (packages installed from the regular apt repos)

ROS packages (such as gmapping or move_base), are packages that are released into ROS. All you need to do is add the name of the package as specified in its package.xml. If all you know is the debian package name, remove ros-<rosdistro> and replace any dashes - with underscores _. The name to put in your package.xml for ros-noetic-gmapping would be gmapping for the gmapping package, or move_base for ros-noetic-move-base, etc.

System packages are normal packages that you could install without ROS, such as libgflags-dev. All you need to know is the name of the rosdep key for that dependency. The rosdep key is an alias that will map to the right package name on your platform. You can find rosdep keys by searching for them on https://index.ros.org . If you use gflags in your package, searching for gflags on index.ros.org will tell you the name of the rosdep key is libfglags-dev. Generally the rosdep key name is the same as the Debian/Ubuntu package name.

If there is no rosdep key for your package, then in the short term use apt-get, but also consider contributing a rosdep rule for it.

$\endgroup$
1
  • $\begingroup$ I agree with what Shane says, but there is often a much simpler way: if your platform has a binary ros repo, just install the top-level package using apt. All the dependencies will automatically be installed in /opt/ros/. For your specific case, installing the apt package ros-noetic-gmapping would have done it all painlessly. $\endgroup$
    – Mike973
    Commented May 18, 2023 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.