feedbackTester.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import roslib; roslib.load_manifest('wiimote')
4 import rospy
5 from sensor_msgs.msg import JoyFeedbackArray
6 from sensor_msgs.msg import JoyFeedback
7 
8 # Test the wiimote package LED control. Expect the following LED
9 # patterns of INTER_PATTERN_SLEEP_DURATION seconds duration each:
10 
11 
12 INTER_PATTERN_SLEEP_DURATION = 0.2
13 
14 def talker():
15  pub = rospy.Publisher('/joy/set_feedback', JoyFeedbackArray, queue_size=1)
16  rospy.init_node('ledControlTester', anonymous=True)
17 
18  led0 = JoyFeedback()
19  led0.type = JoyFeedback.TYPE_LED
20  led0.id = 0
21  led1 = JoyFeedback()
22  led1.type = JoyFeedback.TYPE_LED
23  led1.id = 1
24  led2 = JoyFeedback()
25  led2.type = JoyFeedback.TYPE_LED
26  led2.id = 2
27  led3 = JoyFeedback()
28  led3.type = JoyFeedback.TYPE_LED
29  led3.id = 3
30  rum = JoyFeedback()
31  rum.type = JoyFeedback.TYPE_RUMBLE
32  rum.id = 0
33 
34 
35  while not rospy.is_shutdown():
36 
37  msg = JoyFeedbackArray()
38  msg.array = [led0, led1, led2, led3, rum]
39 
40  led0.intensity = 0.2
41  led3.intensity = 0.2
42  rum.intensity = 0.49
43 
44  if msg is not None:
45  rospy.logdebug("Msg: " + str(msg))
46  pub.publish(msg)
47  rospy.sleep(INTER_PATTERN_SLEEP_DURATION)
48 
49  led0.intensity = 1.0
50  rum.intensity = 0.51
51 
52  if msg is not None:
53  rospy.logdebug("Msg: " + str(msg))
54  pub.publish(msg)
55  rospy.sleep(INTER_PATTERN_SLEEP_DURATION)
56 
57  led0.intensity = 0.0
58  led1.intensity = 1.0
59  rum.intensity = 0.0
60 
61  if msg is not None:
62  rospy.logdebug("Msg: " + str(msg))
63  pub.publish(msg)
64  rospy.sleep(INTER_PATTERN_SLEEP_DURATION)
65 
66  led1.intensity = 0.0
67  led2.intensity = 1.0
68  rum.intensity = 0.7
69 
70  if msg is not None:
71  rospy.logdebug("Msg: " + str(msg))
72  pub.publish(msg)
73  rospy.sleep(INTER_PATTERN_SLEEP_DURATION)
74 
75  led2.intensity = 0.0
76  led3.intensity = 1.0
77  rum.intensity = 0.49
78 
79  if msg is not None:
80  rospy.logdebug("Msg: " + str(msg))
81  pub.publish(msg)
82  rospy.sleep(INTER_PATTERN_SLEEP_DURATION)
83 
84  led1.intensity = 1.0
85  led2.intensity = 1.0
86  rum.intensity = 1.0
87 
88  if msg is not None:
89  rospy.logdebug("Msg: " + str(msg))
90  pub.publish(msg)
91  rospy.sleep(INTER_PATTERN_SLEEP_DURATION)
92 
93  led0.intensity = 1.0
94  led1.intensity = 0.4
95  led2.intensity = 0.4
96 
97  msg.array = [led0, led1, led2]
98 
99  if msg is not None:
100  rospy.logdebug("Msg: " + str(msg))
101  pub.publish(msg)
102  rospy.sleep(INTER_PATTERN_SLEEP_DURATION)
103 
104 
105 if __name__ == '__main__':
106 
107  print("\n ****************************************************************\n")
108  print("**** You should see six LED on/off configurations, and feel Rumbles! ****")
109  print("\n **************************************************************")
110  print("[off, off, off, off]")
111  print("[on, off, off, off]")
112  print("[off, on, off, off]")
113  print("[off, off, on, off]")
114  print("[off, off, off, on ]")
115  print("[off, on, on, on ]")
116  print("[on, off, off, on ]")
117  try:
118  talker()
119  except rospy.ROSInterruptException:
120  pass


wiimote
Author(s): Andreas Paepcke, Melonee Wise, Mark Horn
autogenerated on Fri Jun 7 2019 22:01:33