Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
wiimote.WIIMote.WIIMote Class Reference
Inheritance diagram for wiimote.WIIMote.WIIMote:
Inheritance graph
[legend]

Public Member Functions

def __init__ (self, theSampleRate=0, wiiStateLock=None, gatherCalibrationStats=False)
 
def computeAccStatistics (self)
 
def computeGyroStatistics (self)
 
def getAccelerometerCalibration (self)
 
def getAccFactoryCalibrationSettings (self)
 
def getBattery (self)
 
def getGyroCalibration (self)
 
def getLEDs (self, asInt=False)
 
def getMeanAccelerator (self)
 
def getMeanGyro (self)
 
def getNunchukFactoryCalibrationSettings (self)
 
def getRumble (self)
 
def getStdevAccelerator (self)
 
def getStdevGyro (self)
 
def getVarianceAccelerator (self)
 
def getVarianceGyro (self)
 
def getWiimoteState (self)
 
def motionPlusPresent (self)
 
def nunchukPresent (self)
 
def printState (self)
 
def setAccelerometerCalibration (self, zeroReadingList, oneReadingList)
 
def setAccelerometerCalibration (self, zeroReadingNPArray, oneReadingNPArray)
 
def setGyroCalibration (self, gyroTriplet)
 
def setLEDs (self, statusList)
 
def setNunchukAccelerometerCalibration (self, zeroReadingList, oneReadingList)
 
def setRumble (self, switchPos)
 
def shutdown (self)
 
def zeroDevice (self)
 

Public Attributes

 calibrationSamples
 
 gatherCalibrationStats
 
 lastZeroingTime
 
 latestCalibrationSuccessful
 
 maxAccReading
 
 maxGyroReading
 
 meanAcc
 
 meanAccMetric
 
 meanGyro
 
 meanGyroMetric
 
 sampleRate
 
 stdevAcc
 
 stdevAccMetric
 
 stdevGyro
 
 stdevGyroMetric
 
 varAcc
 
 varGyroMetric
 
 wiiMoteState
 
 wiiStateLock
 

Static Public Attributes

 BATTERY_MAX = cwiid.BATTERY_MAX
 

Private Member Functions

def _calibrationCallback (self, state, theTime)
 
def _getInstanceVarCriticalSection (self, varName)
 
def _steadyStateCallback (self, state, theTime)
 

Private Attributes

 _warmupCnt
 

Static Private Attributes

 _accList = None
 
 _accNormal = None
 
 _accTotal = None
 
 _gyroList = None
 
 _gyroNormal = None
 
 _gyroTotal = None
 
list _LEDMasksOff
 
list _LEDMasksOn = [LED1_ON, LED2_ON, LED3_ON, LED4_ON]
 
 _nunchukJoyOrig = None
 
 _readingsCnt = None
 
 _startTime = None
 
 _wiiCallbackStack = None
 
 _wm = None
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Member Function Documentation

def wiimote.WIIMote.WIIMote._calibrationCallback (   self,
  state,
  theTime 
)
private
Wii's callback destination while zeroing the device.

Definition at line 263 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 510 of file WIIMote.py.

def wiimote.WIIMote.WIIMote._steadyStateCallback (   self,
  state,
  theTime 
)
private

Definition at line 238 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 755 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 784 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 642 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 654 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.getBattery (   self)
Obtain battery state from Wiimote.

Maximum charge is BATTERY_MAX.

Definition at line 630 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.getGyroCalibration (   self)
Return current Gyro zeroing offsets as list x/y/z.

Definition at line 699 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 588 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.getMeanAccelerator (   self)
Accessor that provides locking.

Definition at line 455 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.getMeanGyro (   self)
Accessor that provides locking.

Definition at line 482 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 674 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.getRumble (   self)

Definition at line 550 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.getStdevAccelerator (   self)
Accessor that provides locking.

Definition at line 464 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.getStdevGyro (   self)
Accessor that provides locking.

Definition at line 491 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.getVarianceAccelerator (   self)
Accessor that provides locking.

Definition at line 473 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.getVarianceGyro (   self)
Accessor that provides locking.

Definition at line 500 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.getWiimoteState (   self)
Returns the most recent Wiistate instance. Provides proper locking.

Definition at line 446 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 721 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 738 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.printState (   self)

Definition at line 808 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.setAccelerometerCalibration (   self,
  zeroReadingList,
  oneReadingList 
)

Definition at line 689 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.setAccelerometerCalibration (   self,
  zeroReadingNPArray,
  oneReadingNPArray 
)

