feedbackTester.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import roslib; roslib.load_manifest('wiimote')
00004 import rospy
00005 from sensor_msgs.msg import JoyFeedbackArray
00006 from sensor_msgs.msg import JoyFeedback
00007 
00008 # Test the wiimote package LED control. Expect the following LED
00009 # patterns of INTER_PATTERN_SLEEP_DURATION seconds duration each:
00010 
00011 
00012 INTER_PATTERN_SLEEP_DURATION = 0.2
00013 
00014 def talker():    
00015     pub = rospy.Publisher('/joy/set_feedback', JoyFeedbackArray)
00016     rospy.init_node('ledControlTester', anonymous=True)
00017 
00018     led0 = JoyFeedback()
00019     led0.type = JoyFeedback.TYPE_LED
00020     led0.id = 0
00021     led1 = JoyFeedback()
00022     led1.type = JoyFeedback.TYPE_LED
00023     led1.id = 1
00024     led2 = JoyFeedback()
00025     led2.type = JoyFeedback.TYPE_LED
00026     led2.id = 2
00027     led3 = JoyFeedback()
00028     led3.type = JoyFeedback.TYPE_LED
00029     led3.id = 3
00030     rum = JoyFeedback()
00031     rum.type = JoyFeedback.TYPE_RUMBLE
00032     rum.id = 0
00033 
00034 
00035     while not rospy.is_shutdown():
00036       
00037       msg = JoyFeedbackArray()
00038       msg.array = [led0, led1, led2, led3, rum]
00039       
00040       led0.intensity = 0.2
00041       led3.intensity = 0.2
00042       rum.intensity = 0.49
00043 
00044       if msg is not None:
00045           rospy.logdebug("Msg: " + str(msg))
00046           pub.publish(msg)
00047           rospy.sleep(INTER_PATTERN_SLEEP_DURATION)
00048           
00049       led0.intensity = 1.0
00050       rum.intensity = 0.51
00051 
00052       if msg is not None:
00053           rospy.logdebug("Msg: " + str(msg))
00054           pub.publish(msg)
00055           rospy.sleep(INTER_PATTERN_SLEEP_DURATION)
00056           
00057       led0.intensity = 0.0
00058       led1.intensity = 1.0
00059       rum.intensity = 0.0
00060 
00061       if msg is not None:
00062           rospy.logdebug("Msg: " + str(msg))
00063           pub.publish(msg)
00064           rospy.sleep(INTER_PATTERN_SLEEP_DURATION)
00065           
00066       led1.intensity = 0.0
00067       led2.intensity = 1.0
00068       rum.intensity = 0.7
00069 
00070       if msg is not None:
00071           rospy.logdebug("Msg: " + str(msg))
00072           pub.publish(msg)
00073           rospy.sleep(INTER_PATTERN_SLEEP_DURATION)
00074           
00075       led2.intensity = 0.0
00076       led3.intensity = 1.0
00077       rum.intensity = 0.49
00078 
00079       if msg is not None:
00080           rospy.logdebug("Msg: " + str(msg))
00081           pub.publish(msg)
00082           rospy.sleep(INTER_PATTERN_SLEEP_DURATION)
00083           
00084       led1.intensity = 1.0
00085       led2.intensity = 1.0
00086       rum.intensity = 1.0
00087 
00088       if msg is not None:
00089           rospy.logdebug("Msg: " + str(msg))
00090           pub.publish(msg)
00091           rospy.sleep(INTER_PATTERN_SLEEP_DURATION)
00092           
00093       led0.intensity = 1.0
00094       led1.intensity = 0.4
00095       led2.intensity = 0.4
00096       
00097       msg.array = [led0, led1, led2]
00098 
00099       if msg is not None:
00100           rospy.logdebug("Msg: " + str(msg))
00101           pub.publish(msg)
00102           rospy.sleep(INTER_PATTERN_SLEEP_DURATION)
00103 
00104 
00105 if __name__ == '__main__':
00106     
00107   print("\n   ****************************************************************\n")
00108   print("****     You should see six LED on/off configurations, and feel Rumbles!  ****")
00109   print("\n   **************************************************************")
00110   print("[off, off, off, off]")
00111   print("[on,  off, off, off]")
00112   print("[off, on,  off, off]")
00113   print("[off, off, on,  off]")
00114   print("[off, off, off, on ]")
00115   print("[off, on,  on,  on ]")
00116   print("[on,  off, off, on ]")
00117   try:
00118     talker()
00119   except rospy.ROSInterruptException:
00120     pass


wiimote
Author(s): Andreas Paepcke, Melonee Wise
autogenerated on Mon Oct 6 2014 01:06:37