View Full Version : Tracking skews collisions

04-23-2015, 01:16 AM
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.

04-23-2015, 12:03 PM
Can you post example Vizard code that reproduces the issue for you?

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.link(navigationNode, viz.MainView)

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

headlink = viz.link(headTracker, 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 = viz.link( 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?

04-27-2015, 11:47 AM
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 warehouse_maze.py:

ac = view_collision.AvatarCollision(collideTrackers=Tru e)
ac.setTransport(vizconnect.getTransport().getNode3 d())

02-25-2016, 04: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.

02-25-2016, 05: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()
ac.setTransport(vizconnect.getTransport().getNode3 d())

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.

02-28-2016, 04: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.

02-28-2016, 05: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.