aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar dxiao <dxiao@mit.edu>2011-02-13 19:00:44 -0500
committerGravatar dxiao <dxiao@mit.edu>2011-02-13 19:00:44 -0500
commit7a4f06d15b0fe9bd22996af6a1ca2c3ca5ca3e3f (patch)
treeb15d0ba7ca22b3064e877ca6965f4a8ce84d7640
parent43bf9e8b188638ca2e11f5dff691cf54902ac8dc (diff)
Added a vertical bars animation to C5Sign-dxiao
-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.py8
5 files changed, 452 insertions, 3 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 02bd0a2..45e42de 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 79ebe1a..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)
@@ -99,7 +100,9 @@ class C5SignMapper(PixelMapper):
[eventLocation, signPart] = eventLocSplit
signParts = signPart.split('.')
pixelLocs = signPosition[signParts[0]][signParts[1]]
- screen = [p for p in screen if (p.location in pixelLocs)]
+ screenPixels = [p for p in screen if (p.location in pixelLocs)]
+ else:
+ screenPixels = [p for p in screen]
#{x}>5,{y}<k
@@ -111,7 +114,7 @@ class C5SignMapper(PixelMapper):
conditionLambdas = [eval('lambda pixel:'+condition) for condition in conditions]
else:
conditionLambdas = []
- for pixel in screen:
+ for pixel in screenPixels:
try:
pixelValid = True
for p in conditionLambdas:
@@ -121,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