0
$\begingroup$

Rosanswers logo

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 package.....my 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 ...


Originally posted by aarontan on ROS Answers with karma: 135 on 2018-06-28

Post score: 0


Original comments

Comment by jayess on 2018-06-28:
Did you do the Desktop-full install?

Comment by aarontan on 2018-06-28:
yes I did desktop-full install

Comment by chrissunny94 on 2018-06-29:
Simply do roscd to the package_name . It will take you to the directory and you will know

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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!

Originally posted by BryceWilley with karma: 711 on 2018-06-29

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by gvdhoorn on 2018-06-30:
Slightly more 'official' and/or appropriate way to do this: wiki/DebianPackageSources.

Comment by BryceWilley on 2018-07-02:
Thanks gvdhoorn! I've updated the answer to use your clearly less convoluted solution.

Comment by gvdhoorn on 2018-07-02:
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.

Comment by burakaksoy on 2018-11-28:
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.

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Update:

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

/opt/ros/<distro>/include


Originally posted by jayess with karma: 6155 on 2018-06-28

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by aarontan on 2018-06-28:
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

Comment by aarontan on 2018-06-28:
my question applies to other pkg's as well, where does ros store the source codes of these fundamental pkgs to make them work?

$\endgroup$

Your Answer

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