WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 07-09-2008, 03:27 PM
jalvarez jalvarez is offline
Join Date: Jun 2008
Posts: 12
Physics and Haptics

I want to use a haptic device to grasp a part, enable collision between multiple parts, and allow the user to feel the force through a Phantom Omni.

First I noticed that manipulating the objects directly interferes with the physics solver, so I tried adding a spring between the part and the marker so that i have position and orientation control through the spring. However when i add the angular Kd and Ks it doesnt give me orientation control. What is the correct way of adding a Torsional spring upon pressing the omni's button?

I have also sat the accuracy and step size of my simulation because the physics were non realistic. However there are still some issues (the parts should not go through one another)

I want to calculate the spring force (which is simply subtracting the
position of Omni marker and the grasped part). However I am not sure how
to render a specific haptic force. I have used constant effect.

Here is my code

thank you in advance for your help

import viz
import math
import hd


cyl = viz.add('cylinder.wrl',pos=[0,2,5])

#spring = cyl.addSpring(viz.LINK_POS,linearKd=100,linearKs=1 0000, angularKs=100, angularKd=10)

sphere = viz.add('sphere.wrl',pos=[-1,2,5])


marker = viz.add('marker.wrl',pos=[0,2,5])


#add spring effect for collision
ce = hd.ConstantEffect(dir=[0,0,-1],mag=1)

def hdbuttondown(button):

if button == hd.BUTTON1:

objects = hd.get(hd.TOUCH_OBJECTS)
for obj in objects:
#Begin dragging the object
#Disable the haptic object while dragging it

def hdbuttonup(button):
#Check if button 1 is released
if button == hd.BUTTON1:
for obj in hd.get(hd.DRAG_OBJECTS):
#Re-enable the haptic object
#Stop dragging all objects

def collision(e):
#on collision render a spring force to the omni
if e.obj1 == cyl:
#calculate the force based on position
force=[posMarker[0] - poscyl[0], posMarker[1] - poscyl[1], posMarker[2] - poscyl[2]]

ce.setMagnitude(30*vizmat.Distance(poscyl,posMarke r))


def notcollision(e):
#on collision render a spring force to the omni

Reply With Quote
Old 07-10-2008, 07:52 PM
farshizzo farshizzo is offline
WorldViz Team Member
Join Date: Mar 2003
Posts: 2,849
To enable orientation control with the spring you need to add the viz.LINK_ORI flag. Your code for creating the spring would look something like this:
spring = cyl.addSpring(viz.LINK_POS|viz.LINK_ORI,linearKd=100,linearKs=10000, angularKs=100, angularKd=10)
For apply forces the ConstantEffect should work. Does the sample script that comes with our Sensable Haptic Device download work for you?
Reply With Quote
Old 07-11-2008, 08:43 AM
jalvarez jalvarez is offline
Join Date: Jun 2008
Posts: 12
from my understanding, once you use collide mesh for a part the dynamics get disabled so this defeats the purpose of adding the spring. when i change the part to either collide box, sphere, or capsule the physics go crazy upon collision. if i do collide mesh i the physics work but the force is not always correct. sometimes instead of being a repulsive force between the parts, it attracts them. I plan to do some virtual assembly and this is my first trial on just manipulation, collision detection, and force feedback. if I used collide mesh in all my parts, would this give me a problem?

thank you again for your help!
Reply With Quote
Old 07-16-2008, 04:03 PM
farshizzo farshizzo is offline
WorldViz Team Member
Join Date: Mar 2003
Posts: 2,849
You are correct, using collideMesh will disable dynamics on an object. I think the reason the physics goes crazy is that you are using a very high spring constant, which results in very large force vectors. Try decreasing the spring constant (less than 100). You will need to adjust the constant depending on the density of the object you are controlling.
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 03:07 AM.

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