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

Revision history [back]

From what I can tell, the core of your question is "how can I find the source code of a package?" 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 http://wiki.ros.org. Usually a Google search brings this up. For gmapping, this page is http://wiki.ros.org/gmapping.
  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!

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

Edit:

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 http://packages.ros.org/ros/ubuntu 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.

Original:

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 http://wiki.ros.org. Usually a Google search brings this up. For gmapping, this page is http://wiki.ros.org/gmapping.
  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!