I’m having trouble with OSC data being delayed on the Mac. It works on the PC just fine.
After running my app: ppython oscTest.py the data comes in delayed, but once I hit ctrl+c in the terminal window the data starts streaming in. Also, the data streams in if I don’t call run() at the end of my script.
So it seems that the Panda run loop is somehow blocking the OSC calls, but just on the Mac.
I’ve included an example from this thread that is about the same issue. They say they’ve solved it, but it doesn’t work for me.
import sys
from direct.showbase.ShowBase import ShowBase
from direct.task import Task
from direct.actor.Actor import Actor
import simpleOSC as osc
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
# enviroment
foo_camera = lambda x: self.camera.setPos(0, -20, 3) or Task.cont # ugly python use
self.taskMgr.add(foo_camera, "SpinCameraTask")
def release():
osc.closeOSC()
sys.exit()
self.accept('escape', release)
# osc
self.initOscServer()
self.oscPosition = 0,0,0
# actor
self.pandaActor = Actor("models/panda-model") #,
self.pandaActor.setScale(0.005, 0.005, 0.005)
self.pandaActor.reparentTo(self.render)
def initOscServer(self):
#functions to handle OSC messages
def handler1(addr, tags, data, source): # *msg):
self.oscPosition = data[0]/100.0, data[1]/100.0, 0
#initialize ocs, including port.
osc.initOSCServer("127.0.0.1", 12345)
osc.setOSCHandler("/mouse/position", handler1 )
self.osc = osc
taskMgr.add( self.doStuffsWithActor, 'doing' )
def doStuffsWithActor(self, task):
self.pandaActor.setPos(*self.oscPosition)
return Task.cont
app = MyApp()
app.run()
print 'am i here?'