WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   How to get pre and current position of a moving object (https://forum.worldviz.com/showthread.php?t=5168)

Melody 09-24-2014 06:31 PM

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)

Frank Verberne 09-25-2014 04:20 AM

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?

Melody 09-25-2014 12:07 PM

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.

Melody 09-25-2014 02:30 PM

I figured it out.
Thank you anyway!


All times are GMT -7. The time now is 10:57 AM.

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