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:
- figure out the package that hosts the/those node(s)
- retrieve the source code of the package
- 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:
- topic is published to
- topic is subscribed to
- 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:
- 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)
- 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 grep
ping through source code: the ROS log(s). It might be possible to print out the source line nr (when configured using ROSCONSOLE_FORMAT) and a sufficiently high logging level (DEBUG
or even higher). If this works, I wouldn't recommend doing this in production systems though.
Edit 3:
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
This is a good example of what I described in my original answer ("dynamic topic name creation"): that topic name is not something you will find directly in the sources of any of those packages, as it's dynamically created inside a xacro macro (here) that loads a Gazebo camera plugin (here) which finally is instantiated here with the argument "down"
.
Taking all that together we end up with a Gazebo sensor
that uses a Gazebo ROS Camera plugin, has the name camera_down
and publishes on the topic /pioneer3at/camera_down/image_raw
(as you can see here).
The complete string /pioneer3at/camera_down/image_raw
doesn't appear in any of these sources, but if we take the dynamic behaviour of all the involved components into account we can figure it out.
Note that in this particular case grep
ping the output of xacro
after converting the pioneer3at.urdf.xacro
file with the proper arguments supplied would have resulted in at least parts of the topic name appearing in the .urdf
file.
Originally posted by gvdhoorn with karma: 86574 on 2019-03-03
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by nbro on 2019-03-03:
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.
Comment by gvdhoorn on 2019-03-03:\
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.
Comment by gvdhoorn on 2019-03-03:\
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.
Comment by nbro on 2019-03-03:
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.
Comment by nbro on 2019-03-03:
Yes, but I am referring to the package inside the workspace pioneer3at_simulation
. I only used this package.
Comment by gvdhoorn on 2019-03-03:
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.
Comment by nbro on 2019-03-03:
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