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

Constructor & Destructor Documentation

◆ __init__()

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

Member Function Documentation

◆ _calibrationCallback()

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

Definition at line 214 of file WIIMote.py.

◆ _getInstanceVarCriticalSection()

def wiimote.WIIMote.WIIMote._getInstanceVarCriticalSection (   self,
  varName 
)
private
Return the value of the given instance variable, providing locking service.

Definition at line 420 of file WIIMote.py.

◆ _steadyStateCallback()

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

Definition at line 194 of file WIIMote.py.

◆ computeAccStatistics()

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

◆ computeGyroStatistics()

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

◆ getAccelerometerCalibration()

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

◆ getAccFactoryCalibrationSettings()

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

◆ getBattery()

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

Maximum charge is BATTERY_MAX.

Definition at line 518 of file WIIMote.py.

◆ getGyroCalibration()

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

Definition at line 567 of file WIIMote.py.

◆ getLEDs()

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

◆ getMeanAccelerator()

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

Definition at line 390 of file WIIMote.py.

◆ getMeanGyro()

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

Definition at line 405 of file WIIMote.py.

◆ getNunchukFactoryCalibrationSettings()

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

◆ getRumble()

def wiimote.WIIMote.WIIMote.getRumble (   self)

Definition at line 451 of file WIIMote.py.

◆ getStdevAccelerator()

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

Definition at line 395 of file WIIMote.py.

◆ getStdevGyro()

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

Definition at line 410 of file WIIMote.py.

◆ getVarianceAccelerator()

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

Definition at line 400 of file WIIMote.py.

◆ getVarianceGyro()

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

Definition at line 415 of file WIIMote.py.

◆ getWiimoteState()

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

Definition at line 385 of file WIIMote.py.

◆ motionPlusPresent()

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

◆ nunchukPresent()

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

◆ printState()

def wiimote.WIIMote.WIIMote.printState (   self)

Definition at line 646 of file WIIMote.py.

◆ setAccelerometerCalibration() [1/2]

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

Definition at line 561 of file WIIMote.py.

◆ setAccelerometerCalibration() [2/2]

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

Definition at line 564 of file WIIMote.py.

◆ setGyroCalibration()

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

Definition at line 571 of file WIIMote.py.

◆ setLEDs()

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

◆ setNunchukAccelerometerCalibration()

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

Definition at line 574 of file WIIMote.py.

◆ setRumble()

def wiimote.WIIMote.WIIMote.setRumble (   self,
  switchPos 
)
Start of stop rumble (i.e. vibration). 1: start; 0: stop

Definition at line 447 of file WIIMote.py.

◆ shutdown()

def wiimote.WIIMote.WIIMote.shutdown (   self)

Definition at line 649 of file WIIMote.py.

◆ zeroDevice()

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

Member Data Documentation

◆ _accList

wiimote.WIIMote.WIIMote._accList = None
staticprivate

Definition at line 77 of file WIIMote.py.

◆ _accNormal

wiimote.WIIMote.WIIMote._accNormal = None
staticprivate

Definition at line 83 of file WIIMote.py.

◆ _accTotal

wiimote.WIIMote.WIIMote._accTotal = None
staticprivate

Definition at line 80 of file WIIMote.py.

◆ _gyroList

wiimote.WIIMote.WIIMote._gyroList = None
staticprivate

Definition at line 78 of file WIIMote.py.

◆ _gyroNormal

wiimote.WIIMote.WIIMote._gyroNormal = None
staticprivate

Definition at line 84 of file WIIMote.py.

◆ _gyroTotal

wiimote.WIIMote.WIIMote._gyroTotal = None
staticprivate

Definition at line 81 of file WIIMote.py.

◆ _LEDMasksOff

list wiimote.WIIMote.WIIMote._LEDMasksOff
staticprivate
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 89 of file WIIMote.py.

◆ _LEDMasksOn

