VRPN?

ok, so, I’m ready to start setting up the geowall and the flock of birds.

Is vrpn support included in the regular installers (the ubuntu one, particularly…) or do you have to build from source to use it?

is there any documentation? I couldn’t find VrpnClient in the manual or the reference.

I figured that I guess you do have to build panda and include vrpn explicitly if you want to use it. So, I built VRPN, then copied the libs and headers over into panda’s thirdparty/ directory. makepanda liked that, and tried to use it, but I’ve run into this odd problem about semaphores:

g++ -ftemplate-depth-30 -fPIC -c -o built/tmp/vrpn_composite.o -I"/usr/include/python2.6" -I"thirdparty/linux-libs-x64/vrpn/include" -I"built/tmp" -I"built/include" -Ipanda/src/vrpn -O2 -DBUILDING_PANDA panda/src/vrpn/vrpn_composite.cxx
In file included from thirdparty/linux-libs-x64/vrpn/include/vrpn_Connection.h:7,
                 from panda/src/vrpn/vrpn_interface.h:31,
                 from panda/src/vrpn/vrpnClient.h:21,
                 from panda/src/vrpn/config_vrpn.cxx:18,
                 from panda/src/vrpn/vrpn_composite1.cxx:2,
                 from panda/src/vrpn/vrpn_composite.cxx:1:
thirdparty/linux-libs-x64/vrpn/include/vrpn_Shared.h:269: error: ISO C++ forbids declaration of ‘sem_t’ with no type
thirdparty/linux-libs-x64/vrpn/include/vrpn_Shared.h:269: error: expected ‘;’ before ‘*’ token

I wonder if what’s happening is that panda/src/pipeline/semaphore.h is getting included instead of the /usr/include/semaphore.h, so it’s not getting sem_t ?

Exactly right. On the CVS trunk, we have renamed this file to psemaphore.h to avoid this problem.

David

I think I’ve got everything built and working how it should be, but I’m just getting zeros in Panda for the tracker position. Not sure if I’m using the TrackerNode and Client correctly.

I’m just using a joystick first, before moving on to actual trackers. Here’s the contents of my joystick.cfg:

vrpn_Tracker_AnalogFly	JoystickTracker	60.0	absolute
X	*Joystick0	0	0.0	0.0	1.0	-1.0
Y	*Joystick0	1	0.0	0.0	-1.0	1.0
Z	*Joystick0	6	0.0	0.0	1.0	1.0
RX	NULL		3	0.0	0.0	1.0	1.0
RY	NULL		4	0.0	0.0	1.0	1.0
RZ	*Joystick0	5	0.0	0.0	0.5	1.0
RESET	NULL	0
CLUTCH	NULL 0

vrpn_Joylin	Joystick0 /dev/input/js1

I launch the server:

./vrpn_server -f joystick.cfg

vrpn_print_devices gives correct data:

./vrpn_print_devices JoystickTracker@localhost

But, my panda code only gives me 0’s

import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.task import Task
from direct.showbase import DirectObject
import random


class World(DirectObject.DirectObject):
  def __init__(self):
    light1 = PointLight ('light1')
    self.lightNode1 = render.attachNewNode (light1)
    self.lightNode1.setPos(0,-20,50)
    render.setLight(self.lightNode1)

    self.environment = loader.loadModel ("environment")
    self.environment.reparentTo (render)
    self.vrpnclient = VrpnClient ('localhost')
    self.tracker0 = TrackerNode(self.vrpnclient,"JoystickTracker")
    print self.tracker0.isValid()
    taskMgr.add (self.update,"update")
    
  def update (self,t):
      self.vrpnclient.poll()
      print self.tracker0.getPos()
      return Task.cont

w=World()
run()

I tried “JoystickTracker” and “JoystickTracker@localhost” for the device name for TrackerNode(), neither made any difference.

Anything else you need to do for this? I had some trouble finding a complete vrpn example, so I’m just kind of piecing this together …

The TrackerNode does not itself transform to match the tracker, so checking self.tracker0.getPos() will always return 0, regardless of the data coming in.

Instead, a TrackerNode is meant to be attached into the datagraph, similar to the way base.trackball is used. The datagraph is a special graph of nodes that control user-input devices, such as the keyboard and mouse (and any VRPN devices you connect); you can think of the data in the datagraph as flowing from parent to child, along the graph lines. In general, you hook up devices in the datagraph by parenting them.

Use a Transform2SG node as the child of TrackerNode in order to convert its transform data into a scene-graph transform.

Try:

self.myTrackedNode = render.attachNewNode('myTrackedNode')
self.tracker0.reparentTo(base.dgraph)
t2n = self.tracker0.attachNewNode(Transform2SG('t2n'))
t2n.node().setNode(self.myTrackedNode.node())

print self.myTrackedNode.getPos()

David

Thanks … I had to tweak that just a bit but here’s the working code:

import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.task import Task
from direct.showbase import *
import random

class World(DirectObject.DirectObject):
  def __init__(self):
    light1 = PointLight ('light1')
    self.lightNode1 = render.attachNewNode (light1)
    self.lightNode1.setPos(0,-20,50)
    render.setLight(self.lightNode1)

    self.environment = loader.loadModel ("environment")
    self.environment.reparentTo (render)
    self.vrpnclient = VrpnClient ('localhost')
    self.tracker0 = TrackerNode(self.vrpnclient,"JoystickTracker")
    taskMgr.add (self.update,"update")
    self.myTrackedNode = render.attachNewNode('myTrackedNode')
    
    base.dataRoot.node().addChild(self.tracker0)
    
    t2n = Transform2SG('t2n')
    self.tracker0.addChild(t2n)
    print t2n
    t2n.setNode(self.myTrackedNode.node())
    
    
  def update (self,t):
      self.vrpnclient.poll()
      print self.myTrackedNode.getPos()
      return Task.cont

w=World()
run()

Although the numbers seem very strange. I would have thought the joystick tracker would give ranges from -1 to 1 on the different axes; it does do this at the extremes, but in between has this odd non-linear up to around +/- 50. But that’s a VRPN issue, not a panda one.

(EDIT): solved, that’s because I wasn’t using the config file correctly at all. I had

X	*Joystick0	0	0.0	0.0	1.0	-1.0

which I thought meant the range would be 1 to -1. Nope, turns out that last -1 is an exponent, hence my weird numbers :slight_smile:

Any chance to provide also c++ example for this? I am really lost here.