WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   How to get real time position of a object which is connected to a haptic device (https://forum.worldviz.com/showthread.php?t=5161)

Melody 09-04-2014 02:05 PM

How to get real time position of a object which is connected to a haptic device
 
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.

Jeff 09-08-2014 02:27 PM

Do you get changing positions with the following code?

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 .getMagnitude(). But what I get is a constant I set in addSpringEffect.

.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?

Jeff 09-11-2014 02:16 PM

Quote:

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:

Code:

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)

Quote:

Position here represents the effect position, right?
Yes, the position value you pass in when you define the spring effect is the effect position.

Quote:

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!!!


All times are GMT -7. The time now is 03:24 PM.

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