11 from jsk_rviz_plugins.srv
import RequestMarkerOperate
12 from jsk_rviz_plugins.msg
import TransformableMarkerOperate
13 from jsk_interactive_marker.msg
import MarkerDimensions
14 from jsk_interactive_marker.msg
import PoseStampedWithName
15 from jsk_interactive_marker.srv
import GetTransformableMarkerFocus
16 from jsk_interactive_marker.srv
import GetTransformableMarkerFocusRequest
17 from jsk_interactive_marker.srv
import SetTransformableMarkerPose
18 from jsk_interactive_marker.srv
import SetTransformableMarkerPoseRequest
19 from jsk_interactive_marker.srv
import SetTransformableMarkerColor
20 from jsk_interactive_marker.srv
import SetTransformableMarkerColorRequest
21 from jsk_interactive_marker.srv
import SetMarkerDimensions
22 from jsk_interactive_marker.srv
import SetMarkerDimensionsRequest
23 from jsk_recognition_utils.color
import labelcolormap
24 from jsk_recognition_msgs.msg
import BoundingBox
25 from jsk_recognition_msgs.msg
import BoundingBoxArray
32 self.
server = rospy.resolve_name(
'~server')
36 rospy.logfatal(
"config_file '{}' does not exist" 42 osp.join(self.
server,
'request_marker_operate'),
45 osp.join(self.
server,
'set_color'), SetTransformableMarkerColor)
47 osp.join(self.
server,
'set_pose'), SetTransformableMarkerPose)
49 osp.join(self.
server,
'set_dimensions'), SetMarkerDimensions)
51 osp.join(self.
server,
'get_focus'),
52 GetTransformableMarkerFocus)
53 rospy.wait_for_service(self.req_marker.resolved_name)
54 rospy.wait_for_service(self.req_color.resolved_name)
55 rospy.wait_for_service(self.req_pose.resolved_name)
56 rospy.wait_for_service(self.req_dim.resolved_name)
57 rospy.wait_for_service(self.req_focus.resolved_name)
65 boxes = self.
config[
'boxes']
67 cmap = labelcolormap(n_boxes)
68 for i
in xrange(n_boxes):
71 frame_id = box.get(
'frame_id',
'/map')
73 type=TransformableMarkerOperate.BOX)
74 self.
set_color(name, (cmap[i][0], cmap[i][1], cmap[i][2], 0.5))
75 dim = box.get(
'dimensions', [1, 1, 1])
77 pos = box.get(
'position', [0, 0, 0])
78 ori = box.get(
'orientation', [0, 0, 0, 1])
79 self.
set_pose(box[
'name'], box[
'frame_id'], pos, ori)
81 position=Vector3(*pos),
82 orientation=Quaternion(*ori),
85 rospy.loginfo(
"Inserted transformable box '{}'.".format(name))
88 osp.join(self.
server,
'marker_dimensions'),
92 osp.join(self.
server,
'pose_with_name'),
96 do_auto_save = rospy.get_param(
'~config_auto_save',
True)
102 '~output/boxes', BoundingBoxArray, queue_size=1)
107 msg = TransformableMarkerOperate(
110 action=TransformableMarkerOperate.INSERT,
117 req = SetTransformableMarkerColorRequest()
118 req.target_name = name
119 req.color.r = rgba[0]
120 req.color.g = rgba[1]
121 req.color.b = rgba[2]
122 req.color.a = rgba[3]
126 req = SetMarkerDimensionsRequest()
127 req.target_name = name
128 req.dimensions.x = dimensions[0]
129 req.dimensions.y = dimensions[1]
130 req.dimensions.z = dimensions[2]
133 def set_pose(self, name, frame_id, position, orientation):
134 req = SetTransformableMarkerPoseRequest()
135 req.target_name = name
136 req.pose_stamped.header.frame_id = frame_id
137 req.pose_stamped.pose.position.x = position[0]
138 req.pose_stamped.pose.position.y = position[1]
139 req.pose_stamped.pose.position.z = position[2]
140 req.pose_stamped.pose.orientation.x = orientation[0]
141 req.pose_stamped.pose.orientation.y = orientation[1]
142 req.pose_stamped.pose.orientation.z = orientation[2]
143 req.pose_stamped.pose.orientation.w = orientation[3]
147 req = GetTransformableMarkerFocusRequest()
149 return res.target_name
159 bbox_array_msg = BoundingBoxArray()
160 bbox_array_msg.header.frame_id = self.
config[
'boxes'][0][
'frame_id']
161 bbox_array_msg.header.stamp = event.current_real
162 for box
in self.
config[
'boxes']:
163 bbox_msg = BoundingBox()
165 bbox_msg.header.frame_id = bbox_array_msg.header.frame_id
166 bbox_msg.header.stamp = bbox_array_msg.header.stamp
169 bbox_msg.dimensions.x = dimensions.x
170 bbox_msg.dimensions.y = dimensions.y
171 bbox_msg.dimensions.z = dimensions.z
172 bbox_array_msg.boxes.append(bbox_msg)
173 self.pub_bboxes.publish(bbox_array_msg)
176 for i, box
in enumerate(self.
config[
'boxes']):
177 box_cfg = self.
config[
'boxes'][i]
178 box_cfg[
'name'] = box[
'name']
183 'frame_id': box[
'frame_id'],
204 if __name__ ==
'__main__':
205 rospy.init_node(
'transformable_markers_client')