aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-01-28 16:24:41 -0500
committerGravatar rcoh <rcoh@mit.edu>2011-01-28 16:24:41 -0500
commit23b8176c9e7fcbcc7fbe45b9840012a91e2f39e0 (patch)
treebfae320048c9216ffd800cbd49a964f33b55fb4a
parentbd1119e82ff9f4bd8835ed6d3934f156a6da8b23 (diff)
parent51b0d5f0cd4524a977e0bf48ca6f643d85d05d00 (diff)
Merge branch 'mobileapp' of github.com:rcoh/SmootLight into fridaydemo
-rw-r--r--behaviors/MobileShakeBehavior.py29
-rw-r--r--behaviors/MoveBehavior.py7
-rw-r--r--config/MobileTest.xml28
-rw-r--r--inputs/TCPInput.py2
4 files changed, 37 insertions, 29 deletions
diff --git a/behaviors/MobileShakeBehavior.py b/behaviors/MobileShakeBehavior.py
index e25e929..b05cb5f 100644
--- a/behaviors/MobileShakeBehavior.py
+++ b/behaviors/MobileShakeBehavior.py
@@ -1,17 +1,26 @@
from operationscore.Behavior import *
+import util.ComponentRegistry as compReg
import util.Strings as Strings
class MobileShakeBehavior(Behavior):
+ def behaviorInit(self):
+ self.mapper = None
+
def processResponse(self, sensorInputs, recursiveInputs):
+ if self.mapper == None:
+ try:
+ self.mapper = compReg.getComponent('mobilegaussmap')
+ except KeyError:
+ pass
+
#print sensorInputs
- ret = []
for sInput in sensorInputs:
- outDict = dict(sInput)
- if 'type' in sInput and sInput['type'] == 2:
- outDict['Location'] = '{x}>' + str(0) + ',{y}>' + str(0)
- outDict['Color'] = [sInput['r'], sInput['g'], sInput['b']]
- else: # dumb invisible pixel
- outDict['Location'] = (-1, -1)
- outDict['Color'] = [0, 0, 0]
- ret.append(outDict)
- return (ret, recursiveInputs)
+ if 'Shake' in sInput and sInput['Shake'] == 1:
+ #print 'increase!'
+ self.mapper.argDict['Width'] += 30
+ #self.mapper.argDict['CutoffDist'] += 20
+ sInput['Shake'] = 0
+ print 'Width:' + str(compReg.getComponent('mobilegaussmap').argDict['Width'])
+ #print 'CutoffDist: '+ str(compReg.getComponent('mobilegaussmap').argDict['CutoffDist'])
+
+ return (sensorInputs, recursiveInputs)
diff --git a/behaviors/MoveBehavior.py b/behaviors/MoveBehavior.py
index e504ca9..6e7fc6a 100644
--- a/behaviors/MoveBehavior.py
+++ b/behaviors/MoveBehavior.py
@@ -19,12 +19,13 @@ class MoveBehavior(Behavior):
currDict = dict(currRecLoc)
for sensorInput in sensorInputs:
if 'type' in sensorInput and sensorInput['type'] == 1:
+ currDict['Shake'] = 0
currDict['Location'] = (currDict['Location'][0] - sensorInput['x'] * self['XStep'], \
currDict['Location'][1] + sensorInput['y'] * self['YStep'])
currDict['Color'] = [sensorInput['r'], sensorInput['g'], sensorInput['b']]
- #elif sensorInput['type'] == 2:
- # currDict['Shake'] = 1
- # currDict['Force'] = sensorInput['force']
+ elif sensorInput['type'] == 2:
+ currDict['Shake'] = 1
+ #currDict['Force'] = sensorInput['force']
ret.append(currDict)
#print ret
return (ret, ret)
diff --git a/config/MobileTest.xml b/config/MobileTest.xml
index af94c25..63c3b47 100644
--- a/config/MobileTest.xml
+++ b/config/MobileTest.xml
@@ -26,6 +26,16 @@
<Height>1</Height>
</Args>
</PixelMapper>
+ <PixelMapper>
+ <Class>pixelmappers.GaussianMapper</Class>
+ <Args>
+ <Id>mobilegaussmap</Id>
+ <CutoffDist>30</CutoffDist>
+ <MinWeight>0.1</MinWeight>
+ <Width>10</Width>
+ <Height>1</Height>
+ </Args>
+ </PixelMapper>
</PixelMapperConfiguration>
<RendererConfiguration>
<Renderer>
@@ -227,26 +237,12 @@
</Inputs>
<ChainedBehaviors>
<Id>move</Id>
+ <Id>mobileshake</Id>
<Id>decay</Id>
</ChainedBehaviors>
<RenderToScreen>True</RenderToScreen>
- <Mapper>gaussmap</Mapper>
+ <Mapper>mobilegaussmap</Mapper>
</Args>
</Behavior>
- <Behavior>
- <Class>behaviors.BehaviorChain</Class>
- <Args>
- <Id>shakeanddecay</Id>
- <Inputs>
- <Id>tcp</Id>
- </Inputs>
- <ChainedBehaviors>
- <Id>mobileshake</Id>
- <Id>slowdecay</Id>
- </ChainedBehaviors>
- <RenderToScreen>True</RenderToScreen>
- <Mapper>simplemap</Mapper>
- </Args>
- </Behavior>
</BehaviorConfiguration>
</LightInstallation>
diff --git a/inputs/TCPInput.py b/inputs/TCPInput.py
index 51a6677..e565649 100644
--- a/inputs/TCPInput.py
+++ b/inputs/TCPInput.py
@@ -50,6 +50,8 @@ class TCPInput(Input):
for datagroup in data.split('\n'):
if datagroup != None and datagroup != '':
dataDict = json.loads(datagroup)
+ #if dataDict['type'] != 1:
+ #print dataDict
self.respond(dataDict)
except Exception as exp:
print str(exp)