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


wiimote
Author(s): Andreas Paepcke, Melonee Wise, Mark Horn
autogenerated on Thu Dec 5 2024 03:18:13