Skip to content

Commit

Permalink
added a service to get the nodelet manager's name
Browse files Browse the repository at this point in the history
closes #42
  • Loading branch information
wjwwood committed Mar 14, 2014
1 parent eab4f35 commit 6348c94
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ add_service_files(FILES
GetCapabilitySpec.srv
GetCapabilitySpecs.srv
GetInterfaces.srv
GetNodeletManagerName.srv
GetProviders.srv
GetRunningCapabilities.srv
GetSemanticInterfaces.srv
Expand Down
4 changes: 4 additions & 0 deletions src/capabilities/launch_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ def __init__(self, quiet=False, screen=False, nodelet_manager_name=None):
self.__nodelet_manager_name = nodelet_manager_name or (rospy.get_name().lstrip('/') + '_nodelet_manager')
self.__start_nodelet_manager()

@property
def nodelet_manager_name(self):
return self.__nodelet_manager_name

def stop(self):
"""Stops the launch manager, also stopping any running launch files"""
if self.stopping:
Expand Down
14 changes: 14 additions & 0 deletions src/capabilities/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
from capabilities.srv import GetCapabilitySpecsResponse
from capabilities.srv import GetInterfaces
from capabilities.srv import GetInterfacesResponse
from capabilities.srv import GetNodeletManagerName
from capabilities.srv import GetNodeletManagerNameResponse
from capabilities.srv import GetProviders
from capabilities.srv import GetProvidersResponse
from capabilities.srv import GetSemanticInterfaces
Expand Down Expand Up @@ -333,6 +335,10 @@ def spin(self):
'~get_capability_spec', GetCapabilitySpec,
self.handle_get_capability_spec)

self.__get_nodelet_manager_name_service = rospy.Service(
'~get_nodelet_manager_name', GetNodeletManagerName,
self.handle_get_nodelet_manager_name)

rospy.Subscriber(
'~events', CapabilityEvent, self.handle_capability_events)

Expand Down Expand Up @@ -765,6 +771,14 @@ def _handle_get_running_capabilities(self, req):
resp.running_capabilities.append(running_capability)
return resp

def handle_get_nodelet_manager_name(self, req):
return self.__catch_and_log(self._handle_get_nodelet_manager_name, req)

def _handle_get_nodelet_manager_name(self, req):
resp = GetNodeletManagerNameResponse()
resp.nodelet_manager_name = self.__launch_manager.nodelet_manager_name
return resp


def create_parser():
parser = argparse.ArgumentParser(description="Runs the capability server")
Expand Down
3 changes: 3 additions & 0 deletions srv/GetNodeletManagerName.srv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

---
string nodelet_manager_name
3 changes: 3 additions & 0 deletions test/rostest/test_server/test_ros_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def test_introspection_services(self):
# get semantic interfaces by interface
resp = call_service('/capability_server/get_semantic_interfaces', 'minimal_pkg/Minimal')
assert 'minimal_pkg/SpecificMinimal' in resp.semantic_interfaces, resp
# get nodelet manager name
resp = call_service('/capability_server/get_nodelet_manager_name')
assert resp.nodelet_manager_name == 'capability_server_nodelet_manager', resp

def test_start_stop_capabilities(self):
# fail to start interface without a provider
Expand Down

0 comments on commit 6348c94

Please sign in to comment.