#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
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) 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) 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 Code:
racketOri.reset() |
#3
|
|||
|
|||
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!
__________________
:-$ |
Thread Tools | |
Display Modes | Rate This Thread |
|
|