WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 05-12-2005, 04:49 PM
jargon jargon is offline
Member
 
Join Date: May 2005
Location: Es Bee
Posts: 9
Exclamation intersense orientation

I'm using an intersense box to orient a tennis racket. When I use the following code to interface the intersense with vizard:
*********************
racketOri = viz.add('intersense2.dls')
racket=viz.add('racket3.WRL')
racket.scale(1.8, 1.8, 1.8)
racket.rotate(-90,0,0)
racket.translate(0,0,0)
def mytimer(num):
racket.rotate(racketOri.get()[3],racketOri.get()[5], -
racketOri.get()[4])

viz.starttimer(0,0.01,-1)
viz.callback(viz.TIMER_EVENT,mytimer)
**********************

The racket orients correctly right until I roll the racket to a certain point. Then the racket yaws 180 degrees and pitches 180 degrees.

However When I use the following code
(employing the "link" command)
************
racketOri = viz.add('intersense2.dls')
racket=viz.add('racket3.WRL')
racket.scale(1.8, 1.8, 1.8)
racket.rotate(-90,0,0)
racket.translate(0,0,0)
racket.link(racket.Ori)
*****************

This problem goes away (I'm able to yaw pitch and roll 360 degree no problem) However I cannot rotate the racket because it's linked to the intersense orientation. I have two questions on this
1) Is there a way for me to orient the racket in Vizard such that I can use the link command - either resetting the intersense orientation or rotating the racket though it's linked.

2) Shouldn't these two pieces of code do the same thing? If there is a way I can fix the top code - this would solve the problem too.

I'd rather not rotate the model in 3ds max but if it came to that I could do that too.
Thanks for your help
Reply With Quote
  #2  
Old 05-12-2005, 05:14 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

Even though you didn't explicitly say anything about it, I'm assuming you are trying to apply an offset rotation to the racket?

There are many ways to go about this.

1) As you already mentioned, you could rotate the model in 3ds max. This would probably be the easiest solution.

2) Manually apply the rotation in a timer and apply the offset with it. It seems like this is what you are already trying to do. Try the following code instead:
Code:
def mytimer(num):
    ori = racketOri.get()
    racket.rotate(ori[3],ori[4],ori[5])
    racket.rotate(offset[0],offset[1],offset[2],viz.RELATIVE_LOCAL)
This will perform exactly what the link command does, but afterwards it applies an offset rotation.

3) You could use a transform hierarchy to offset the racket automatically. Here is some sample code:
Code:
racket = viz.add(viz.GROUP)
racketModel = racket.add('racket3.wrl')
racketModel.rotate(offset[0],offset[1],offset[2])
racket.link(racketOri)
This will place the racket model underneath a hierarchy. The offset rotation will be applied to the racket model and the intersense will be linked to the parent transform, which is the GROUP node.

4) Reset the intersense in your offset rotation. Hold the physical racket in the neutral position and apply a reset command to the racketOri. After this point the intersense plugin will automatically apply an offset to the rotation. I noticed that you are using a different intersense plugin named intersense2.dls. If it is an older version of the plugin, then this method might not work. Anyway, to use this method you would use the following code:
Code:
racketOri = viz.add('intersense.dls')
racketOri.command(8) #Tell the intersense to use quaternion rotations instead of eulers
racketOri.command(9) #Tell the intersense to apply offset rotation
Now, whenever you want to reset the racket to its neutral rotation you would issue the following command:
Code:
racketOri.reset()
Let me know if any of these methods don't work
Reply With Quote
  #3  
Old 05-14-2005, 05:55 PM
jargon jargon is offline
Member
 
Join Date: May 2005
Location: Es Bee
Posts: 9
Wink totally worked

Thanks, I modified this code
def mytimer(num):
ori = racketOri.get()
racket.rotate(ori[3],ori[4],ori[5])
racket.rotate(offset[0],offset[1],offset[2],viz.RELATIVE_LOCAL)

and it works perfectly now.
Thanks!
__________________
:-$
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 11:44 AM.


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