-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathblinking.py
40 lines (29 loc) · 842 Bytes
/
blinking.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
import rospy
from baxter_interface import Limb
import baxter_interface
import time
import cv2
import cv_bridge
import rospkg
from sensor_msgs.msg import Image
import random
def callback(data):
global msg
global msg_closed
if not data == msg_closed:
msg = data
rospy.init_node('blinking')
_images = '/home/scem/ros_ws/baxter_eyes'
img = cv2.imread(_images + '/straight.jpg')
sub = rospy.Subscriber('/robot/xdisplay', Image, callback)
img_closed = cv2.imread(_images + '/closed.jpg')
msg_closed = cv_bridge.CvBridge().cv2_to_imgmsg(img_closed)
msg = cv_bridge.CvBridge().cv2_to_imgmsg(img)
pub = rospy.Publisher('/robot/xdisplay', Image,latch=True, queue_size=10)
while not rospy.is_shutdown():
timer = random.randint(2,4)
time.sleep(timer)
print "blinking"
pub.publish(msg_closed)
pub.publish(msg)