WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-24-2014, 07:31 PM
Melody Melody is offline
Member
 
Join Date: Aug 2014
Posts: 26
How to get pre and current position of a moving object

I tried to get pre and current position of my haptic device with timer.
But I got the pre and current positions are exactly the same.
Could you please let me know how to solve this problem?

Below please see my coding. Thank you in advance.

def getposition():
global currpos
global currposy
global preposy
currpos=mark.getPosition(viz.ABS_GLOBAL)
prepos=currpos
currpos=mark.getPosition(viz.ABS_GLOBAL)

def maintimer():
vizact.ontimer(0,getposition)

viz.callback(viz.KEYDOWN_EVENT,maintimer)
Reply With Quote
  #2  
Old 09-25-2014, 05:20 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
I am not sure what you are trying to do here. What do you mean by the pre-position of your haptic device? Do you mean the starting position of your haptic device? If so, then you should get the starting position once, outside of your timer loop. It would also be more helpful to know what you're trying to accomplish in general.

You can also try to change vizact.ontimer(0,geposition) to vizact.ontimer(1,getposition). Then the function would only be called every second, so changes of the position of your haptic device would be easier to detect. Finally, does the position of your haptic device gets registered properly? I.e. if you put your haptic device in a certain position, run the code, then move the haptic device and run the code again, does that change the value that you get?
Reply With Quote
  #3  
Old 09-25-2014, 01:07 PM
Melody Melody is offline
Member
 
Join Date: Aug 2014
Posts: 26
I am trying to compare pre and current position of the device to decide which force function to apply.
For your first suggestion, I tried but it seems does not work. Do you have any more detailed suggestion?
The second one is not suitable for my programming. One second is too long to read data for only one time.
Thanks for your answers.
Reply With Quote
  #4  
Old 09-25-2014, 03:30 PM
Melody Melody is offline
Member
 
Join Date: Aug 2014
Posts: 26
I figured it out.
Thank you anyway!
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 02:39 PM.


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