WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-04-2014, 02:05 PM
Melody Melody is offline
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.
Reply With Quote
  #2  
Old 09-08-2014, 02:27 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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)
Reply With Quote
  #3  
Old 09-11-2014, 09:23 AM
Melody Melody is offline
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.

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


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Real time collision and object navigation sunil.nair Vizard 11 10-04-2013 08:10 PM
how to hide 3D virtual object behind real object? Darkmax Vizard 3 05-29-2012 09:39 AM
Time - seconds are longer than real seconds clowenth Vizard 6 05-19-2010 09:14 AM
Can you link the position of a tracker to the orientation of an object? michaelrepucci Vizard 1 09-19-2008 10:23 AM
timer question Elittdogg Vizard 5 10-10-2007 02:49 PM


All times are GMT -7. The time now is 11:22 PM.


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