diff options
-rw-r--r-- | behaviors/ControllerOSC.py | 62 | ||||
-rw-r--r-- | behaviors/TouchOSC.py | 3 | ||||
-rw-r--r-- | config/6thFloorOSC.xml | 2 | ||||
-rwxr-xr-x | testosc.py | 36 | ||||
-rwxr-xr-x | tests/testosc.py (renamed from oscserver.py) | 0 |
5 files changed, 3 insertions, 100 deletions
diff --git a/behaviors/ControllerOSC.py b/behaviors/ControllerOSC.py deleted file mode 100644 index 05d2e7d..0000000 --- a/behaviors/ControllerOSC.py +++ /dev/null @@ -1,62 +0,0 @@ -from operationscore.Behavior import * -from logger import main_log -#import util.ColorOps as color -import colorsys -from numpy import array -import pdb -import util.ComponentRegistry as compReg - -speedfactor = 15 -vel_decay = .9 - -def constrainLocation(v,c): - if v[0] > c[0]: - v[0] = c[0] - elif v[0]<0: - v[0] = 0 - - if v[1] > c[1]: - v[1] = c[1] - elif v[1]<0: - v[1] = 0 - - return v - -class ControllerOSC(Behavior): - def behaviorInit(self): - self.xy = array((0,0)) - self.v_xy = array((0,0)) - self.v_decay = vel_decay - - self.start_hsv = [0,1,1] - self.dest_hsv = [0,1,1] - self.ssize = compReg.getComponent('Screen').getSize()[-2:] #896 x 310 - - def processResponse(self, sensorInputs, recursiveInputs): - ret = [] - if sensorInputs: - data = sensorInputs[-1]#for data in sensorInputs: - if data['Path'] == '/sixaxis/xy': - #try: - x = data['Value'][0] - y = data['Value'][1] - if y < 0: - self.start_hsv[1] = 1.0+y #s - else: - self.start_hsv[2] = 1.0-y - self.start_hsv[0] = (x+1)/2. - elif data['Path'] == '/sixaxis/lrud': - val=data['Value'] - vy = val[3]-val[2] - vx = val[1]-val[0] - #pdb.set_trace() - #self.v_xy = (val[1]*ssize[0], (1.0-val[0])*ssize[1]) - self.v_xy = array((vx, vy)) * speedfactor - else: - main_log.error('Sensor Inputs: ' + str(sensorInputs)) - self.xy = self.xy + self.v_xy - constrainLocation(self.xy,self.ssize) - self.v_xy *= self.v_decay - ret.append({'Color':[i*255. for i in colorsys.hsv_to_rgb(*self.start_hsv)],'Location':(int(self.xy[0]), int(self.xy[1]))}) - - return (ret, []) diff --git a/behaviors/TouchOSC.py b/behaviors/TouchOSC.py index e7893e3..099d5e5 100644 --- a/behaviors/TouchOSC.py +++ b/behaviors/TouchOSC.py @@ -12,7 +12,8 @@ class TouchOSC(Behavior): self.xy = (-1,-1) def processResponse(self, sensorInputs, recursiveInputs): ret = [] - for data in sensorInputs: + if sensorInputs: + data = sensorInputs[-1]#for data in sensorInputs: if data['Path'] == '/1/fader1': try: self.h = data['Value'][0] diff --git a/config/6thFloorOSC.xml b/config/6thFloorOSC.xml index aa7a07d..cb1fd10 100644 --- a/config/6thFloorOSC.xml +++ b/config/6thFloorOSC.xml @@ -50,7 +50,7 @@ <Args> <Id>osc</Id> <Port>12345</Port> - <RefreshInterval>10</RefreshInterval> + <RefreshInterval>20</RefreshInterval> </Args> </InputElement> <InputElement> diff --git a/testosc.py b/testosc.py deleted file mode 100755 index cea03f4..0000000 --- a/testosc.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python - -import liblo, sys - -# create server, listening on port 1234 -try: - server = liblo.Server(12345) -except liblo.ServerError, err: - print str(err) - sys.exit() - -def foo_bar_callback(path, args): - i, f = args - print "received message '%s' with arguments '%d' and '%f'" % (path, i, f) - -def foo_baz_callback(path, args, types, src, data): - print "received message '%s'" % path - print "blob contains %d bytes, user data was '%s'" % (len(args[0]), data) - -def fallback(path, args, types, src): - print "got unknown message '%s' from '%s'" % (path, src.get_url()) - for a, t in zip(args, types): - print "argument of type '%s': %s" % (t, a) - -# register method taking an int and a float -server.add_method("/foo/bar", 'if', foo_bar_callback) - -# register method taking a blob, and passing user data to the callback -server.add_method("/foo/baz", 'b', foo_baz_callback, "blah") - -# register a fallback for unhandled messages -server.add_method(None, None, fallback) - -# loop and dispatch messages every 100ms -while True: - server.recv(100) diff --git a/oscserver.py b/tests/testosc.py index 6763f41..6763f41 100755 --- a/oscserver.py +++ b/tests/testosc.py |