wiimoteConstants.py
Go to the documentation of this file.
1 ################################################################################
2 #
3 # File: wiimoteConstants.py
4 # RCS: $Header: $
5 # Description: Constants for Wii Arm Control
6 # Author: Andreas Paepcke
7 # Created: Thu Aug 13 11:44:04 2009 (Andreas Paepcke) paepcke@anw.willowgarage.com
8 # Modified: Thu Jan 13 13:44:31 2011 (Andreas Paepcke) paepcke@bhb.willowgarage.com
9 # Language: Python
10 # Package: N/A
11 # Status: Experimental (Do Not Distribute)
12 #
13 # #
14 ################################################################################
15 #
16 # Revisions:
17 #
18 # Thu Mar 18 10:56:09 2010 (David Lu) davidlu@wustl.edu
19 # Added nunchuk options
20 # Fri Oct 29 08:58:21 2010 (Miguel Angel Julian Aguilar, QBO Project) miguel.angel@thecorpora.com
21 # Added classic controller options
22 ################################################################################
23 
24 _DEBUGLEVEL = 1
25 _MONITOR_LEVEL = 1
26 
27 import numpy as np
28 
29 # Control over calibration:
30 NUM_ZEROING_READINGS = 100 # Number of readings to take for zeroing acc and gyro
31 NUM_WARMUP_READINGS = 100 # Number of readings to throw away initially so that
32  # the gyro starts providing data for calibration
33 
34 # Number of standard deviations that accelerator or
35 # gyro measurements need to be beyond the mean (axis
36 # by axis) to be considered an outlier:
37 
38 OUTLIER_STDEV_MULTIPLE = 3
39 
40 # Whether to calibrate the Wiimote even when
41 # the calibration process was less than perfect:
42 
43 CALIBRATE_WITH_FAILED_CALIBRATION_DATA = False
44 
45 # TimedSwitch message field value constants:
46 SWITCH_ON = 1
47 SWITCH_OFF = 0
48 SWITCH_PULSE_PATTERN = -1
49 
50 # Output indicators on the Wiimote:
51 
52 RUMBLE = 1
53 LED = 2
54 
55 # Buttons in cwiid structure:
56 
57 BTN_1 = 0x0002 # cwiid.CWIID_BTN_1
58 BTN_2 = 0x0001 # cwiid.CWIID_BTN_2
59 BTN_B = 0x0004 # cwiid.CWIID_BTN_B
60 BTN_A = 0x0008 # cwiid.CWIID_BTN_A
61 BTN_MINUS = 0x0010 # cwiid.CWIID_BTN_MINUS
62 BTN_PLUS = 0x1000 # cwiid.CWIID_BTN_PLUS
63 BTN_LEFT = 0x0100 # cwiid.CWIID_BTN_LEFT
64 BTN_RIGHT = 0x0200 # cwiid.CWIID_BTN_RIGHT
65 BTN_DOWN = 0x0400 # cwiid.CWIID_BTN_DOWN
66 BTN_UP = 0x0800 # cwiid.CWIID_BTN_UP
67 BTN_HOME = 0x0080 # cwiid.CWIID_BTN_HOME
68 
69 # nunchuk Buttons
70 BTN_C = 0x0002
71 BTN_Z = 0x0001
72 
73 # Classic Controller Buttons
74 CLASSIC_BTN_UP = 0x0001
75 CLASSIC_BTN_LEFT = 0x0002
76 CLASSIC_BTN_ZR = 0x0004
77 CLASSIC_BTN_X = 0x0008
78 CLASSIC_BTN_A = 0x0010
79 CLASSIC_BTN_Y = 0x0020
80 CLASSIC_BTN_B = 0x0040
81 CLASSIC_BTN_ZL = 0x0080
82 CLASSIC_BTN_R = 0x0200
83 CLASSIC_BTN_PLUS = 0x0400
84 CLASSIC_BTN_HOME = 0x0800
85 CLASSIC_BTN_MINUS = 0x1000
86 CLASSIC_BTN_L = 0x2000
87 CLASSIC_BTN_DOWN = 0x4000
88 CLASSIC_BTN_RIGHT = 0x8000
89 
90 X = 0
91 Y = 1
92 Z = 2
93 
94 PHI = 0
95 THETA = 1
96 PSI = 2
97 
98 
99 # Buttons order in Wiimote ROS message array:
100 # These buttons are now defined in Wiimote.msg,
101 # so that they are available to other languages.
102 
103 #MSG_BTN_1 = 0
104 #MSG_BTN_2 = 1
105 #MSG_BTN_A = 2
106 #MSG_BTN_B = 3
107 #MSG_BTN_PLUS = 4
108 #MSG_BTN_MINUS = 5
109 #MSG_BTN_LEFT = 6
110 #MSG_BTN_RIGHT = 7
111 #MSG_BTN_UP = 8
112 #MSG_BTN_DOWN = 9
113 #MSG_BTN_HOME = 10
114 
115 
116 X_COORD = 'x'
117 Y_COORD = 'y'
118 Z_COORD = 'z'
119 NORM_X = 'normX'
120 NORM_Y = 'normY'
121 NORM_Z = 'normZ'
122 
123 NUM_IR_SENSORS = 4
124 IR1 = 'ir1'
125 IR2 = 'ir2'
126 IR3 = 'ir3'
127 IR4 = 'ir4'
128 
129 NUM_LEDS = 4
130 LED1_ON = 0x01
131 LED2_ON = 0x02
132 LED3_ON = 0x04
133 LED4_ON = 0x08
134 
135 # Indices into a two-tuple of info about battery state
136 # in wiimote messages:
137 # 0: Percentage of battery left.
138 # 1: The raw battery reading
139 
140 BATTERY_PERCENTAGE = 0
141 BATTERY_RAW = 1
142 
143 # Turning wiimote accelerator readings from g's to m/sec^2:
144 EARTH_GRAVITY = 9.80665 # m/sec^2
145 
146 # Turning wiimote gyro readings to radians/sec.
147 # This scale factor is highly approximate. Procedure:
148 # - Tape Wiimote to center of an office chair seat
149 # - Rotate the chair at approximately constant speed
150 # for 10 seconds. This resulted in 6 chair revolutions
151 # - On average, the Wiimote gyro read 3570 during this
152 # experiment.
153 # - Speed of chair revolving:
154 # * One full circle is: 2#pi radians
155 # * Six revolutions = 12pi radians. ==> 12pi rad in 10 sec ==> 1.2pi rad/sec
156 # * => 3570 == 1.2pi
157 # * => x*3570 = 1.2pi
158 # * => x = 1.2pi/3570 (1.2pi = 3.769908)
159 # * => scale factor = 0.001055997
160 # So multiplying the gyro readings by this factor
161 # calibrates the readings to show angular velocity
162 # in radians/sec.
163 GYRO_SCALE_FACTOR = 0.001055997
164 
165 # Status type of message from Wii to us:
166 WII_MSG_TYPE_STATUS = 0
167 WII_MSG_TYPE_BTN = 1
168 WII_MSG_TYPE_ACC = 2
169 WII_MSG_TYPE_IR = 3
170 WII_MSG_TYPE_NUNCHUK = 4
171 WII_MSG_TYPE_CLASSIC = 5
172 # WII_MSG_TYPE_BALANCE = 6
173 WII_MSG_TYPE_MOTIONPLUS = 7 # Gyro
174 WII_MSG_TYPE_ERROR = 8
175 WII_MSG_TYPE_UNKNOWN = 9
176 
177 
178 #define CWIID_IR_X_MAX 1024
179 #define CWIID_IR_Y_MAX 768
180 
181 ACC_X_STDEV_THRESHOLD = 1.0
182 ACC_Y_STDEV_THRESHOLD = 1.0
183 ACC_Z_STDEV_THRESHOLD = 1.0
184 
185 GYRO_X_STDEV_THRESHOLD = 50.0
186 GYRO_Y_STDEV_THRESHOLD = 50.0
187 GYRO_Z_STDEV_THRESHOLD = 50.0
188 
189 THRESHOLDS_ARRAY = np.array([ACC_X_STDEV_THRESHOLD,
190  ACC_Y_STDEV_THRESHOLD,
191  ACC_Z_STDEV_THRESHOLD,
192  GYRO_X_STDEV_THRESHOLD,
193  GYRO_Y_STDEV_THRESHOLD,
194  GYRO_Z_STDEV_THRESHOLD])
195 
196 


wiimote
Author(s): Andreas Paepcke, Melonee Wise, Mark Horn
autogenerated on Mon Jun 10 2019 13:42:43