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
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
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
00031
00032
00033
00034
00035