View Full Version : How to get real time position of a object which is connected to a haptic device
Melody
09-04-2014, 02:05 PM
How to get real time position of a object which is connected to a haptic device?
My haptic device is phantom omni
I tried to print it out, it shows [0,0,0] all the time.
I need to read the real time position and then apply different functions based on different positions.
Do you get changing positions with the following code?
import viz
import vizact
viz.go()
sensable = viz.add('sensable.dle')
device = sensable.addHapticDevice()
def printPosition():
print device.getPosition()
vizact.ontimer(0,printPosition)
Melody
09-11-2014, 09:23 AM
Thanks Jeff.
May I ask how can I get the real-time spring force I applied?
I tried <effect>.getMagnitude(). But what I get is a constant I set in addSpringEffect.
<device>.addSpringEffect( gain=None
,magnitude=None
,position=None
,referenceFrame=None )
Position here represents the effect position, right?
And what is the relationship between magnitude and spring force? In F = k(P-X), magnitude is the max spring force?
May I ask how can I get the real-time spring force I applied?
After you've defined and enabled the spring effect you could create your own function that returns the spring effect force based on F = k(P - X). Something like the following:
import vizmat
def getSpringForce():
#get effect position and gain.
P = springEffect.getPosition()
k = springEffect.getGain()
#get haptic device position
X = device.getPosition()
#return force
return k * vizmat.Distance(P,X)
Position here represents the effect position, right?
Yes, the position value you pass in when you define the spring effect is the effect position.
And what is the relationship between magnitude and spring force? In F = k(P-X), magnitude is the max spring force?
The magnitude of the effect force is capped at the magnitude value you define.
Melody
09-15-2014, 02:35 PM
Thank you so much!!!
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.