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

Add new service to retrieve the different interfaces in the ROS Network #988

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions rosapi/scripts/rosapi_node
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ from rosapi_msgs.srv import (
GetROSVersion,
GetTime,
HasParam,
Interfaces,
MessageDetails,
NodeDetails,
Nodes,
Expand Down Expand Up @@ -89,6 +90,7 @@ class Rosapi(Node):
full_name = self.get_namespace() + "/" + self.get_name()
params.init(full_name)
self.create_service(Topics, "/rosapi/topics", self.get_topics)
self.create_service(Interfaces, "/rosapi/interfaces", self.get_interfaces)
self.create_service(TopicsForType, "/rosapi/topics_for_type", self.get_topics_for_type)
self.create_service(
TopicsAndRawTypes,
Expand Down Expand Up @@ -137,6 +139,11 @@ class Rosapi(Node):
response.topics, response.types = proxy.get_topics_and_types(self.globs.topics)
return response

def get_interfaces(self, request, response):
"""Called by the rosapi/Types service. Returns a list of all the types in the system."""
response.interfaces = proxy.get_interfaces()
return response

def get_topics_for_type(self, request, response):
"""Called by the rosapi/TopicsForType service. Returns a list of all the topics that are publishing a given type"""
response.topics = proxy.get_topics_for_type(request.type, self.globs.topics)
Expand Down
6 changes: 6 additions & 0 deletions rosapi/src/rosapi/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from ros2interface.api import type_completer
from ros2node.api import (
get_node_names,
get_publisher_info,
Expand Down Expand Up @@ -60,6 +61,11 @@ def get_topics(topics_glob, include_hidden=False):
return filter_globs(topics_glob, topic_names)


def get_interfaces():
"""Returns a list of all the types in the ROS system"""
return type_completer()


def get_topics_and_types(topics_glob, include_hidden=False):
return get_publications_and_types(
topics_glob, get_topic_names_and_types, include_hidden_topics=include_hidden
Expand Down
1 change: 1 addition & 0 deletions rosapi_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rosidl_generate_interfaces(${PROJECT_NAME}
srv/GetROSVersion.srv
srv/GetTime.srv
srv/HasParam.srv
srv/Interfaces.srv
srv/MessageDetails.srv
srv/Nodes.srv
srv/NodeDetails.srv
Expand Down
2 changes: 2 additions & 0 deletions rosapi_msgs/srv/Interfaces.srv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
string[] interfaces
Loading