aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar dan <dmtaub@gmail.com>2011-01-28 16:11:11 -0500
committerGravatar dan <dmtaub@gmail.com>2011-01-28 16:11:11 -0500
commitf017051f9b93c3a8ac435537c8c9c1f360d0702f (patch)
tree3f0a9e01ddcb87af2e1b016dd8489be572641ca0
parentfac2f8373cd0e63a34a39cb77c0c7276d1d88b65 (diff)
parenta7d6577e55ebd665ad9e4f45183836f11b3c6fd4 (diff)
Merge branch 'fridaydemo' of github.com:rcoh/SmootLight into osc
-rw-r--r--behaviors/Deccelerate.xml9
-rw-r--r--behaviors/ExpandingColorZones.py20
-rwxr-xr-xbehaviors/SmootWind.py33
-rw-r--r--config/Demo.xml227
-rwxr-xr-xconfig/HTMLTest.xml58
-rw-r--r--config/Jennifer.xml128
-rw-r--r--config/Kuan.xml99
-rwxr-xr-xconfig/SmootWindTest.xml173
-rwxr-xr-xinputs/HTMLInput.py29
-rw-r--r--inputs/RandomLocs.py32
-rwxr-xr-xpixelmappers/WindGaussianMapper.py18
-rw-r--r--util/Geo.py6
12 files changed, 816 insertions, 16 deletions
diff --git a/behaviors/Deccelerate.xml b/behaviors/Deccelerate.xml
new file mode 100644
index 0000000..e64e61d
--- /dev/null
+++ b/behaviors/Deccelerate.xml
@@ -0,0 +1,9 @@
+
+<Behavior>
+ <Class>behaviors.ModifyParam</Class>
+ <Args>
+ <ParamType>Sensor</ParamType>
+ <ParamName>StepSize</ParamName>
+ <ParamOp>{val}*.98</ParamOp>
+ </Args>
+</Behavior>
diff --git a/behaviors/ExpandingColorZones.py b/behaviors/ExpandingColorZones.py
new file mode 100644
index 0000000..345851e
--- /dev/null
+++ b/behaviors/ExpandingColorZones.py
@@ -0,0 +1,20 @@
+from operationscore.Behavior import *
+from logger import main_log
+class ExpandingColorZones(Behavior):
+ def behaviorInit(self):
+ self.mapping = {'r':[(132,0),(255,0,0)], 'g':[(400,0), (0,255,0)],
+ 'b':[(668,0),
+ (0,0,255)]}
+ self.mappingkey = 'KeyChar'
+ def processResponse(self, sensorInputs, recursiveInputs):
+ ret = []
+ for data in sensorInputs:
+ data = dict(data)
+ if self.mappingkey in data:
+ try:
+ data['Location'], data['Color'] =\
+ self.mapping[data[self.mappingkey]]
+ ret.append(data)
+ except:
+ main_log.warn('Bad mapping key. Expanding Color Zones.')
+ return (ret,[])
diff --git a/behaviors/SmootWind.py b/behaviors/SmootWind.py
new file mode 100755
index 0000000..347e2fc
--- /dev/null
+++ b/behaviors/SmootWind.py
@@ -0,0 +1,33 @@
+from operationscore.Behavior import *
+import util.ComponentRegistry as compReg
+import random
+
+class SmootWind(Behavior):
+ def behaviorInit(self):
+ self.mapper = None
+ self.xFor = None
+
+ def processResponse(self, sensorInputs, recursiveInputs):
+ if self.mapper == None:
+ try:
+ self.mapper = compReg.getComponent('windgaussmap')
+ except KeyError:
+ pass
+ if self.xFor == None:
+ try:
+ self.xFor = compReg.getComponent('xfor')
+ except KeyError:
+ pass
+
+ for sensory in sensorInputs:
+ print sensory
+ # input[0] is windspeed, [1] is dir
+ windSpeed = sensory[0]
+ windDir = sensory[1]
+
+ #print self.mapper.argDict
+ self.mapper.argDict['Width'] = float(windSpeed)*2+20
+ self.xFor.argDict['ParamOp'] = float(windSpeed)*3+10*random.random();
+ #print 'Width: ' + str(self.mapper.argDict['Width'])
+ #print 'xFor: ' + str(self.xFor.argDict['ParamOp'])
+ return (sensorInputs, recursiveInputs)
diff --git a/config/Demo.xml b/config/Demo.xml
new file mode 100644
index 0000000..525e468
--- /dev/null
+++ b/config/Demo.xml
@@ -0,0 +1,227 @@
+<!---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/60StripLayout.xml</InheritsFrom>
+ </PixelConfiguration>
+ <PixelMapperConfiguration>
+ <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>10</Width>
+ <Height>1</Height>
+ </Args>
+ </PixelMapper>
+ </PixelMapperConfiguration>
+ <RendererConfiguration>
+ <Renderer>
+ <InheritsFrom>renderers/60StripSeq.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.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.TCPInput</Class>
+ <Args>
+ <Id>tcp</Id>
+ <Port>20120</Port>
+ <RefreshInterval>10</RefreshInterval>
+ </Args>
+ </InputElement>-->
+ <InputElement Id="followmouse">
+ <InheritsFrom>inputs/MouseFollower.xml</InheritsFrom>
+ </InputElement>
+ </InputConfiguration>
+ <BehaviorConfiguration>
+ <Behavior Id="colorchange">
+ <InheritsFrom>behaviors/RandomColor.xml</InheritsFrom>
+ <Args>
+ <ColorList>
+ <Val>(255,0,0)</Val>
+ <Val>(0,0,255)</Val>
+ </ColorList>
+ </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>.01</Coefficient>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.XYMove</Class>
+ <Args>
+ <Id>xymove</Id>
+ <XStep>5</XStep>
+ <YStep>2</YStep>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.RestrictLocation</Class>
+ <Args>
+ <Id>xbounce</Id>
+ <Action>{val}*-1</Action>
+ <ParamName>XStep</ParamName>
+ <LocationRestriction>{x}&lt;0 or {x}&gt;800</LocationRestriction>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.RestrictLocation</Class>
+ <Args>
+ <Id>ybounce</Id>
+ <Action>{val}*-1</Action>
+ <ParamName>YStep</ParamName>
+ <LocationRestriction>{y}&lt;0 or {y}&gt;200</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.Square</Class>
+ <Args>
+ <Id>square</Id>
+ <Width>20</Width>
+ </Args>
+ </Behavior>
+ <Behavior Id="recursivedecay">
+ <InheritsFrom>behaviors/LoopAndDie.xml</InheritsFrom>
+ <Args>
+ <InitialResponseCount>80</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>decay</Id>
+ </ChainedBehaviors>
+ <RecursiveHooks>{'mover':'movebounce'}</RecursiveHooks>
+ <RenderToScreen>True</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.BehaviorChain</Class>
+ <Args>
+ <Id>mousechaser</Id>
+ <Inputs>
+ <Id>followmouse</Id>
+ </Inputs>
+ <ChainedBehaviors>
+ <Id>echo</Id>
+ <Id>square</Id>
+ <Id>singleframe</Id>
+ </ChainedBehaviors>
+ <RenderToScreen>True</RenderToScreen>
+ </Args>
+ </Behavior>
+ <Behavior Id="running">
+ <InheritsFrom>behaviors/RunningBehavior.xml</InheritsFrom>
+ </Behavior>
+ </BehaviorConfiguration>
+</LightInstallation>
diff --git a/config/HTMLTest.xml b/config/HTMLTest.xml
new file mode 100755
index 0000000..159cec4
--- /dev/null
+++ b/config/HTMLTest.xml
@@ -0,0 +1,58 @@
+<LightInstallation>
+ <InstallationConfiguration>
+ <Defaults>
+ <PixelMapper>simplemap</PixelMapper>
+ </Defaults>
+ </InstallationConfiguration>
+ <PixelConfiguration>
+ <InheritsFrom>layouts/BasicSixStrip.xml</InheritsFrom>
+ </PixelConfiguration>
+ <PixelMapperConfiguration>
+ <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>10</Width>
+ <Height>1</Height>
+ </Args>
+ </PixelMapper>
+ </PixelMapperConfiguration>
+ <RendererConfiguration>
+ <Renderer>
+ <InheritsFrom>renderers/Pygame.xml</InheritsFrom>
+ </Renderer>
+ </RendererConfiguration>
+ <InputConfiguration>
+ <InputElement>
+ <Class>inputs.HTMLInput</Class>
+ <Args>
+ <Id>weatherinput</Id>
+ <Src>'http://sailing.mit.edu/weather/'</Src>
+ <!--<Regex>'rtWindSpeed = (\d+).*rtWindDir = (\d+)'</Regex>-->
+ <Regex>'rtWindSpeed = (\d+).*\s.*\s.*rtWindDir = (\d+)'</Regex>
+ <!--<RefreshInterval>60000</RefreshInterval>-->
+ </Args>
+ </InputElement>
+ </InputConfiguration>
+ <BehaviorConfiguration>
+ <Behavior>
+ <Class>behaviors.EchoBehavior</Class>
+ <Args>
+ <Inputs>
+ <Id>weatherinput</Id>
+ </Inputs>
+ <Id>echo</Id>
+ <RenderToScreen>False</RenderToScreen>
+ </Args>
+ </Behavior>
+ </BehaviorConfiguration>
+</LightInstallation>
diff --git a/config/Jennifer.xml b/config/Jennifer.xml
new file mode 100644
index 0000000..e6cfc40
--- /dev/null
+++ b/config/Jennifer.xml
@@ -0,0 +1,128 @@
+<!---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/60StripLayout.xml</InheritsFrom>
+ </PixelConfiguration>
+ <PixelMapperConfiguration>
+ <PixelMapper>
+ <Class>pixelmappers.SimpleMapper</Class>
+ <Args>
+ <Id>simplemap</Id>
+ <CutoffDist>20</CutoffDist>
+ </Args>
+ </PixelMapper>
+ </PixelMapperConfiguration>
+ <RendererConfiguration>
+ <Renderer>
+ <InheritsFrom>renderers/60StripSeq.xml</InheritsFrom>
+ </Renderer>
+ <Renderer>
+ <InheritsFrom>renderers/Pygame.xml</InheritsFrom>
+ </Renderer>
+ </RendererConfiguration>
+ <InputConfiguration>
+ <InputElement>
+ <Class>inputs.PygameInput</Class>
+ <Args><!--Passed as a dictionary-->
+ <Id>pygameclick</Id>
+ <RefreshInterval>10</RefreshInterval>
+ <Clicks>True</Clicks>
+ </Args>
+ </InputElement>
+ <InputElement>
+ <Class>inputs.PygameInput</Class>
+ <Args><!--Passed as a dictionary-->
+ <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>
+ </InputConfiguration>
+ <BehaviorConfiguration>
+ <Behavior Id="dim">
+ <InheritsFrom>behaviors/DimColor.xml</InheritsFrom>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.Expand</Class>
+ <Args>
+ <Id>expand</Id>
+ <ExpandRate>8</ExpandRate>
+ </Args>
+ </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 Id="decay">
+ <InheritsFrom>behaviors/PixelDecay.xml</InheritsFrom>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>expanddie</Id>
+ <ChainedBehaviors>
+ <Id>expand</Id>
+ <Id>decexpand</Id>
+ <Id>dim</Id>
+ <Id>8sectimeout</Id>
+ </ChainedBehaviors>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.ExpandingColorZones</Class>
+ <Args>
+ <Id>colorzones</Id>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>colorbars</Id>
+ <Inputs>
+ <Id>pygamekey</Id>
+ </Inputs>
+ <ChainedBehaviors>
+ <Id>colorzones</Id>
+ <Id>mover</Id>
+ <Id>decay</Id>
+ </ChainedBehaviors>
+ <RecursiveHooks>{'mover':'expanddie'}</RecursiveHooks>
+ <RenderToScreen>True</RenderToScreen>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.Timeout</Class>
+ <Args>
+ <Id>8sectimeout</Id>
+ <Timeout>8000</Timeout>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.ResponseMover</Class>
+ <Args>
+ <Id>mover</Id>
+ </Args>
+ </Behavior>
+ <Behavior Id="decexpand" ParamName="ExpandRate">
+ <InheritsFrom>behaviors/Deccelerate.xml</InheritsFrom>
+ </Behavior>
+ </BehaviorConfiguration>
+</LightInstallation>
diff --git a/config/Kuan.xml b/config/Kuan.xml
new file mode 100644
index 0000000..c85cb75
--- /dev/null
+++ b/config/Kuan.xml
@@ -0,0 +1,99 @@
+<LightInstallation>
+ <InstallationConfiguration>
+ <Defaults>
+ <PixelMapper>simplemap</PixelMapper>
+ </Defaults>
+ </InstallationConfiguration>
+ <PixelConfiguration>
+ <InheritsFrom>layouts/60StripLayout.xml</InheritsFrom>
+ </PixelConfiguration>
+ <PixelMapperConfiguration>
+ <PixelMapper>
+ <Class>pixelmappers.SimpleMapper</Class>
+ <Args>
+ <Id>simplemap</Id>
+ <CutoffDist>20</CutoffDist>
+ </Args>
+ </PixelMapper>
+ </PixelMapperConfiguration>
+ <RendererConfiguration>
+ <Renderer>
+ <InheritsFrom>renderers/60StripSeq.xml</InheritsFrom>
+ </Renderer>
+ <Renderer>
+ <InheritsFrom>renderers/Pygame.xml</InheritsFrom>
+ </Renderer>
+ </RendererConfiguration>
+ <InputConfiguration>
+ <InputElement>
+ <Class>inputs.PygameInput</Class>
+ <Args>
+ <Id>pygamekey</Id>
+ <RefreshInterval>10</RefreshInterval>
+ <Keyboard>True</Keyboard>
+ </Args>
+ </InputElement>
+ </InputConfiguration>
+ <BehaviorConfiguration>
+ <Behavior Id="risefall" MaxHeight="200">
+ <InheritsFrom>behaviors/RiseFall.xml</InheritsFrom>
+ </Behavior>
+ <Behavior Id="dim">
+ <InheritsFrom>behaviors/DimColor.xml</InheritsFrom>
+ </Behavior>
+ <Behavior Id="colorchange">
+ <InheritsFrom>behaviors/RandomColor.xml</InheritsFrom>
+ </Behavior>
+ <Behavior Id="decay">
+ <InheritsFrom>behaviors/PixelDecay.xml</InheritsFrom>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>risefalldie</Id>
+ <ChainedBehaviors>
+ <Id>risefall</Id>
+ <Id>2sec</Id>
+ <Id>dim</Id>
+ </ChainedBehaviors>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>doors</Id>
+ <Inputs>
+ <Id>pygamekey</Id>
+ </Inputs>
+ <ChainedBehaviors>
+ <Id>mitdoors</Id>
+ <Id>colorchange</Id>
+ <Id>mover</Id>
+ <Id>decay</Id>
+ </ChainedBehaviors>
+ <RecursiveHooks>{'mover':'risefalldie'}</RecursiveHooks>
+ <RenderToScreen>True</RenderToScreen>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.Timeout</Class>
+ <Args>
+ <Id>2sec</Id>
+ <Timeout>2000</Timeout>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.MITDoors</Class>
+ <Args>
+ <Id>mitdoors</Id>
+ <Bottom>200</Bottom>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.ResponseMover</Class>
+ <Args>
+ <Id>mover</Id>
+ </Args>
+ </Behavior>
+ </BehaviorConfiguration>
+</LightInstallation>
diff --git a/config/SmootWindTest.xml b/config/SmootWindTest.xml
new file mode 100755
index 0000000..6b74450
--- /dev/null
+++ b/config/SmootWindTest.xml
@@ -0,0 +1,173 @@
+<!---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/60StripLayout.xml</InheritsFrom>
+ </PixelConfiguration>
+ <PixelMapperConfiguration>
+ <PixelMapper>
+ <Class>pixelmappers.SimpleMapper</Class>
+ <Args>
+ <Id>simplemap</Id>
+ <CutoffDist>20</CutoffDist>
+ </Args>
+ </PixelMapper>
+ <PixelMapper>
+ <Class>pixelmappers.GaussianMapper</Class>
+ <Args>
+ <Id>gaussmap</Id>
+ <CutoffDist>10</CutoffDist>
+ <MinWeight>0.1</MinWeight>
+ <Width>10</Width>
+ <Height>5</Height>
+ </Args>
+ </PixelMapper>
+ <PixelMapper>
+ <Class>pixelmappers.WindGaussianMapper</Class>
+ <Args>
+ <Id>windgaussmap</Id>
+ <CutoffDist>150</CutoffDist>
+ <MinWeight>0.005</MinWeight>
+ <Width>30</Width>
+ <Height>10</Height>
+ </Args>
+ </PixelMapper>
+ </PixelMapperConfiguration>
+ <RendererConfiguration>
+ <Renderer>
+ <InheritsFrom>renderers/60StripSeq.xml</InheritsFrom>
+ </Renderer>
+ <Renderer>
+ <InheritsFrom>renderers/Pygame.xml</InheritsFrom>
+ </Renderer>
+ </RendererConfiguration>
+ <InputConfiguration>
+ <InputElement>
+ <Class>inputs.PygameInput</Class>
+ <Args><!--Passed as a dictionary-->
+ <Id>pygame</Id>
+ <RefreshInterval>1</RefreshInterval>
+ </Args>
+ </InputElement>
+ <InputElement>
+ <Class>inputs.HTMLInput</Class>
+ <Args>
+ <Id>weatherinput</Id>
+ <Src>'http://sailing.mit.edu/weather/'</Src>
+ <!--<Regex>'rtWindSpeed = (\d+).*rtWindDir = (\d+)'</Regex>-->
+ <Regex>'rtWindSpeed = (\d+).*\s.*\s.*rtWindDir = (\d+)'</Regex>
+ <!--<RefreshInterval>60000</RefreshInterval>-->
+ </Args>
+ </InputElement>
+ <InputElement>
+ <Class>inputs.RandomLocs</Class>
+ <Args>
+ <Id>randomLoc</Id>
+ </Args>
+ </InputElement>
+ </InputConfiguration>
+ <BehaviorConfiguration>
+ <Behavior Id="colorchange">
+ <InheritsFrom>behaviors/RandomColor.xml</InheritsFrom>
+ </Behavior>
+ <Behavior Id="staticcolor">
+ <InheritsFrom>behaviors/RandomColor.xml</InheritsFrom>
+ <Args>
+ <ColorList>
+ <Val>(100,200,255)</Val>
+ <Val>(50,200,255)</Val>
+ <Val>(0,200,255)</Val>
+ <Val>(0,150,255)</Val>
+ </ColorList>
+ </Args>
+ </Behavior>
+ <Behavior Id="decay">
+ <InheritsFrom>behaviors/PixelDecay.xml</InheritsFrom>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.XYMove</Class>
+ <Args>
+ <Id>xymove</Id>
+ <XStep>0</XStep>
+ <YStep>0</YStep>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>movebounce</Id>
+ <ChainedBehaviors>
+ <Id>xymove</Id>
+ <Id>yfor</Id>
+ <Id>xfor</Id>
+ <Id>20sectimeout</Id>
+ </ChainedBehaviors>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.Timeout</Class>
+ <Args>
+ <Id>20sectimeout</Id>
+ <Timeout>20000</Timeout>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.ModifyParam</Class>
+ <Args>
+ <Id>yfor</Id>
+ <ParamName>YStep</ParamName>
+ <ParamType>Sensor</ParamType>
+ <ParamOp>2*(2*math.sin({x}/float(100))+math.sin({x}/float(50)))</ParamOp>
+ </Args>
+ </Behavior>
+
+ <Behavior>
+ <Class>behaviors.ModifyParam</Class>
+ <Args>
+ <Id>xfor</Id>
+ <ParamName>XStep</ParamName>
+ <ParamType>Sensor</ParamType>
+ <!--<ParamOp>75</ParamOp>-->
+ <ParamOp>25</ParamOp>
+ </Args>
+ </Behavior>
+
+ <Behavior>
+ <Class>behaviors.SmootWind</Class>
+ <Args>
+ <Id>smootwind</Id>
+ <Inputs>
+ <Id>weatherinput</Id>
+ </Inputs>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.ResponseMover</Class>
+ <Args>
+ <Id>mover</Id>
+ </Args>
+ </Behavior>
+ <Behavior>
+ <Class>behaviors.BehaviorChain</Class>
+ <Args>
+ <Id>xymover</Id>
+ <Inputs>
+ <Id>pygame</Id>
+ <Id>randomLoc</Id>
+ </Inputs>
+ <ChainedBehaviors>
+ <Id>staticcolor</Id>
+ <Id>mover</Id>
+ <Id>decay</Id>
+ </ChainedBehaviors>
+ <RecursiveHooks>{'mover':'movebounce'}</RecursiveHooks>
+ <RenderToScreen>True</RenderToScreen>
+ <Mapper>windgaussmap</Mapper>
+ </Args>
+ </Behavior>
+ </BehaviorConfiguration>
+</LightInstallation>
diff --git a/inputs/HTMLInput.py b/inputs/HTMLInput.py
new file mode 100755
index 0000000..9697a32
--- /dev/null
+++ b/inputs/HTMLInput.py
@@ -0,0 +1,29 @@
+from operationscore.Input import *
+import urllib, re
+
+"""
+HTML Input, which takes 2 arguments:
+- 'Src': a URL to a web page, and
+- 'Regex': a Regex to parse data out of the web page.
+The input parses the source code of the web page according to the regex, and processes the parsed regex groups.
+"""
+class HTMLInput(Input):
+ def inputInit(self):
+ self.src = self.argDict['Src']
+ self.regex = self.argDict['Regex']
+
+ def getHTML(self):
+ self.sock = urllib.urlopen(self.src);
+ self.html = self.sock.read()
+ self.sock.close()
+
+ def sensingLoop(self):
+ self.getHTML()
+ self.dataList = []
+
+ pattern = re.compile(self.regex)
+ matchObj = pattern.search(self.html)
+ self.dataList = matchObj.groups()
+
+ self.respond(self.dataList)
+
diff --git a/inputs/RandomLocs.py b/inputs/RandomLocs.py
index 2719981..f4182cf 100644
--- a/inputs/RandomLocs.py
+++ b/inputs/RandomLocs.py
@@ -1,16 +1,16 @@
-import util.TimeOps as clock
-import random
-import util.Geo as Geo
-import util.Strings as Strings
-from operationscore.Input import *
-class RandomLocs(Input):
- """RandomLocs is an Input that generates RandomLocations at a preset time interval. Just a
- prototype, some assembly required."""
-
- def inputInit(self):
- self['LastEvent'] = clock.time()
- def sensingLoop(self): #TODO: move to params
- currentTime = clock.time()
- if currentTime - self['LastEvent'] > 2000:
- self.respond({Strings.LOCATION: Geo.randomLoc((50,50))})
- self['LastEvent'] = currentTime
+import util.TimeOps as clock
+import random
+import util.Geo as Geo
+import util.Strings as Strings
+from operationscore.Input import *
+class RandomLocs(Input):
+ """RandomLocs is an Input that generates RandomLocations at a preset but randomly changing time interval. Just a
+ prototype, some assembly required."""
+
+ def inputInit(self):
+ self['LastEvent'] = clock.time()
+ def sensingLoop(self): #TODO: move to params
+ currentTime = clock.time()
+ if currentTime - self['LastEvent'] > 200+500*random.random():
+ self.respond({Strings.LOCATION: Geo.randomLoc((200,200))})
+ self['LastEvent'] = currentTime
diff --git a/pixelmappers/WindGaussianMapper.py b/pixelmappers/WindGaussianMapper.py
new file mode 100755
index 0000000..c5d77ca
--- /dev/null
+++ b/pixelmappers/WindGaussianMapper.py
@@ -0,0 +1,18 @@
+from operationscore.PixelMapper import *
+import util.Geo as Geo
+import math
+class WindGaussianMapper(PixelMapper):
+ def mappingFunction(self, eventLocation, screen):
+ returnPixels = [] #TODO: consider preallocation and trimming
+ [x,y] = eventLocation
+ potentialPixels = screen.pixelsInRange(x-self.CutoffDist, x)
+ for (xloc,pixel) in screen.pixelsInRange(x-self.CutoffDist, x):
+ pixelDistx = math.fabs(pixel.location[0] - x)
+ pixelDisty = math.fabs(pixel.location[1] - y)
+ if pixelDistx < self.CutoffDist:
+ if pixelDisty < 30:
+ w = Geo.windtrail(pixelDistx, pixelDisty, self.Height, 0, self.Width)
+ if w > self.MinWeight:
+ returnPixels.append((pixel, w))
+
+ return returnPixels
diff --git a/util/Geo.py b/util/Geo.py
index 05ea9fe..0dde80b 100644
--- a/util/Geo.py
+++ b/util/Geo.py
@@ -26,3 +26,9 @@ def randomLoc(boundingBox): #TODO: make less shitty
def approxexp(x):
"""Approximates exp with a 3 term Taylor Series."""
return 1+x+x**2/2+x**3/6
+
+def windtrail(x,y,height,center,width):
+ a=height
+ b=center
+ c=width
+ return a*((math.exp(-((x-b))/(c)))**2)*(math.exp(-((y))/(0.2*c)))**2