WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   The problem of tracker using via VRPN (https://forum.worldviz.com/showthread.php?t=2206)

_kj_ 08-11-2009 10:40 PM

The problem of tracker using via VRPN
 
Greetings to everyone!

We develop a small application in WorldViz. The viewport rotation must be implemented through 3DOF trackers in this application. Using embedded WorldViz driver for InterSense tracker, app works well. InterSense is used as follows:

Code:

viz.go( viz.TRACKER )
tracker = viz.add( 'intersense.dls' )
vizact.onupdate( 0, UpdateView )

def UpdateView():
        yaw, pitch, roll = tracker.getEuler()
        viz.MainView.setEuler( GetOrderedAndInvertedViewAngles( yaw, pitch, roll ), viz.BODY_ORI )

# Return ordered and inverted view angles depends on current settings
def GetOrderedAndInvertedViewAngles( yaw, pitch, roll ):
        # order:
        if view_angles_order_1.get() == viz.DOWN:
                y = yaw
                p = pitch
                r = roll
        elif view_angles_order_2.get() == viz.DOWN:
                y = pitch
                p = yaw
                r = roll
        elif view_angles_order_3.get() == viz.DOWN:
                y = pitch
                p = roll
                r = yaw
        elif view_angles_order_4.get() == viz.DOWN:
                y = yaw
                p = roll
                r = pitch
        elif view_angles_order_5.get() == viz.DOWN:
                y = roll
                p = pitch
                r = yaw
        elif view_angles_order_6.get() == viz.DOWN:
                y = roll
                p = yaw
                r = pitch
        # invert:
        if view_angles_invert_yaw.get() == viz.DOWN:
                y = -y
        if view_angles_invert_pitch.get() == viz.DOWN:
                p = -p
        if view_angles_invert_roll.get() == viz.DOWN:
                r = -r
        return [y, p, r]

But if we use WorldViz VRPN driver, the viewport rotations will go incorrect. If in zero orientation up/down tracker rotations result in up/down viewport rotations respectively, while turning tracker 90 degrees to the left/right, up/down tracker rotations will no longer result in proper up/down viewport rotations, but in left/right viewport roll... It seems that tracker and viewport work in different coordinate systems. We tried all combinations of flags in viz.MainView.setEuler() method and there was no combination that worked properly. It seems that the flag viz.ABS_LOCAL does not generally work correctly, because it works exactly the same as the viz.REL_LOCAL flag, so it interprets rotation angles as relative but not absolute, as it must be according to the flag`s name and its description in WorldViz help. There is a code:

Code:

viz.go()

vrpn = viz.add( 'vrpn7.dle' )
tracker = vrpn.addTracker( 'Head@localhost' )

def UpdateView():
        yaw, pitch, roll = tracker.getEuler()
        viz.MainView.setEuler( GetOrderedAndInvertedViewAngles( yaw, pitch, roll ), viz.BODY_ORI )

# Return ordered and inverted view angles depends on current settings
def GetOrderedAndInvertedViewAngles( yaw, pitch, roll ):
        # order:
        if view_angles_order_1.get() == viz.DOWN:
                y = yaw
                p = pitch
                r = roll
        elif view_angles_order_2.get() == viz.DOWN:
                y = pitch
                p = yaw
                r = roll
        elif view_angles_order_3.get() == viz.DOWN:
                y = pitch
                p = roll
                r = yaw
        elif view_angles_order_4.get() == viz.DOWN:
                y = yaw
                p = roll
                r = pitch
        elif view_angles_order_5.get() == viz.DOWN:
                y = roll
                p = pitch
                r = yaw
        elif view_angles_order_6.get() == viz.DOWN:
                y = roll
                p = yaw
                r = pitch
        # invert:
        if view_angles_invert_yaw.get() == viz.DOWN:
                y = -y
        if view_angles_invert_pitch.get() == viz.DOWN:
                p = -p
        if view_angles_invert_roll.get() == viz.DOWN:
                r = -r
        return [y, p, r]

Could anybody give a sample code of using 3DOF tracker for viewport control via VRPN, that is working properly?

farshizzo 08-12-2009 11:39 AM

I believe the problem is that the VRPN server is sending the InterSense data in a different coordinate frame than Vizard's coordinate frame. You can use the swapQuat command on the VRPN tracker object to modify its coordinate system. I'm not sure what exact values you will need to correct the VRPN data, but here is how Vizard's built-in InterSense plugin swaps the quaternion data:
Code:

tracker.swapQuat([-3,4,-2,1])
Add this code after you create the VRPN tracker object and see if it helps. If it doesn't then you might need to modify the swap values.

_kj_ 08-13-2009 12:03 AM

Thanks, this solution worked correctly at least for miniAHRS tracker via VRPN. I used exactly the same swap values for tracker.swapQuat(). We`ll test this solution for other trackers some time later.


All times are GMT -7. The time now is 01:50 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC