Go to the documentation of this file.00001
00002
00003 import rospy
00004 from jsk_recognition_msgs.msg import BoundingBox
00005 from jsk_recognition_msgs.srv import SaveMesh
00006 from jsk_recognition_msgs.srv import SaveMeshRequest
00007 from std_srvs.srv import Empty
00008 from std_srvs.srv import EmptyResponse
00009
00010
00011 class SaveMeshServer(object):
00012
00013 def __init__(self):
00014 self.ground_frame_id = rospy.get_param('~ground_frame_id', '')
00015 self.sub_bbox = rospy.Subscriber('~input/bbox', BoundingBox, self._cb)
00016 self.srv_client = rospy.ServiceProxy('~save_mesh', SaveMesh)
00017 self.srv_server = rospy.Service('~request', Empty, self._request_cb)
00018 self.bbox_msg = None
00019
00020 def _cb(self, bbox_msg):
00021 self.bbox_msg = bbox_msg
00022
00023 def _request_cb(self, req):
00024 if self.bbox_msg is None:
00025 rospy.logerr('No bounding box is set, so ignoring the request.')
00026 return EmptyResponse()
00027
00028 req = SaveMeshRequest()
00029 req.box = self.bbox_msg
00030 req.ground_frame_id = self.ground_frame_id
00031 self.srv_client.call(req)
00032 return EmptyResponse()
00033
00034
00035 if __name__ == '__main__':
00036 rospy.init_node('save_mesh_server')
00037 server = SaveMeshServer()
00038 rospy.spin()