wiimoteTests.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 #
4 # WIIMote Run Tests
5 #
6 # ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7 
8 # TODO: Don't duplicate cwiid constants in armConrolConstants.py
9 # TODO: Offer exception if stdev is too high in IMU readings
10 # TODO: Zeroing
11 # TODO: Catch wiimote being turned off.
12 
13 
14 from __future__ import absolute_import
15 from . import WIIMote
16 from .wiimoteExceptions import *
17 from .wiiutils import *
18 from .wiistate import *
19 import numpy as np
20 
21 mySampleRate = 1
22 try:
23  ac = WIIMote.WIIMote(theSampleRate=mySampleRate)
24  ac.zeroDevice()
25 
26 # ********************
27 # numSamples = 50
28 #
29 # accMeans = []
30 # accStdevs = []
31 # gyroMeans = []
32 # gyroStdevs = []
33 #
34 # for i in range(numSamples):
35 # ac.zero()
36 # accMeans.append(ac.meanAcc)
37 # accStdevs.append(ac.stdevAcc)
38 # gyroMeans.append(ac.meanGyro)
39 # gyroStdevs.append(ac.stdevGyro)
40 #
41 # accMean = np.vstack(accMeans).mean(axis=0)
42 # accStdev = np.vstack(accMeans).std(axis=0)
43 # gyroMean = np.vstack(gyroMeans).mean(axis=0)
44 # gyroStdev = np.vstack(gyroMeans).std(axis=0)
45 #
46 # report("Acc mean: " + `accMean` + " Min mean: " + `np.vstack(accMeans).min(axis=0)` +
47 # " Max mean: " + `np.vstack(accMeans).max(axis=0)`)
48 # report("Acc stdev: " + `np.vstack(accMeans).std(axis=0)`)
49 #
50 # report("Gyro mean: " + `gyroMean` + " Min gyro: " + `np.vstack(gyroMeans).min(axis=0)` +
51 # " Max gyro: " + `np.vstack(gyroMeans).max(axis=0)`)
52 # report("Gyro stdev: " + `gyroStdev`)
53 #
54 #
55 #
56 #
57 # exit(0)
58 #
59 # report ("Acc list: " + `map(lambda wiiReading: wiiReading.tuple(), ac._accList)`)
60 # report ("Acc mean: " + `ac.meanAcc` + " Acc stdev: " + `ac.stdevAcc`)
61 # report ("Gyro list: " + `map(lambda wiiReading: wiiReading.tuple(), ac._gyroList[1:])`)
62 # report ("Gyro mean: " + `ac.meanGyro` + " Gyro stdev: " + `ac.stdevGyro`)
63 # ********************
64 
65 except WiimoteError as e:
66  report(e)
67  exit()
68 
69 
70 ledCycle = 0
71 try:
72  while True:
73  time.sleep(mySampleRate)
74 
75  ac.printState()
76 
77  if ledCycle == 0:
78  ac.setLEDs([True, False, False, False])
79  elif ledCycle == 1:
80  ac.setLEDs([False, True, False, False])
81  elif ledCycle == 2:
82  ac.setLEDs([False, False, True, False])
83  elif ledCycle == 3:
84  ac.setLEDs([False, False, False, True])
85  elif ledCycle == 4:
86  ac.setLEDs([True, False, False, None])
87  elif ledCycle == 5:
88  ac.setLEDs([None, True, True, None])
89  elif ledCycle == 6:
90  ac.setLEDs([False, False, False, False])
91  ledCycle += 1
92  if ledCycle >= 7:
93  ledCycle = 0
94 
95 
96 finally:
97  ac.shutdown()
wiimote.wiiutils.report
def report(str, debuglevel=acConst._DEBUGLEVEL)
Definition: wiiutils.py:26
wiimote.WIIMote.WIIMote
Definition: WIIMote.py:53


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