$search
Main class for Wiimote device interaction. This class should be a singleton, or it should have only class members/methods. Public Data attributes: wiiMoteState WIIState object that holds the latest sampled state sampleRate Control Wiimote state samples to take per second meanAcc Triplet with mean of accelerator at rest stdevAcc Triplet with standard deviation of accelerator at rest meanGyro Triplet with mean of gyro (angular rate) at rest stdevGyro Triplet with standard deviation gyro (angular rate) at rest Public Methods:
Definition at line 77 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::__init__ | ( | self, | ||
theSampleRate = 0 , |
||||
wiiStateLock = None , |
||||
gatherCalibrationStats = False | ||||
) |
Instantiate a Wiimote driver instance, which controls one physical Wiimote device. Parameters: theSampleRate: How often to update the instance's wiiMoteState variable: theSampleRate= -1: never theSampleRate= 0: as often as possible theSampleRate= x: every x seconds
Definition at line 135 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::_calibrationCallback | ( | self, | ||
state, | ||||
theTime | ||||
) | [private] |
Wii's callback destination while zeroing the device.
Definition at line 267 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::_getInstanceVarCriticalSection | ( | self, | ||
varName | ||||
) | [private] |
Return the value of the given instance variable, providing locking service.
Definition at line 514 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::_steadyStateCallback | ( | self, | ||
state, | ||||
theTime | ||||
) | [private] |
Definition at line 242 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::computeAccStatistics | ( | self | ) |
Compute mean and stdev for accelerometer data list self._accList in both Gs and metric m/sec^2
Definition at line 759 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::computeGyroStatistics | ( | self | ) |
Compute mean and stdev for gyro data list self._gyroList in both Gs and metric m/sec^2
Definition at line 788 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::getAccelerometerCalibration | ( | self | ) |
Returns currently operative accelerometer calibration. Return value: tuple with calibration for zero reading, and calibration or a '1' reading.
Definition at line 646 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::getAccFactoryCalibrationSettings | ( | self | ) |
Obtain calibration data from accelerometer. Retrieve factory-installed calibration data for the Wiimote's accelerometer. Returns a two-tuple with the calibration numbers for zero and one:
Definition at line 658 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::getBattery | ( | self | ) |
Obtain battery state from Wiimote. Maximum charge is BATTERY_MAX.
Definition at line 634 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::getGyroCalibration | ( | self | ) |
Return current Gyro zeroing offsets as list x/y/z.
Definition at line 703 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::getLEDs | ( | self, | ||
asInt = False | ||||
) |
Get the status of the four Wii LEDs. Return value depends on the asInt parameter: if asInt=False, the method returns a 4-tuple. Each entry is either True or False. True indicates that the respective LED is on; False means off. If asInt=True, return value is a bit vector indicating which LEDs are on.
Definition at line 592 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::getMeanAccelerator | ( | self | ) |
Accessor that provides locking.
Definition at line 459 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::getMeanGyro | ( | self | ) |
Accessor that provides locking.
Definition at line 486 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::getNunchukFactoryCalibrationSettings | ( | self | ) |
Obtain calibration data from nunchuk accelerometer. Retrieve factory-installed calibration data for the Nunchuk's accelerometer. Returns a two-tuple with the calibration numbers for zero and one:
Definition at line 678 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::getRumble | ( | self | ) |
Definition at line 554 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::getStdevAccelerator | ( | self | ) |
Accessor that provides locking.
Definition at line 468 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::getStdevGyro | ( | self | ) |
Accessor that provides locking.
Definition at line 495 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::getVarianceAccelerator | ( | self | ) |
Accessor that provides locking.
Definition at line 477 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::getVarianceGyro | ( | self | ) |
Accessor that provides locking.
Definition at line 504 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::getWiimoteState | ( | self | ) |
Returns the most recent Wiistate instance. Provides proper locking.
Definition at line 450 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::motionPlusPresent | ( | self | ) |
Return True/False to indicate whether a Wiimotion Plus is detected. Note: The return value is accurate only after at least one Wiimote state has been read. This means that either _steadyStateCallback or _calibrationCallback must have run at least once.
Definition at line 725 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::nunchukPresent | ( | self | ) |
Return True/False to indicate whether a Nunchuk is detected. Note: The return value is accurate only after at least one Wiimote state has been read. This means that either _steadyStateCallback or _calibrationCallback must have run at least once.
Definition at line 742 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::printState | ( | self | ) |
Definition at line 812 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::setAccelerometerCalibration | ( | self, | ||
zeroReadingNPArray, | ||||
oneReadingNPArray | ||||
) |
Definition at line 696 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::setAccelerometerCalibration | ( | self, | ||
zeroReadingList, | ||||
oneReadingList | ||||
) |
Definition at line 693 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::setGyroCalibration | ( | self, | ||
gyroTriplet | ||||
) |
Definition at line 711 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::setLEDs | ( | self, | ||
statusList | ||||
) |
Set the four Wii LEDs according to statusList statusList must be a 4-tuple. Each entry is either True/1, False/0, or None. True (or 1) will turn the respective LED on; False (or 0) turns it off, and None leaves the state unchanged.
Definition at line 566 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::setNunchukAccelerometerCalibration | ( | self, | ||
zeroReadingList, | ||||
oneReadingList | ||||
) |
Definition at line 718 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::setRumble | ( | self, | ||
switchPos | ||||
) |
Start of stop rumble (i.e. vibration). 1: start; 0: stop
Definition at line 545 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::shutdown | ( | self | ) |
Definition at line 820 of file WIIMote.py.
def wiimote::WIIMote::WIIMote::zeroDevice | ( | self | ) |
Find the at-rest values of the accelerometer and the gyro. Collect NUM_ZEROING_READINGS readings of acc and gyro. Average them. If the standard deviation of any of the six axes exceeds a threshold that was determined empirically, then the calibration fails. Else the gyro is biased to compensate for its at-rest offset. The offset is the abs(mean(Gyro)). The stdev thresholds are documented in wiimoteConstants.py. Note that we always use the Wiimote's factory-installed zeroing data. In the code below we nonetheless compute the stats for the accelerometer, in case this behavior is to change in the future. We sleep while the samples are taken. In order to prevent other threads from reading bad values for mean/stdev, and variance, we lock access to those vars.
Definition at line 302 of file WIIMote.py.
wiimote::WIIMote::WIIMote::_accList = None [static, private] |
Definition at line 112 of file WIIMote.py.
wiimote::WIIMote::WIIMote::_accNormal = None [static, private] |
Definition at line 119 of file WIIMote.py.
wiimote::WIIMote::WIIMote::_accTotal = None [static, private] |
Definition at line 115 of file WIIMote.py.
wiimote::WIIMote::WIIMote::_gyroList = None [static, private] |
Definition at line 113 of file WIIMote.py.
wiimote::WIIMote::WIIMote::_gyroNormal = None [static, private] |
Definition at line 120 of file WIIMote.py.
wiimote::WIIMote::WIIMote::_gyroTotal = None [static, private] |
Definition at line 116 of file WIIMote.py.
list wiimote::WIIMote::WIIMote::_LEDMasksOff [static, private] |
[0 | LED2_ON | LED3_ON | LED4_ON, # AND to turn off
0 | LED1_ON | LED3_ON | LED4_ON,
0 | LED1_ON | LED2_ON | LED4_ON,
0 | LED1_ON | LED2_ON | LED3_ON]
Definition at line 125 of file WIIMote.py.
list wiimote::WIIMote::WIIMote::_LEDMasksOn = [LED1_ON, LED2_ON, LED3_ON, LED4_ON] [static, private] |
Definition at line 124 of file WIIMote.py.
wiimote::WIIMote::WIIMote::_nunchukJoyOrig = None [static, private] |
Definition at line 122 of file WIIMote.py.
wiimote::WIIMote::WIIMote::_readingsCnt = None [static, private] |
Definition at line 114 of file WIIMote.py.
wiimote::WIIMote::WIIMote::_startTime = None [static, private] |
Definition at line 111 of file WIIMote.py.
wiimote::WIIMote::WIIMote::_warmupCnt [private] |
Definition at line 325 of file WIIMote.py.
wiimote::WIIMote::WIIMote::_wiiCallbackStack = None [static, private] |
Definition at line 109 of file WIIMote.py.
wiimote::WIIMote::WIIMote::_wm = None [static, private] |
Definition at line 108 of file WIIMote.py.
wiimote::WIIMote::WIIMote::BATTERY_MAX = cwiid.BATTERY_MAX [static] |
Definition at line 98 of file WIIMote.py.
Definition at line 149 of file WIIMote.py.
Definition at line 147 of file WIIMote.py.
Definition at line 145 of file WIIMote.py.
Definition at line 187 of file WIIMote.py.
Definition at line 763 of file WIIMote.py.
Definition at line 791 of file WIIMote.py.
Definition at line 170 of file WIIMote.py.
Definition at line 171 of file WIIMote.py.
Definition at line 179 of file WIIMote.py.
Definition at line 180 of file WIIMote.py.
Definition at line 164 of file WIIMote.py.
Definition at line 173 of file WIIMote.py.
Definition at line 174 of file WIIMote.py.
Definition at line 182 of file WIIMote.py.
Definition at line 183 of file WIIMote.py.
Definition at line 176 of file WIIMote.py.
Definition at line 185 of file WIIMote.py.
Definition at line 163 of file WIIMote.py.
Definition at line 162 of file WIIMote.py.