Skip to content

Commit fbed931

Browse files
FlorianLebecqueMatthias Rathauscher (LWN)
authored andcommitted
Add new service to retrieve the different interfaces in the ROS Network (RobotWebTools#988)
1 parent d9c1357 commit fbed931

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

rosapi/scripts/rosapi_node

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ from rosapi_msgs.srv import (
4848
GetROSVersion,
4949
GetTime,
5050
HasParam,
51+
Interfaces,
5152
MessageDetails,
5253
NodeDetails,
5354
Nodes,
@@ -93,6 +94,7 @@ class Rosapi(Node):
9394
params.init(full_name, timeout_sec)
9495

9596
self.create_service(Topics, "/rosapi/topics", self.get_topics)
97+
self.create_service(Interfaces, "/rosapi/interfaces", self.get_interfaces)
9698
self.create_service(TopicsForType, "/rosapi/topics_for_type", self.get_topics_for_type)
9799
self.create_service(
98100
TopicsAndRawTypes,
@@ -141,6 +143,11 @@ class Rosapi(Node):
141143
response.topics, response.types = proxy.get_topics_and_types(self.globs.topics)
142144
return response
143145

146+
def get_interfaces(self, request, response):
147+
"""Called by the rosapi/Types service. Returns a list of all the types in the system."""
148+
response.interfaces = proxy.get_interfaces()
149+
return response
150+
144151
def get_topics_for_type(self, request, response):
145152
"""Called by the rosapi/TopicsForType service. Returns a list of all the topics that are publishing a given type"""
146153
response.topics = proxy.get_topics_for_type(request.type, self.globs.topics)

rosapi/src/rosapi/proxy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3232
# POSSIBILITY OF SUCH DAMAGE.
3333

34+
from ros2interface.api import type_completer
3435
from ros2node.api import (
3536
get_node_names,
3637
get_publisher_info,
@@ -60,6 +61,11 @@ def get_topics(topics_glob, include_hidden=False):
6061
return filter_globs(topics_glob, topic_names)
6162

6263

64+
def get_interfaces():
65+
"""Returns a list of all the types in the ROS system"""
66+
return type_completer()
67+
68+
6369
def get_topics_and_types(topics_glob, include_hidden=False):
6470
return get_publications_and_types(
6571
topics_glob, get_topic_names_and_types, include_hidden_topics=include_hidden

rosapi_msgs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ rosidl_generate_interfaces(${PROJECT_NAME}
1414
srv/GetROSVersion.srv
1515
srv/GetTime.srv
1616
srv/HasParam.srv
17+
srv/Interfaces.srv
1718
srv/MessageDetails.srv
1819
srv/Nodes.srv
1920
srv/NodeDetails.srv

rosapi_msgs/srv/Interfaces.srv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
string[] interfaces

0 commit comments

Comments
 (0)