aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-02-13 19:10:54 -0500
committerGravatar rcoh <rcoh@mit.edu>2011-02-13 19:10:54 -0500
commiteb8e19fbc6368c5e3eb0d58698ac020939ec74b7 (patch)
tree1648da7d7c49b141eeab7863929a9589d5d07bfa
parent85cecf2a74d452a065766440d76a165fb07753a6 (diff)
parent7a4f06d15b0fe9bd22996af6a1ca2c3ca5ca3e3f (diff)
Merge branch 'conner5' of github.com:dxiao/SmootLight into conner5
-rw-r--r--behaviors/VerticalBar.py30
-rw-r--r--config/C5Sign-dxiao.xml396
-rw-r--r--config/C5Sign.xml2
-rw-r--r--inputs/ContinuousLocationInput.py19
-rw-r--r--pixelmappers/C5SignMapper.py101
5 files changed, 530 insertions, 18 deletions
diff --git a/behaviors/VerticalBar.py b/behaviors/VerticalBar.py
new file mode 100644
index 0000000..e1a67fe
--- /dev/null
+++ b/behaviors/VerticalBar.py
@@ -0,0 +1,30 @@
+from operationscore.Behavior import *
+class VerticalBar(Behavior):
+
+ def processResponse(self, inputs, recurs):
+
+ ret = []
+ for inputset in inputs:
+ #import pdb; pdb.set_trace()
+
+ if 'xLoc' not in inputset:
+ inputset['xLoc'] = inputset['Location'][0]
+ xLoc = inputset['xLoc']
+
+ condition = '{x} == ' + str(xLoc)
+
+ if self['Combine']:
+ inputset['Location'] += ',' + condition
+ else:
+ inputset['Location'] = condition
+
+ ret.append(inputset)
+
+ return (ret, [])
+
+ def setLastOutput(self, output):
+
+ coutput = Behavior.deepCopyPacket(output)
+ for data in coutput:
+ data['Location'] = data['xLoc']
+ return coutput
diff --git a/config/C5Sign-dxiao.xml b/config/C5Sign-dxiao.xml
new file mode 100644
index 0000000..38eb40c
--- /dev/null
+++ b/config/C5Sign-dxiao.xml
@@ -0,0 +1,396 @@
+<!---All configuration items contain a "Class" tag specifying the python class they represent, and an "Args" tag specifying the args to be passed in.-->
+<LightInstallation>
+ <InstallationConfiguration>
+ <Defaults>
+ <PixelMapper>simplemap</PixelMapper>
+ </Defaults>
+ </InstallationConfiguration>
+ <PixelConfiguration>
+ <InheritsFrom>layouts/C5SignLayout.xml</InheritsFrom>
+ </PixelConfiguration>
+ <PixelMapperConfiguration>
+ <!-- ****************************** -->
+ <PixelMapper>
+ <Class>pixelmappers.C5SignMapper</Class>
+ <Args>
+ <Id>c5signmapper</Id>
+ <CutoffDist>20</CutoffDist>
+ </Args>
+ </PixelMapper>
+ <!-- ****************************** -->
+ <PixelMapper>
+ <Class>pixelmappers.SimpleMapper</Class>
+ <Args>
+ <Id>simplemap</Id>
+ <CutoffDist>20</CutoffDist>
+ </Args>
+ </PixelMapper>
+ <PixelMapper>
+ <Class>pixelmappers.GaussianMapper</Class>
+ <Args>
+ <Id>gaussmap</Id>
+ <CutoffDist>30</CutoffDist>
+ <MinWeight>0.1</MinWeight>
+ <Width>7</Width>
+ <Height>1</Height>
+ </Args>
+ </PixelMapper>
+ </PixelMapperConfiguration>
+ <RendererConfiguration>
+ <Renderer>
+ <InheritsFrom>renderers/C5Renderer.xml</InheritsFrom>
+ </Renderer>
+ <Renderer>
+ <InheritsFrom>renderers/Pygame.xml</InheritsFrom>
+ </Renderer>
+ </RendererConfiguration>
+ <InputConfiguration>
+ <!--InputElement>
+ <Class>inputs.PygameInput</Class>
+ <Args>
+ <Id>pygameclick</Id>
+ <RefreshInterval>10</RefreshInterval>
+ <Clicks>True</Clicks>
+ </Args>
+ </InputElement-->
+ <InputElement>
+ <Class>inputs.OSCInput</Class>
+ <Args>
+ <Id>osc</Id>
+ <Port>1234</Port>
+ <RefreshInterval>10</RefreshInterval>
+ </Args>
+ </InputElement>
+ <!--InputElement>
+ <Class>inputs.PygameInput</Class>
+ <Args>
+ <Id>pygamekey</Id>
+ <RefreshInterval>10</RefreshInterval>
+ <Keyboard>True</Keyboard>
+ </Args>
+ </InputElement-->
+ <InputElement>
+ <Class>inputs.UDPInput</Class>
+ <Args>
+ <Id>udp</Id>
+ <Port>3344</Port>
+ <RefreshInterval>50</RefreshInterval>
+ </Args>
+ </InputElement>
+ <InputElement>
+ <Class>inputs.ContinuousCenterInput</Class>
+ <Args>
+ <Id>center</Id>
+ <RefreshInterval>1800</RefreshInterval>
+ </Args>
+ </InputElement>
+ <!-- ****************************** -->
+ <InputElement>
+ <Class>inputs.ContinuousLocationInput</Class>
+ <Args>
+ <Id>centerleft</Id>
+ <xloc>left</xloc>
+ <yloc>center</yloc>
+ <RefreshInterval>1800</RefreshInterval>
+ </Args>
+ </InputElement>
+ <!-- ****************************** -->
+ <!--<InputElement>
+ <Class>inputs.TCPInput</Class>
+ <Args>
+ <Id>tcp</Id>
+ <Port>20120</Port>
+ <RefreshInterval>10</RefreshInterval>
+ </Args>
+ </InputElement>-->
+ <!--InputElement Id="followmouse" RefreshInterval="10">
+ <InheritsFrom>inputs/MouseFollower.xml</InheritsFrom>
+ </InputElement-->
+ </InputConfiguration>
+ <BehaviorConfiguration>
+ <Behavior>
+ <Args>
+ <Id>touchosc</Id>
+ </Args>
+ <Class>behaviors.TouchOSC</Class>
+ </Behavior>
+ <Behavior Id="colorchange">
+ <InheritsFrom>behaviors/RandomColor.xml</InheritsFrom>
+ <Args>
+ <!--ColorList>
+ <Val>(255,0,0)</Val>
+ <Val>(0,0,255)</Val>
+ </ColorList-->
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>OSCTouchChase</Id>
+ <Inputs>
+ <Id>osc</Id>
+ </Inputs>
+ <ChainedBehaviors>
+ <Id>touchosc</Id>
+ <Id>decay</Id>
+ </ChainedBehaviors>
+ <Mapper>gaussmap</Mapper>
+ <RenderToScreen>False</RenderToScreen>
+ </Args>
+ </Behavior>
+ <Behavior Id="decay">
+ <InheritsFrom>behaviors/PixelDecay.xml</InheritsFrom>
+ </Behavior>
+ <Behavior Id="singleframe">
+ <InheritsFrom>behaviors/SingleFrame.xml</InheritsFrom>
+ </Behavior>
+ <!-- ****************************** -->
+ <Behavior Id="slowdecay">
+ <InheritsFrom>behaviors/PixelDecay.xml</InheritsFrom>
+ <Args>
+ <Coefficient>.001</Coefficient>
+ </Args>
+ </Behavior>
+ <!-- ****************************** -->
+ <Behavior>
+ <Class>behaviors.XYMove</Class>
+ <Args>
+ <Id>xymove</Id>
+ <XStep>1</XStep>
+ <YStep>1</YStep>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.RestrictLocation</Class>
+ <Args>
+ <Id>xbounce</Id>
+ <Action>{val}*-1</Action>
+ <ParamName>XStep</ParamName>
+ <LocationRestriction>{x}&lt;2 or {x}&gt;48</LocationRestriction>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.RestrictLocation</Class>
+ <Args>
+ <Id>ybounce</Id>
+ <Action>{val}*-1</Action>
+ <ParamName>YStep</ParamName>
+ <LocationRestriction>{y}&lt;2 or {y}&gt;24</LocationRestriction>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>movebounce</Id>
+ <ChainedBehaviors>
+ <Id>xymove</Id>
+ <Id>ybounce</Id>
+ <Id>xbounce</Id>
+ </ChainedBehaviors>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.ModifyParam</Class>
+ <Args>
+ <Id>ysin</Id>
+ <ParamName>YStep</ParamName>
+ <ParamType>Sensor</ParamType>
+ <ParamOp>4*math.sin({x}/float(40))</ParamOp>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.DebugBehavior</Class>
+ <Args>
+ <Id>debug</Id>
+ <z-index>0</z-index>
+ <Inputs>
+ <Id>pygamekey</Id>
+ <Id>udp</Id>
+ </Inputs>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.AllPixels</Class>
+ <Args>
+ <Id>square</Id>
+ <Width>20</Width>
+ </Args>
+ </Behavior>
+ <Behavior Id="recursivedecay">
+ <InheritsFrom>behaviors/LoopAndDie.xml</InheritsFrom>
+ <Args>
+ <InitialResponseCount>160</InitialResponseCount>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>runcolordecay</Id>
+ <Inputs>
+ <Id>pygameclick</Id>
+ </Inputs>
+ <ChainedBehaviors>
+ <Id>colorchange</Id>
+ <Id>mover</Id>
+ <!--<Id>square</Id>-->
+ <Id>decay</Id>
+ </ChainedBehaviors>
+ <RecursiveHooks>{'mover':'movebounce'}</RecursiveHooks>
+ <RenderToScreen>False</RenderToScreen>
+ <Mapper>gaussmap</Mapper>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.ResponseMover</Class>
+ <Args>
+ <Id>mover</Id>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.RandomWalk</Class>
+ <Args>
+ <Id>randmovement</Id>
+ <StepSize>2</StepSize>
+ </Args>
+ </Behavior>
+ <Behavior Id="accelerate">
+ <InheritsFrom>behaviors/Accelerate.xml</InheritsFrom>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.EchoBehavior</Class>
+ <Args>
+ <Id>echo</Id>
+ <z-index>0</z-index>
+ <RenderToScreen>False</RenderToScreen>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.ColorShift</Class>
+ <Args>
+ <Id>colorshift</Id>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>mousechaser</Id>
+ <Inputs>
+ </Inputs>
+ <ChainedBehaviors>
+ <Id>echo</Id>
+ <Id>innercircle</Id>
+ <Id>outercircle</Id>
+ <Id>singleframe</Id>
+ </ChainedBehaviors>
+ <RenderToScreen>False</RenderToScreen>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.Circle</Class>
+ <Args>
+ <Id>innercircle</Id>
+ <Radius>0</Radius>
+ <Outside>True</Outside>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.Circle</Class>
+ <Args>
+ <Id>outercircle</Id>
+ <Radius>3</Radius>
+ <Combine>True</Combine>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.ModifyParam</Class>
+ <Args>
+ <Id>incrinner</Id>
+ <ParamOp>{val}+.3</ParamOp>
+ <ParamName>innercircleRadius</ParamName>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.ModifyParam</Class>
+ <Args>
+ <Id>incrouter</Id>
+ <ParamOp>{val}+.3</ParamOp>
+ <ParamName>outercircleRadius</ParamName>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>circle_expand</Id>
+ <ChainedBehaviors>
+ <Id>innercircle</Id>
+ <Id>outercircle</Id>
+ <Id>incrinner</Id>
+ <Id>incrouter</Id>
+ <Id>recursivedecay</Id>
+ </ChainedBehaviors>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>expandingcirlces</Id>
+ <Inputs>
+ <Id>centerleft</Id>
+ </Inputs>
+ <ChainedBehaviors>
+ <Id>colorchange</Id>
+ <Id>mover</Id>
+ <Id>decay</Id>
+ </ChainedBehaviors>
+ <RecursiveHooks>{'mover':'circle_expand'}</RecursiveHooks>
+ <RenderToScreen>False</RenderToScreen>
+ </Args>
+ </Behavior>
+ <!-- ****************************** -->
+ <Behavior>
+ <Class>behaviors.ModifyParam</Class>
+ <Args>
+ <Id>incrVertBarLoc</Id>
+ <ParamName>xLoc</ParamName>
+ <ParamOp>{val}+1</ParamOp>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.VerticalBar</Class>
+ <Args>
+ <Id>vertBar</Id>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>bar_move</Id>
+ <ChainedBehaviors>
+ <Id>vertBar</Id>
+ <Id>incrVertBarLoc</Id>
+ <Id>recursivedecay</Id>
+ </ChainedBehaviors>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>scanningbars</Id>
+ <Inputs>
+ <Id>centerleft</Id>
+ </Inputs>
+ <ChainedBehaviors>
+ <Id>colorchange</Id>
+ <Id>mover</Id>
+ <Id>slowdecay</Id>
+ </ChainedBehaviors>
+ <RecursiveHooks>{'mover':'bar_move'}</RecursiveHooks>
+ <RenderToScreen>True</RenderToScreen>
+ </Args>
+ </Behavior>
+ <!-- ****************************** -->
+ <Behavior Id="running">
+ <InheritsFrom>behaviors/RunningBehavior.xml</InheritsFrom>
+ </Behavior>
+ </BehaviorConfiguration>
+</LightInstallation>
diff --git a/config/C5Sign.xml b/config/C5Sign.xml
index 7ecb9e0..d4abdc1 100644
--- a/config/C5Sign.xml
+++ b/config/C5Sign.xml
@@ -10,7 +10,7 @@
</PixelConfiguration>
<PixelMapperConfiguration>
<PixelMapper>
- <Class>pixelmappers.SimpleMapper</Class>
+ <Class>pixelmappers.C5SignMapper</Class>
<Args>
<Id>simplemap</Id>
<CutoffDist>20</CutoffDist>
diff --git a/inputs/ContinuousLocationInput.py b/inputs/ContinuousLocationInput.py
new file mode 100644
index 0000000..f39bd9b
--- /dev/null
+++ b/inputs/ContinuousLocationInput.py
@@ -0,0 +1,19 @@
+import util.TimeOps as clock
+import util.ComponentRegistry as compReg
+import util.Strings as Strings
+from operationscore.Input import *
+class ContinuousLocationInput(Input):
+ '''Continuously returns one of nine positions on the screen as specified by the xloc
+ and yloc arguments, which can take values 'min', 'max', and 'center'. '''
+ def inputInit(self):
+ xvals = {}
+ yvals = {}
+ xvals['left'], yvals['bottom'], xvals['right'], yvals['top'] = compReg.getComponent('Screen').getSize()
+ (xvals['center'], yvals['center']) = ((xvals['left']+xvals['right']) / 2, (yvals['top']+yvals['bottom']) / 2)
+
+ self.location = (xvals[self['xloc']], yvals[self['yloc']])
+
+ def sensingLoop(self):
+ print (self.location)
+ self.respond({Strings.LOCATION: self.location})
+
diff --git a/pixelmappers/C5SignMapper.py b/pixelmappers/C5SignMapper.py
index b310c59..24631c4 100644
--- a/pixelmappers/C5SignMapper.py
+++ b/pixelmappers/C5SignMapper.py
@@ -1,6 +1,7 @@
from operationscore.PixelMapper import *
import util.Geo as Geo
import sys
+import math
class C5SignMapper(PixelMapper):
"""C5SignMapper is a modification to SimpleMapper which maps events to the
nearest Pixel. In addtion, it also maps sign artifacts (letters, logo, etc)
@@ -9,16 +10,73 @@ class C5SignMapper(PixelMapper):
(Conditons, separated by commas. and and or may also be used)."""
signPosition = {
- "ls" : [(2,8), (2,14), (2,20)],
- "ts" : [(4,22), (10,22), (16,22), (22,22), (27, 22), (33, 22), (39,22),
- (44, 22)],
- "rs" : [(45,2), (45, 8), (45,14), (45,20)],
- "bs" : [(4,2), (10,2), (16,2), (22, 2), (27,2), (34,2), (39,2), (44,2)],
- "wt" : [(12,5), (13, 5), (16,5), (18,5), (21,5), (23,5), (26,5), (27,5),
- (30,5), (34,5), (37,5)],
- "cl" : [(17,8), (21,10), (24,10), (26,12), (31,12)],
- "c5" : [(6,17), (11,17), (15,17), (19,17), (22, 17), (27,17), (33,16),
- (34, 16), (38,17), (42,17)]}
+ "ls" : {
+ 'all' : [(2,2),(2,8), (2,14), (2,20)],
+ '1' : [(2,2)],
+ '2' : [(2,8)],
+ '3' : [(2,14)],
+ '4' : [(2,20)] },
+ "ts" : {
+ 'all' : [(4,22), (10,22), (16,22), (22,22), (27, 22), (33, 22), (39,22), (44, 22)],
+ '1' : [(4,22)],
+ '2' : [(10,22)],
+ '3' : [(16,22)],
+ '4' : [(22,22)],
+ '5' : [(27,22)],
+ '6' : [(33,22)],
+ '7' : [(39,22)],
+ '8' : [(44,22)] },
+ "rs" : {
+ 'all' : [(45,2), (45, 8), (45,14), (45,20)],
+ '1' : [(45,2)],
+ '2' : [(45,8)],
+ '3' : [(45,14)],
+ '4' : [(45,20)] },
+ "bs" : {
+ 'all' : [(4,2), (10,2), (16,2), (22, 2), (27,2), (34,2), (39,2), (44,2)],
+ '1' : [(4,2)],
+ '2' : [(10,2)],
+ '3' : [(16,2)],
+ '4' : [(22,2)],
+ '5' : [(27,2)],
+ '6' : [(33,2)],
+ '7' : [(39,2)],
+ '8' : [(44,2)] },
+ "wt" : {
+ 'all' : [(12,5), (13, 5), (16,5), (18,5), (21,5), (23,5), (26,5), (27,5), (30,5), (34,5), (37,5)],
+ '1' : [(12,5), (13,5)],
+ '2' : [(16,5)],
+ '3' : [(18,5)],
+ '4' : [(21,5)],
+ '5' : [(23,5)],
+ '6' : [(26,5),(27,5)],
+ '7' : [(30,5)],
+ '8' : [(34,5)],
+ '9' : [(37,5)] },
+ "cl" : {
+ 'all' : [(17,8), (21,10), (24,10), (26,12), (31,12)],
+ 'in' : [(21,10),(24,10),(26,12)],
+ 'out' : [(17,8),(31,12)],
+ '1' : [(17,8)],
+ '2' : [(21,10)],
+ '3' : [(24,10)],
+ '4' : [(26,12)],
+ '5' : [(31,12)] },
+ "c5" : {
+ 'all' : [(6,17), (11,17), (15,17), (19,17), (22, 17), (27,17), (33,16), (34, 16), (38,17), (42,17)],
+ 'con' : [(6,17), (11,17), (15,17), (19,17), (22, 17), (27,17)],
+ 'five': [(33,16), (34, 16), (38,17), (42,17)],
+ '1' : [(6,17)],
+ '2' : [(11,17)],
+ '3' : [(15,17)],
+ '4' : [(19,17)],
+ '5' : [(22,17)],
+ '6' : [(27,17)],
+ '7' : [(33,16)],
+ '8' : [(34,16)],
+ '9' : [(38,17)],
+ '10' : [(42,17)] },
+ }
def mappingFunction(self, eventLocation, screen):
if type(eventLocation) == type(tuple()):
@@ -35,20 +93,28 @@ class C5SignMapper(PixelMapper):
return [(bestPixel,1)]
else:
return []
- elif type(eventLocation) == type
else:
- eventLocSplit = eventLocation.split(' :: ')
+ #pixel locs
+ eventLocSplit = eventLocation.split('@')
if len(eventLocSplit) == 2:
- [signPart, eventLocation] = eventLocSplit
- signParts = [signPosition[x] for x in signPart.split(' ')]
+ [eventLocation, signPart] = eventLocSplit
+ signParts = signPart.split('.')
+ pixelLocs = signPosition[signParts[0]][signParts[1]]
+ screenPixels = [p for p in screen if (p.location in pixelLocs)]
+ else:
+ screenPixels = [p for p in screen]
+
#{x}>5,{y}<k
ret = []
eventLocation = eventLocation.replace('{x}', 'pixel.location[0]')
eventLocation = eventLocation.replace('{y}', 'pixel.location[1]')
- conditions = eventLocation.split(',')
- conditionLambdas = [eval('lambda pixel:'+condition) for condition in conditions]
- for pixel in screen:
+ if len(eventLocation) > 0:
+ conditions = eventLocation.split(',')
+ conditionLambdas = [eval('lambda pixel:'+condition) for condition in conditions]
+ else:
+ conditionLambdas = []
+ for pixel in screenPixels:
try:
pixelValid = True
for p in conditionLambdas:
@@ -58,6 +124,7 @@ class C5SignMapper(PixelMapper):
if pixelValid:
ret.append((pixel, 1))
except Exception as exp:
+ import pdb; pdb.set_trace()
raise Exception('Bad event condition')
return ret