WorldViz User Forum How to get real time position of a object which is connected to a haptic device
 User Name Remember Me? Password
 Register FAQ Search Today's Posts Mark Forums Read

#1
09-04-2014, 02:05 PM
 Melody Member Join Date: Aug 2014 Posts: 26
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.
#2
09-08-2014, 02:27 PM
 Jeff WorldViz Team Member Join Date: Aug 2008 Posts: 2,466
Do you get changing positions with the following code?

Code:
```import viz
import vizact
viz.go()

def printPosition():
print device.getPosition()

vizact.ontimer(0,printPosition)```
#3
09-11-2014, 09:23 AM
 Melody Member Join Date: Aug 2014 Posts: 26
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.

,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?
#4
09-11-2014, 02:16 PM
 Jeff WorldViz Team Member Join Date: Aug 2008 Posts: 2,466
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.
#5
09-15-2014, 02:35 PM
 Melody Member Join Date: Aug 2014 Posts: 26
Thank you so much!!!

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements Vizard Precision Position Tracker (PPT) Plug-in development

 Similar Threads Thread Thread Starter Forum Replies Last Post sunil.nair Vizard 11 10-04-2013 08:10 PM Darkmax Vizard 3 05-29-2012 09:39 AM clowenth Vizard 6 05-19-2010 09:14 AM michaelrepucci Vizard 1 09-19-2008 10:23 AM Elittdogg Vizard 5 10-10-2007 02:49 PM

All times are GMT -7. The time now is 06:19 PM.

 Contact Us - WorldViz Home - Archive - Top