WorldViz User Forum

WorldViz User Forum (
-   Precision Position Tracker (PPT) (
-   -   Tracking skews collisions (

adhocdown 04-23-2015 01:16 AM

Tracking skews collisions
I have elegant, functioning collision code. However, once a tracker is introduced to the environment it stops working.

The MainView repeatedly teleports or twitches away from the encountered item instead of making contact and sliding. It's seizure worthy.

I have tried so many workarounds for this, but nothing stabilizes the collision code. I'm assuming it's a tracking-Vizard incompatibility issue, since it works fine in a mouse controlled environment. We're using the DK 2 Rift for orientation and PPT for position tracking.

I've seen a couple of people on the WorldViz forums with similar problems, but their questions were unfortunately never answered.

Jeff 04-23-2015 12:03 PM

Can you post example Vizard code that reproduces the issue for you?

adhocdown 04-23-2015 09:58 PM

I simplified the code as much as I could. It replicates the same problem of glitchy collisions and the problem of 'Collided' calls en masse.


import viz
import time
import string
import vizact
import vizcam
import random
import oculus
import vizinfo
import vizshape
import vizinput

import viztracker
import vizproximity

viz.go()                                                                                                                                                                # Run Vizard.

isIn = False
inWhat = -1
inWhere = None

# Counters.
revisitCtr = 0

# Arrays.
o_house = []
t_ball  = []
houses  = []


# Detect and add the oculus rift ---------------------------------------------------------- #
hmd = oculus.Rift();
vrpn = viz.add('vrpn7.dle')                                                                #Other code should use tracker number 5
posTracker = vrpn.addTracker('PPT0@WORLDVIZ-PC', 5)

isense = viz.add('intersense.dle')
oriTracker = hmd.getSensor()

if not hmd.getSensor():
        sys.exit('Oculus Rift not detected')
# Check if HMD supports position tracking ----------------------------------------------- #
headTracker = viz.mergeLinkable(posTracker, oriTracker)
supportPositionTracking = hmd.getSensor().getSrcMask() & viz.LINK_POS
if supportPositionTracking:
        # Add camera bounds model
        camera_bounds = hmd.addCameraBounds()

        def CheckPositionTracked():
                if hmd.getSensor().getStatus() & oculus.STATUS_POSITION_TRACKED:
        vizact.onupdate(0, CheckPositionTracked)

# Setup navigation node and link to main view
navigationNode = viz.addGroup()
viewLink =, viz.MainView)

# Apply user profile eye height to view --------------------------------------------------- #
profile = hmd.getProfile()
if profile:

headlink =, viz.MainView)
hmd.window = headlink

vizact.onkeydown('r', oriTracker.reset)

yaw,pitch,roll = headlink.getEuler()
m = viz.Matrix.euler(yaw,0,0)

# Add sensor to self.
manager = vizproximity.Manager()
target = vizproximity.Target(headlink)
height = 1.3

# Enable Collision Detection --------------------------------------------------------------#
#viz.MainView.collision( viz.ON )
viz.MainView.stepsize(3) #this seems to make the rejection twitching less violent

def mycollision(info):
        print 'Collided'
viz.callback(viz.COLLISION_EVENT, mycollision)

# Environment Setup ----------------------------------------------------------------------- #
day = viz.add('sky_day.osgb')
ground = viz.add('tut_ground.wrl')

        [1, 0, -5]
        ,[-5, 0, 1]
        ,[5, 0, 1]
        ,[3, 0, 2]
        ,[2, 0, 2]
columns = []

# Birdhouse Setup ------------------------------------------------------------------------- #       
def make_a_home():
        col_num = 0
        for pos in LOCATIONS:
                print 'Add a house'
                newCol = viz.addChild('plant.osgb')
                #Create collision boxes and link to birdhouses
                colBox = viz.add('box.wrl', scale=[0.5, 8, 0.5])

                colLink = newCol, colBox )
                x_val = pos[0]
                z_val = pos[2]
                print col_num
                print pos[0]
                print pos[2]
                columns[col_num].setPosition([x_val, 0, z_val])
                col_num +=1


Additionally, we tried to turn on collisions with vizconnect, as well. However, the moment we useviz.collision(viz.ON), it disconnects our avatar from MainView. Do you know why this occurs?

Jeff 04-27-2015 11:47 AM

1 Attachment(s)
The problem is the position of the navigation node keeps going after the viewpoint stops from a collision. When you try to back away from a collision object it takes awhile for the navigation node to catch up to the viewpoint.

A solution for this is to use a view_collision module written for use with vizconnect. This checks for collisions against an avatar object and then goes back up the chain to modify any transport node that's driving it. To be clear, no avatar needs to be rendered, that's just what vizconnect uses to group the head tracker and any hand trackers. I've attached an example that includes the view_collision module, the main script that adds a maze and collisions, and desktop vizconnect configuration files. If you create your own vizconnect config file with PPT+Oculus and load that with the maze script it should work with collisions. The setup for the collision detection is in


ac = view_collision.AvatarCollision(collideTrackers=True)

bbb 02-25-2016 03:26 AM

Hey Jeff,
I tried to use your module (view_collission) but some issues appeared:
1)it was an error when trying to use the self._avatar.getSkeleton().getBoneDict()
2) I'm using a transport and not an avatar so i need to replace the avatar commands with transport ones, how can i do that?

I'm using vizconnect with oculus rift Dk2 AS TRACKER, than the transport is walking and the input device is xbox 1 controller (using direct input) and finally the oculus rift DK2 as display (hirarchic order - tracker->transport->display)

Thanks in advance.

Jeff 02-25-2016 04:40 AM

There's no need to download the view collision module I attached in my previous post. The latest view collision module is now included with the Vizard installation. If you have a vizconnect file with an avatar and transport then you can run the following code:


import viz
import vizconnect
from vizconnect.util import view_collision

maze = viz.addChild('maze.osgb')

ac = view_collision.AvatarCollision()

Your vizconnect file must have an avatar to use this collision module. If you don't want to render an avatar then choose the head and hands option and delete the glove.cfg file listed under right hand filename.

bbb 02-28-2016 03:21 AM

Hi Jeff,
Thanks for your replay.
I have vizard 5.2 with active license and i need it to be that kind of version, is it free to upgrade it to vizard 5.3 with active license? if not, is your module in the thread is similar to the one added to vizard 5.3 or that changes have been made since than?
Third question is when in the hierarchy should i put my avatar in order for your module to work?

Thank you.

Jeff 02-28-2016 04:08 AM

You can go to Help > Check for Updates to download the latest version of Vizard. There have been updates to the collision module. When you upgrade to 5.3, you'll also need to upgrade the Oculus runtime to version 0.8.

The transport should be a parent of the avatar so the avatar moves when the transport moves.

All times are GMT -7. The time now is 12:43 PM.

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