6 from jsk_topic_tools
import ConnectionBasedTransport
9 from eus_teleop.msg
import EusTeleopStatusArray
10 from sensor_msgs.msg
import Image
16 super(EusTeleopStatusVisualizer, self).
__init__()
17 self.
pub = self.advertise(
'~output/image', Image, queue_size=1)
18 self.
enable = {
'larm':
False,
'rarm':
False}
25 self.
sub = rospy.Subscriber(
'~input/image', Image, self.
_cb)
27 '~input/status', EusTeleopStatusArray, self.
_status_cb)
34 img = self.
bridge.imgmsg_to_cv2(msg, desired_encoding=
"bgr8")
36 img_W = int((H * 16.0 / 9.0 - W) / 2.0)
38 imgs[
'larm'] = np.zeros((H, img_W, C), dtype=np.uint8)
39 imgs[
'rarm'] = np.zeros((H, img_W, C), dtype=np.uint8)
41 for index, arm
in zip([1, 0], [
'larm',
'rarm']):
45 imgs[arm][:, :, 2] = 255
49 imgs[arm][:, :, index] = 255
52 imgs[arm][int(2.0 * H / 3.0):, :, 0] = 0
53 imgs[arm][int(2.0 * H / 3.0):, :, 1] = 165
54 imgs[arm][int(2.0 * H / 3.0):, :, 2] = 255
59 img = np.concatenate((imgs[
'rarm'], img, imgs[
'larm']), axis=1)
60 img_msg = self.
bridge.cv2_to_imgmsg(img, encoding=
"bgr8")
61 img_msg.header = msg.header
62 self.
pub.publish(img_msg)
65 for status
in msg.status:
66 if status.part_name
in self.
enable:
67 self.
enable[status.part_name] = status.enable
69 self.
collision[status.part_name] = status.collision
71 self.
track_error[status.part_name] = status.track_error
73 self.
hand_close[status.part_name] = status.hand_close
76 if __name__ ==
'__main__':
77 rospy.init_node(
'eus_teleop_status_visualizer')