def register_services(self, services):
"""
Similar to `pub_sub.create_publishers` and `pub_sub.create_subscribers`,
this method takes a list of service definition pairs, and registers
a `rospy.Service` object for each.
Because services must be uniquely namespaced, each service will be
exposed externally using the class's namespace as defined at
construction time. This means services map as follows
/self.namespace_method -> self.method(req)
Each pair consists of the name of the service and its service type, as
defined by a .srv file.
"""
for service in services:
callback_name, service_type = service
service_name = '{}_{}'.format(self.namespace, callback_name)
callback = getattr(self, callback_name)
self.registered.append(rospy.Service(service_name, service_type, callback))
评论列表
文章目录