Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
wiimote.WIIMote.WIIMote Class Reference

List of all members.

Public Member Functions

def __init__
def computeAccStatistics
def computeGyroStatistics
def getAccelerometerCalibration
def getAccFactoryCalibrationSettings
def getBattery
def getGyroCalibration
def getLEDs
def getMeanAccelerator
def getMeanGyro
def getNunchukFactoryCalibrationSettings
def getRumble
def getStdevAccelerator
def getStdevGyro
def getVarianceAccelerator
def getVarianceGyro
def getWiimoteState
def motionPlusPresent
def nunchukPresent
def printState
def setAccelerometerCalibration
def setAccelerometerCalibration
def setGyroCalibration
def setLEDs
def setNunchukAccelerometerCalibration
def setRumble
def shutdown
def zeroDevice

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
def _getInstanceVarCriticalSection
def _steadyStateCallback

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 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.

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.

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.

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.

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.

Obtain battery state from Wiimote.

Maximum charge is BATTERY_MAX.

Definition at line 634 of file WIIMote.py.

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.

Accessor that provides locking.

Definition at line 459 of file WIIMote.py.

Accessor that provides locking.

Definition at line 486 of file WIIMote.py.

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.

Definition at line 554 of file WIIMote.py.

Accessor that provides locking.

Definition at line 468 of file WIIMote.py.

Accessor that provides locking.

Definition at line 495 of file WIIMote.py.

Accessor that provides locking.

Definition at line 477 of file WIIMote.py.

Accessor that provides locking.

Definition at line 504 of file WIIMote.py.

Returns the most recent Wiistate instance. Provides proper locking.

Definition at line 450 of file WIIMote.py.

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.

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.

Definition at line 812 of file WIIMote.py.

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

Definition at line 693 of file WIIMote.py.

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

Definition at line 696 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.

Definition at line 820 of file WIIMote.py.

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.


Member Data Documentation

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.

Initial value:
[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.

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.

Definition at line 319 of file WIIMote.py.

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 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 759 of file WIIMote.py.

Definition at line 788 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.

Definition at line 142 of file WIIMote.py.


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


wiimote
Author(s): Andreas Paepcke and Melonee Wise
autogenerated on Sat Dec 28 2013 17:06:51