OSC data delayed on Mac (10.6)

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?'

Do you mean the data comes in with lag or it doesn’t come in at all while the panda app is running?

I’ve also had weird trouble with lag doing osc->panda on Linux, I wonder if it’s something deep down related to unix vs windows sockets or something since that would be similar on osx.

Try liblo instead of simpleOSC, that gave better results for me…

The data does come in, but very slowly. It is delayed to around 1-2 seconds. It is supposed to stream in very fast.

Thanks, I’ll give liblo a try on osx.

@benchang,

I’m having trouble getting liblo working with Panda. I install liblo and then pyliblo. The example runs fine with the system’s version of Python, but running it with the version Panda needs (2.5) - ppython server.py, I get this error:

File “server.py”, line 3, in
import liblo, sys
ImportError: dlopen(/Library/Python/2.5/site-packages/liblo.so, 2): Symbol not found: _lo_address_errstr
Referenced from: /Library/Python/2.5/site-packages/liblo.so
Expected in: flat namespace
in /Library/Python/2.5/site-packages/liblo.so

liblo does exist in site-packages