예제 #1
0
 def callback_local_to_remote(message):
     rospy.logdebug("Local subscriber from topic " + topic_name +
                    ' of type ' + topic_type + ' got data: ' +
                    str(message) + ' which is republished remotely.')
     dict_msg = from_ROS_to_dict(message)
     if not self.client.terminated:
         bridgepub.publish(dict_msg)
예제 #2
0
 def callback_from_remote_service_call(request):
     ros_req = from_dict_to_ROS(request,
                                service_type + 'Request',
                                srv=True)
     rospy.loginfo("Waiting for server " + service_name + "...")
     rospy.wait_for_service(service_name)
     # TODO: error handling in services...
     resp = rosservprox.call(ros_req)
     resp_dict = from_ROS_to_dict(resp)
     return True, resp_dict
예제 #3
0
        def callback_from_remote_service_call(request):
            ros_req = from_dict_to_ROS(request,
                                       service_type + 'Request',
                                       srv=True)
            rospy.loginfo("Waiting for server " + service_name + "...")
            rospy.wait_for_service(service_name)
            # TODO: error handling in services...
            try:
                resp = rosservprox.call(ros_req)
                resp_dict = from_ROS_to_dict(resp)
                return_val = True
            except rospy.ServiceException as exc:
                resp_dict = dict()
                return_val = False
                rospy.logerr("Service did not process request: " + str(exc))

            return return_val, resp_dict
예제 #4
0
        def callback_from_local_srv_call(request):
            rospy.loginfo("Got a SRV call to " + service_name + " of type " +
                          service_type)
            req_dict = from_ROS_to_dict(request)

            result = {'responded': False, 'response': None}

            def cb(success, response):
                result['responded'] = True
                if success:
                    result['response'] = response

            remote_service_client.request(req_dict, cb)
            while not rospy.is_shutdown() and not result['responded']:
                rospy.sleep(0.1)
            if result['response'] is None:
                rospy.logerr('Service call didnt succeed (' +
                             str(service_name) + ' of type ' +
                             str(service_type))
                return None
            return from_dict_to_ROS(result['response'],
                                    service_type + 'Response',
                                    srv=True)