Definition at line 692 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.setGyroCalibration (   self,
  gyroTriplet 
)

Definition at line 707 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 562 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.setNunchukAccelerometerCalibration (   self,
  zeroReadingList,
  oneReadingList 
)

Definition at line 714 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 541 of file WIIMote.py.

def wiimote.WIIMote.WIIMote.shutdown (   self)

Definition at line 816 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 298 of file WIIMote.py.

Member Data Documentation

wiimote.WIIMote.WIIMote._accList = None
staticprivate

Definition at line 112 of file WIIMote.py.

wiimote.WIIMote.WIIMote._accNormal = None
staticprivate

Definition at line 119 of file WIIMote.py.

wiimote.WIIMote.WIIMote._accTotal = None
staticprivate

Definition at line 115 of file WIIMote.py.

wiimote.WIIMote.WIIMote._gyroList = None
staticprivate

Definition at line 113 of file WIIMote.py.

wiimote.WIIMote.WIIMote._gyroNormal = None
staticprivate

Definition at line 120 of file WIIMote.py.

wiimote.WIIMote.WIIMote._gyroTotal = None
staticprivate

Definition at line 116 of file WIIMote.py.

list wiimote.WIIMote.WIIMote._LEDMasksOff
staticprivate
Initial value:
1 = [0 | LED2_ON | LED3_ON | LED4_ON, # AND to turn off
2  0 | LED1_ON | LED3_ON | LED4_ON,
3  0 | LED1_ON | LED2_ON | LED4_ON,
4  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]
staticprivate

Definition at line 124 of file WIIMote.py.

wiimote.WIIMote.WIIMote._nunchukJoyOrig = None
staticprivate

Definition at line 122 of file WIIMote.py.

wiimote.WIIMote.WIIMote._readingsCnt = None
staticprivate

Definition at line 114 of file WIIMote.py.

wiimote.WIIMote.WIIMote._startTime = None
staticprivate

Definition at line 111 of file WIIMote.py.

wiimote.WIIMote.WIIMote._warmupCnt
private

Definition at line 321 of file WIIMote.py.

wiimote.WIIMote.WIIMote._wiiCallbackStack = None
staticprivate

Definition at line 109 of file WIIMote.py.

wiimote.WIIMote.WIIMote._wm = None
staticprivate

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.

wiimote.WIIMote.WIIMote.calibrationSamples

Definition at line 149 of file WIIMote.py.

wiimote.WIIMote.WIIMote.gatherCalibrationStats

Definition at line 147 of file WIIMote.py.

wiimote.WIIMote.WIIMote.lastZeroingTime

Definition at line 145 of file WIIMote.py.

wiimote.WIIMote.WIIMote.latestCalibrationSuccessful

Definition at line 187 of file WIIMote.py.

wiimote.WIIMote.WIIMote.maxAccReading

Definition at line 759 of file WIIMote.py.

wiimote.WIIMote.WIIMote.maxGyroReading

Definition at line 787 of file WIIMote.py.

wiimote.WIIMote.WIIMote.meanAcc

Definition at line 170 of file WIIMote.py.

wiimote.WIIMote.WIIMote.meanAccMetric

Definition at line 171 of file WIIMote.py.

wiimote.WIIMote.WIIMote.meanGyro

Definition at line 179 of file WIIMote.py.

wiimote.WIIMote.WIIMote.meanGyroMetric

Definition at line 180 of file WIIMote.py.

wiimote.WIIMote.WIIMote.sampleRate

Definition at line 164 of file WIIMote.py.

wiimote.WIIMote.WIIMote.stdevAcc

Definition at line 173 of file WIIMote.py.

wiimote.WIIMote.WIIMote.stdevAccMetric

Definition at line 174 of file WIIMote.py.

wiimote.WIIMote.WIIMote.stdevGyro

Definition at line 182 of file WIIMote.py.

wiimote.WIIMote.WIIMote.stdevGyroMetric

Definition at line 183 of file WIIMote.py.

wiimote.WIIMote.WIIMote.varAcc

Definition at line 176 of file WIIMote.py.

wiimote.WIIMote.WIIMote.varGyroMetric

Definition at line 185 of file WIIMote.py.

wiimote.WIIMote.WIIMote.wiiMoteState

Definition at line 163 of file WIIMote.py.

wiimote.WIIMote.WIIMote.wiiStateLock

Definition at line 162 of file WIIMote.py.


The documentation for this class was generated from the following file:


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