cv_trigger.py
Go to the documentation of this file.
00001 import roslib
00002 roslib.load_manifest('trigger_msgs')
00003 import sys
00004 import rospy
00005 import cv
00006 
00007 import trigger_msgs.msg
00008 
00009 rospy.init_node("trigger", anonymous=True)
00010 arm_trigger = rospy.Publisher("arm_trigger", trigger_msgs.msg.Trigger, latch = True)
00011 head_trigger = rospy.Publisher("head_trigger", trigger_msgs.msg.Trigger, latch = True)
00012 cv.NamedWindow('keyboard', 1)
00013 img = cv.CreateImage((30, 30), cv.IPL_DEPTH_8U, 1)
00014 #r = rospy.Rate(132/60.)
00015 r = rospy.Rate(10.)
00016 
00017 i = 0
00018 while not rospy.is_shutdown():
00019     cv.ShowImage('keyboard', img)
00020     k = cv.WaitKey(10)
00021     #print (k & 0xff), k
00022     if chr(k & 0xff) == 'h':
00023         print 'head!'
00024         head_trigger.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.0)), rospy.get_param("~event", ""))
00025 
00026     if chr(k & 0xff) == 'a':
00027         print 'arm!'
00028         arm_trigger.publish(rospy.get_rostime() + rospy.Duration(rospy.get_param("~delay", 0.0)), rospy.get_param("~event", ""))
00029 
00030     #if i % 4 == 0:
00031 
00032     #if i % 8 == 0:
00033 
00034     #i = i+1
00035     #r.sleep()


hai_sandbox
Author(s): Hai Nguyen
autogenerated on Wed Nov 27 2013 11:46:56