list wiimote.WIIMote.WIIMote._LEDMasksOn = [LED1_ON, LED2_ON, LED3_ON, LED4_ON]
staticprivate

Definition at line 88 of file WIIMote.py.

◆ _nunchukJoyOrig

wiimote.WIIMote.WIIMote._nunchukJoyOrig = None
staticprivate

Definition at line 86 of file WIIMote.py.

◆ _readingsCnt

wiimote.WIIMote.WIIMote._readingsCnt = None
staticprivate

Definition at line 79 of file WIIMote.py.

◆ _startTime

wiimote.WIIMote.WIIMote._startTime = None
staticprivate

Definition at line 76 of file WIIMote.py.

◆ _warmupCnt

wiimote.WIIMote.WIIMote._warmupCnt
private

Definition at line 269 of file WIIMote.py.

◆ _wiiCallbackStack

wiimote.WIIMote.WIIMote._wiiCallbackStack = None
staticprivate

Definition at line 74 of file WIIMote.py.

◆ _wm

wiimote.WIIMote.WIIMote._wm = None
staticprivate

Definition at line 73 of file WIIMote.py.

◆ BATTERY_MAX

wiimote.WIIMote.WIIMote.BATTERY_MAX = cwiid.BATTERY_MAX
static

Definition at line 71 of file WIIMote.py.

◆ calibrationSamples

wiimote.WIIMote.WIIMote.calibrationSamples

Definition at line 109 of file WIIMote.py.

◆ gatherCalibrationStats

wiimote.WIIMote.WIIMote.gatherCalibrationStats

Definition at line 107 of file WIIMote.py.

◆ lastZeroingTime

wiimote.WIIMote.WIIMote.lastZeroingTime

Definition at line 105 of file WIIMote.py.

◆ latestCalibrationSuccessful

wiimote.WIIMote.WIIMote.latestCalibrationSuccessful

Definition at line 147 of file WIIMote.py.

◆ maxAccReading

wiimote.WIIMote.WIIMote.maxAccReading

Definition at line 607 of file WIIMote.py.

◆ maxGyroReading

wiimote.WIIMote.WIIMote.maxGyroReading

Definition at line 630 of file WIIMote.py.

◆ meanAcc

wiimote.WIIMote.WIIMote.meanAcc

Definition at line 130 of file WIIMote.py.

◆ meanAccMetric

wiimote.WIIMote.WIIMote.meanAccMetric

Definition at line 131 of file WIIMote.py.

◆ meanGyro

wiimote.WIIMote.WIIMote.meanGyro

Definition at line 139 of file WIIMote.py.

◆ meanGyroMetric

wiimote.WIIMote.WIIMote.meanGyroMetric

Definition at line 140 of file WIIMote.py.

◆ sampleRate

wiimote.WIIMote.WIIMote.sampleRate

Definition at line 124 of file WIIMote.py.

◆ stdevAcc

wiimote.WIIMote.WIIMote.stdevAcc

Definition at line 133 of file WIIMote.py.

◆ stdevAccMetric

wiimote.WIIMote.WIIMote.stdevAccMetric

Definition at line 134 of file WIIMote.py.

◆ stdevGyro

wiimote.WIIMote.WIIMote.stdevGyro

Definition at line 142 of file WIIMote.py.

◆ stdevGyroMetric

wiimote.WIIMote.WIIMote.stdevGyroMetric

Definition at line 143 of file WIIMote.py.

◆ varAcc

wiimote.WIIMote.WIIMote.varAcc

Definition at line 136 of file WIIMote.py.

◆ varGyroMetric

wiimote.WIIMote.WIIMote.varGyroMetric

Definition at line 145 of file WIIMote.py.

◆ wiiMoteState

wiimote.WIIMote.WIIMote.wiiMoteState

Definition at line 123 of file WIIMote.py.

◆ wiiStateLock

wiimote.WIIMote.WIIMote.wiiStateLock

Definition at line 122 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 Thu Dec 5 2024 03:18:13