ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Where are the source codes stored?

asked 2018-06-28 15:29:10 -0500

aarontan gravatar image

Hello all,

I am a new ros user trying to get familiar with the environment. I am working with the husky mobile robot package and I am wondering, when I launch the gmapping_demo.launch file in husky_navigation, I know it launches gmapping.launch subsequently.

In the gmapping.launch file, it starts a node with the gmapping question is, where is the source code for gmapping actually stored in my computer?

I know that there is a gmapping package like this available on github; however, I never installed this so how does my system know how to run gmapping with just installing the husky package? For example, in this package, there is a slam_gmapping/gmapping/src folder that contains the slam_gmapping.cpp file which I believe is the code that makes gmapping work. I am essentially trying to find the slam_gmapping.cpp from the slam_gmapping package in my computer.

I must be missing something ...

edit retag flag offensive close merge delete


Did you do the Desktop-full install?

jayess gravatar image jayess  ( 2018-06-28 17:28:22 -0500 )edit

yes I did desktop-full install

aarontan gravatar image aarontan  ( 2018-06-28 18:10:02 -0500 )edit

Simply do roscd to the package_name . It will take you to the directory and you will know

chrissunny94 gravatar image chrissunny94  ( 2018-06-29 02:25:18 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2018-06-29 12:10:19 -0500

updated 2018-07-02 10:50:55 -0500

From what I can tell, the core of your question is "how can I find the source code of a package?"


A quicker way to do this, as pointed out by @gvdhoorn, is to add the following line to /etc/apt/sources.list.d/ros-latest.list:

+ deb-src xenial main

Then, you can run

sudo apt-get source ros-ROSDISTRO-PACKAGE

to download a copy of all of the source code to the current directory. Now that you have the source, follow step 4 to find the main.


Like Jayess mentioned, installing ROS packages from apt won't download the source code to your computer. This is something I've ran into several times before, and I have a quick and dirty procedure for it:

  1. Figure out the name of the ROS package that I actually want to look at. In this case, you already know it's gmapping.
  2. Find the package's page on . Usually a Google search brings this up. For gmapping , this page is .
  3. On the wiki, most packages link to their source code, usually right below the maintainer list (see the MoveIt page for an example). gmapping is unique in this case, because they are mostly external to ROS. However, they provide a link on their page to the external documentation, which contains a link to the Github source code.
  4. Now that you're at the source code, you probably want to find some launch file, so you follow the code from the beginning. Again, gmapping is unique because they aren't a native ROS project. At this point, I just had to do some smart Googling to find the real Github, specifically for the ROS gmapping code. Now, going to the launch file, we see that it starts a single node, named slam_gmapping. This is the name of the executable started, so if we go over to the CMakeLists.txt, we see that this executable is compiled from slam_gmapping.cpp and main.cpp. Now you're at the start of the code!
edit flag offensive delete link more



Slightly more 'official' and/or appropriate way to do this: wiki/DebianPackageSources.

gvdhoorn gravatar image gvdhoorn  ( 2018-06-30 01:27:28 -0500 )edit

Thanks gvdhoorn! I've updated the answer to use your clearly less convoluted solution.

BryceWilley gravatar image BryceWilley  ( 2018-07-02 10:51:44 -0500 )edit

The biggest advantage I feel is that you get the sources that correspond to whatever binary you have installed / is the currently released version for your platform.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-02 11:17:09 -0500 )edit

After editing the file /etc/apt/sources.list.d/ros-latest.list , do not forget apt-get update. Otherwise apt-get will not be able to locate ROS packages.

burakaksoy gravatar image burakaksoy  ( 2018-11-28 11:33:16 -0500 )edit

answered 2018-06-28 17:34:20 -0500

jayess gravatar image

updated 2018-06-28 18:21:50 -0500

You obviously did install gmapping because you're using it! I'm guessing that you did the Desktop-full install. If that's the case, just check what packages the install page says are installed

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

From the above quote (emphasis is mine), you can see that ros-perception is added, which contains gmapping.

It's also listed as a dependency in the package that you linked to, so if you installed the husky package via apt, then gmapping would have been installed too.


You linked to the source. As far as I know you're not going to find the source on your computer (unless you compiled it manually). If you install something using apt you're installing a binary, not putting the source on your computer. If you want to read the source you should look at the repository that stores the source.

Update 2:

So, I double checked and you can find some headers in


edit flag offensive delete link more


I know that gmapping is installed because I am using it but I do not know where the file is stored. I'd like to find the slam_gmapping.cpp in my computer so that I can read the code that makes gmapping work

aarontan gravatar image aarontan  ( 2018-06-28 18:09:04 -0500 )edit

my question applies to other pkg's as well, where does ros store the source codes of these fundamental pkgs to make them work?

aarontan gravatar image aarontan  ( 2018-06-28 18:09:50 -0500 )edit

Question Tools



Asked: 2018-06-28 15:29:10 -0500

Seen: 2,778 times

Last updated: Jul 02 '18