Ask Your Question
0

Where can I find the file where a specific topic was created?

asked 2019-03-03 08:30:40 -0600

nbro gravatar image

updated 2019-03-03 08:32:02 -0600

I can see the available topics using rostopic list. However, I would like to see the files (the source code) where they are being published from (or where they have been created). Is this possible somehow? When I execute the comand rostopic list I see certain topics which I can't find anywhere inside the ROS package which is supposed to have created them.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-03-03 08:47:07 -0600

gvdhoorn gravatar image

updated 2019-03-03 10:28:54 -0600

I would like to see the files (the source code) where they are being published from (or where they have been created). Is this possible somehow?

In general (and with "a single command")? No, I would say you can't. Not with any of the command line tools that are provided "as part of a standard ROS install".

If however you know which nodes are publishing or subscribing to those topics (note: topics are not "created", in fact, in some sense they do not really even "exist"), you could:

  1. figure out the package that hosts the/those node(s)
  2. retrieve the source code of the package
  3. use something like grep to find occurences of the topic name in the code

But note though: due to remapping and dynamic topic name creation, there is no guarantee at all that you will be able to find the publishers this way. Especially with Python nodes, as Python is so flexible that many "crazy" things can be done at runtime making this sort of sleuthing rather difficult.

I see certain topics which I can't find anywhere inside the ROS package which is supposed to have created them.

nitpick: nodes can be publishers. Packages can't.

Also note that rostopic list shows you a topic name in three cases:

  1. topic is published to
  2. topic is subscribed to
  3. topic is both published and subscribed to

So it could be that a subscriber causes a topic to appear in rostopic list, and that subscriber could be "anywhere".


Edit:

I'm trying to use this ROS package. After having launched the Pioneer 3AT, if I type rostopic list, I see a bunch of topics related to the Pioneer, but I can't find the place where they are being published from.

Looking at the repository you linked, two things stand out:

  1. this is not a package, but an entire workspace with one package (pioneer3at_simulation) and two git submodules pointing to other repositories (with even more packages)
  2. the main package pioneer3at_simulation provides a collection of .launch files (here) that together start (among other things): gazebo and something called teleop_joy.

Gazebo then is configured to load various .world files, urdf_spawner is then used to inject a model of a 3-AT, that loads multiple Gazebo plugins, etc, etc. I haven't checked the two repositories linked in via the git submodules, but I expect those to also either provide additional nodes and/or plugins.

Gazebo, the teleop nodes and all of the Gazebo plugins will both publish and subscribe to topics, and those will appear in rostopic list.

So in order to find "the file where a specific topic was created", you'd have to check the sources of all those packages.


Edit2: I haven't checked, but there is a small chance that you could actually figure out where a topic is published or subscribed to without grepping through source code: the ROS log(s). It might be possible to print out the source line nr (when configured ... (more)

edit flag offensive delete link more

Comments

I even tried to use grep to find the topics, but I didn't find them. Anyway, yes, I was aware of the fact that you can't create topics (but I used the term "create" not to use both publish and subscribe). I also know that topics are published by nodes, but nodes reside inside packages.

nbro gravatar imagenbro ( 2019-03-03 08:53:59 -0600 )edit

I even tried to use grep to find the topics, but I didn't find them

If you can give an example of a topic you couldn't find, perhaps I can try to see/explain why that could have been the case.

gvdhoorn gravatar imagegvdhoorn ( 2019-03-03 08:57:10 -0600 )edit
1

I also know that topics are published by nodes, but nodes reside inside packages.

True, but: I live in a house, and I make bread sometimes. My house doesn't make bread, I do.

gvdhoorn gravatar imagegvdhoorn ( 2019-03-03 08:58:00 -0600 )edit

I'm trying to use this ROS package. After having launched the Pioneer 3AT, if I type rostopic list, I see a bunch of topics related to the Pioneer, but I can't find the place where they are being published from.

nbro gravatar imagenbro ( 2019-03-03 09:12:38 -0600 )edit

Yes, but I am referring to the package inside the workspace pioneer3at_simulation. I only used this package.

nbro gravatar imagenbro ( 2019-03-03 10:00:06 -0600 )edit

I believe my answer still applies. That pkg contains a nr of launch files that start all sorts of nodes, from a nr of other packages.

If you can give an example of a topic name that you can't find (as I asked earlier), perhaps that could be explained.

gvdhoorn gravatar imagegvdhoorn ( 2019-03-03 10:02:24 -0600 )edit

For example, using rostopic list, I see the topic /pioneer3at/camera_down/image_raw. The only place inside that package where I find that topic is in the file rqt_gui_cameras.perspective

nbro gravatar imagenbro ( 2019-03-03 10:04:56 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-03-03 08:30:40 -0600

Seen: 115 times

Last updated: Mar 03 '19