save_mesh_server.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 from jsk_recognition_msgs.msg import BoundingBox
5 from jsk_recognition_msgs.srv import SaveMesh
6 from jsk_recognition_msgs.srv import SaveMeshRequest
7 from std_srvs.srv import Empty
8 from std_srvs.srv import EmptyResponse
9 
10 
11 class SaveMeshServer(object):
12 
13  def __init__(self):
14  self.ground_frame_id = rospy.get_param('~ground_frame_id', '')
15  self.sub_bbox = rospy.Subscriber('~input/bbox', BoundingBox, self._cb)
16  self.srv_client = rospy.ServiceProxy('~save_mesh', SaveMesh)
17  self.srv_server = rospy.Service('~request', Empty, self._request_cb)
18  self.bbox_msg = None
19 
20  def _cb(self, bbox_msg):
21  self.bbox_msg = bbox_msg
22 
23  def _request_cb(self, req):
24  if self.bbox_msg is None:
25  rospy.logerr('No bounding box is set, so ignoring the request.')
26  return EmptyResponse()
27 
28  req = SaveMeshRequest()
29  req.box = self.bbox_msg
30  req.ground_frame_id = self.ground_frame_id
31  self.srv_client.call(req)
32  return EmptyResponse()
33 
34 
35 if __name__ == '__main__':
36  rospy.init_node('save_mesh_server')
37  server = SaveMeshServer()
38  rospy.spin()


jsk_recognition_msgs
Author(s):
autogenerated on Mon May 3 2021 03:02:56