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

How to get nodes and topics without ros running

asked 2018-07-04 06:54:41 -0500

Lycea gravatar image

So I tried to get my head arround how to best solve this problem but I'm probably missing a simple solution. i have a ros workspace. In this workspace I have multiple packages. And in each package I have probably multiple ros nodes.

Now what I want to do is I want to write a script that can get my all the nodes and possibly also all the publishers subscribers. Also if possible the parameters and services .

One idea of me was getting all the packages via the rospack list | workspace_name and that also works great to get the packages in the workspace.

But now the problem is how to I get all the publishers /subscribers. I know that I could get them online if the node is running via the rosnode command but how should I do this offline.

I hope I just overlooked something, I hope someone could help me what the offline methode for this is.

For additional information I'm working on ros Kinetic on Ubuntu 16.04.

edit retag flag offensive close merge delete

Comments

Why do you want to do that ? Being "offline" means that you don't initialize your nodes and publishers/subscribers and everything else so you won't be able to find anything.

Delb gravatar image Delb  ( 2018-07-04 10:04:54 -0500 )edit

I second the comment by @Delb: it would be good if you can provide some more context. Perhaps easier alternatives or more suitable approaches exist for what your ultimate goal is.

gvdhoorn gravatar image gvdhoorn  ( 2018-07-05 02:40:48 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2018-07-04 10:14:08 -0500

I think grep is your best option. Navigate to the src directory of your Catkin workspace to issue these commands.

List Python and C++ nodes:

grep -Er "rospy.init_node|ros::init"

List Python and C++ subscribers:

grep -Er "rospy.Subscriber|.subscribe\("

List Python and C++ publishers:

grep -Er "rospy.Publisher|.advertise<"

List Python and C++ services:

grep -Er "rospy.Service\(|.advertiseService\("

Note that this assumes in Python you always call things relative to rospy. For C++ you could also grep on ros::Subscriber, ros::Publisher, and ros::ServiceServicer, but I did it the way I did so you can account for when you have separate header and source files - the commands I provide pick up on where the actual definition is provided.

edit flag offensive delete link more

Comments

Thank you for that answer that was what I was searching for . I did it now in a kind of similar way to as you wrote. :)

Lycea gravatar image Lycea  ( 2018-08-07 04:22:12 -0500 )edit
0

answered 2018-07-05 02:39:54 -0500

gvdhoorn gravatar image

It 'only' (between quotes as it's already quite impressive) works for C++ at the moment, but perhaps haros can help here.

Running haros analyse:

[..] runs analysis and model extraction on a given list of packages.

See the readme for how to further use this.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-07-04 06:54:41 -0500

Seen: 621 times

Last updated: Jul 05 '18