ODE colission + ARtoolkit + interval

I’m receiving data externally from ARtoolkit and within Panda I receive the data as Hpr and Pos. (I’m using AR Professional and can’t use the internal Panda version). While my AR object is moving around the scene I’m using Intervals to smooth out the movement.

I’d like to be able to use collision detection through ODE to determine when my AR object collides with a static object in my scene.

My first problem is that I’m not getting any ODE collision events happening with the code below. I moved the step tasks out of task manager and put that in my socket handler as it gets called approximately every frame. (As a side note, I wasn’t getting any collisions when the step tasks were in task manager either.)

The second issue I’m foreseeing is that when the collision happens my AR data & Interval will be competing with the collision code to move my AR object. As I need to continue to receive AR Hpr and Pos to direct my AR object, how do I mesh the two so that the AR object isn’t jumping all over the place?

base.cam.setPos(0,-40,0)
world = OdeWorld()
world.setGravity(0,0,0)  #no gravity, ok?
world.initSurfaceTable(1)
world.setSurfaceEntry(0, 0, 7, 0.2, 9.1, 0.9, 0.00001, 0.0, 0.002)
space = OdeSimpleSpace()
space.setAutoCollideWorld(world)
contactgroup = OdeJointGroup()
space.setAutoCollideJointGroup(contactgroup)

#-------------- static object ------------
staticObject = loader.loadModel("models/static_object.egg") 
staticObject.reparentTo(render)  
staticObject.setPos(0,0,0)     

staticBody = OdeBody(world)
staticBody.setPosition(staticObject.getPos(render))
staticBody.setQuaternion(staticObject.getQuat(render))
staticMass = OdeMass()
staticMass.setSphere(500,0.5)
staticBody.setMass(staticMass)

staticGeom = OdeSphereGeom(space, 1.2)
staticGeom.setCollideBits(BitMask32(0x00000002))
staticGeom.setCategoryBits(BitMask32(0x00000001))
staticGeom.setBody(staticBody)

#-------------- AR object ------------
ARobject = loader.loadModel("models/AR_object.egg")
ARobject.reparentTo(render)
ARobject.setPos(0,-25,0)

ARBody = OdeBody(world)
ARBody.setPosition(ARobject.getPos(render))
ARBody.setQuaternion(ARobject.getQuat(render))
ARMass = OdeMass()
ARMass.setBox(500, 1, 1, 1)
ARBody.setMass(ARMass)

ARGeom = OdeBoxGeom(1,1,1)
ARGeom.setCollideBits(BitMask32(0x00000002))
ARGeom.setCategoryBits(BitMask32(0x00000001))
ARGeom.setBody(ARBody)


#---------- socket handler to move AR object -----
#called approx every frame
def oscHandler(addr, tags, data, source):
  if addr == "/ARdata":      
    ARHpr = Vec3(data[0], data[1], data[2])        
    ival1 = ARobject.hprInterval(.2, ARHpr)   
    ARPos = Vec3((data[3]), (data[4]), data[5]) 
    ival2 = ARobject.posInterval(.2, ARPos)    
    if base.seq.isPlaying(): 
      base.seq.pause()
    base.seq = Parallel(ival1, ival2)        
    base.seq.start()
    
        
    ARBody.setPosition(ARobject.getPos(render))
    ARBody.setQuaternion(ARobject.getQuat(render))
    
    space.autoCollide()
    world.quickStep(globalClock.getDt())
    ARobject.setPosQuat(render, ARBody.getPosition(), Quat(ARBody.getQuaternion()))
    
    print "contacts number: %d" %space.autoCollide()
    contactgroup.empty() 

#-------------- collision event ------------
def onCollision(entry):
  print "collision"
  print entry
 
space.setCollisionEvent("ode-collision")
base.accept("ode-collision", onCollision)

#setup the socket handler to get data stream
initOSCServer('127.0.0.1', 7000)
setOSCHandler("/ARdata", oscHandler)

base.run()