WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-09-2008, 02:27 PM
jalvarez jalvarez is offline
Member
 
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

viz.go()
viz.phys.enable()
viz.phys.setGravity(0,0,0)
viz.phys.setAccuracy(4)
viz.phys.setStepSize(.001)
viz.clearcolor(1,1,1)

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

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

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

hd.add(cyl)
hd.add(sphere)

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

hd.translate(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
hd.drag(obj)
#Disable the haptic object while dragging it
obj.enablehd(0)
viz.starttimer(0,0,viz.FOREVER)

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
obj.enablehd(1)
#Stop dragging all objects
hd.undrag()

def collision(e):
#on collision render a spring force to the omni
if e.obj1 == cyl:
poscyl=cyl.getPosition()
posMarker=marker.getPosition()
#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))

ce.setDirection(force)
ce.start()


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


viz.callback(viz.COLLIDE_BEGIN_EVENT,collision)
viz.callback(viz.COLLIDE_END_EVENT,notcollision)
hd.callback(hd.BUTTONDOWN_EVENT,hdbuttondown)
hd.callback(hd.BUTTONUP_EVENT,hdbuttonup)
Reply With Quote
 


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 04:19 PM.


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