Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use getTopicTypes() in /rosapi/get_topics for increased performance #381

Merged
merged 1 commit into from
Dec 31, 2018

Conversation

Affonso-Gui
Copy link
Contributor

Hello,

When using rosapi in the development of web applications for the PR2 robot, I was facing the problem that the call for the /rosapi/topics service was extremely slow (operating with over 1200 topics).

Looking into the problem, it seems that getting the types was taking a lot of time:

In [3]: time topics = get_topics(['*'])
CPU times: user 152 ms, sys: 0 ns, total: 152 ms
Wall time: 183 ms

In [4]: time types = get_topics_types(topics, ['*'])
CPU times: user 1min 18s, sys: 428 ms, total: 1min 18s
Wall time: 2min 6s

By using the Master.getTopicTypes() we can get equivalent results (the order changes) with better performance:

In [5]: time new_topics, new_types = get_topics_and_types(['*'])
CPU times: user 244 ms, sys: 0 ns, total: 244 ms
Wall time: 297 ms

In [6]: set(new_topics) == set(topics) and set(types) == set(new_types)
Out[6]: True

Note that differently from Master.getSystemState(), Master.getTopicTypes() also includes inactive topics and does not include topics with unknown messages.

Related to: ros/ros_comm#53

@jihoonl jihoonl merged commit d896276 into RobotWebTools:develop Dec 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants