PDA

View Full Version : calculating angle differences


tavaksai
08-19-2004, 05:17 PM
Hello,

I am trying to find a way to rotate a child in a hierarchy
in such a way that it matches the old rotation of
the parent after parent has been rotated.
Here is an example:


parent = viz.add('parent.wrl')
child = parent.add('child.wrl')
parent_euler = parent.get(viz.EULER)

parent.rotate(yaw1, pitch1, roll1)


now do child.rotate(yaw2, pitch2, roll2) such that
the child has the same rotation as (parallel to)
the parent did before parent rotated.

That is,
(parent_euler) == (child.get(viz.EULER, viz.ABSOLUTE_WORLD))

I am guessing that it may be possible to get the angle
difference between old parent rotation and new parent
rotation and then rotating child by that difference, I
just don't know how get the angle difference.

I am using Euler angles as examples here, but matrix trasformations would be ok also.

Is there maybe a way to detach child from parent using
the hierarchy.dlm plug-in and then reattaching them so that
child keeps old rotation (relative to world) after being attached
to parent?

Thanks in advance,
Max

farshizzo
08-19-2004, 05:46 PM
Hi Max,

The following should work:euler = parent.get(viz.EULER)
parent.rotate(yaw,pitch,roll)
child.rotate(euler,viz.ABSOLUTE_WORLD)
You could also detach the child from the parent and apply the rotation in local coordinates by doing the following:euler = parent.get(viz.EULER)
parent.rotate(yaw,pitch,roll)
#Detach the child from the parent and attach it to the world
child.parent(viz.WORLD)
child.rotate(euler)I believe the parent command was introduced in version 2.16, so make sure you have a recent version of Vizard. Hope this helps.

tavaksai
08-20-2004, 07:32 PM
Thanks for the tip,

I actually tried doing method 1, but with my older
version of Vizard that was not possible. I downloaded
the newest version of Vizard and rotation worked
well, but then I got a brand new problem.

It looks like the new 5DT.dls is not working properly or
the new Vizard simply can't communicate with 5DT gloves.
I get a message like, "ERROR: Failed to connect to
5DT glove on COM3". Same for COM4.

my code looks like:
PORT_5DT = 3
glove_left = viz.add('5DT.dls')
PORT_5DT = 4
glove_right = viz.add('5DT.dls')

The odd thing is that after crashing this way,
ports 3 and 4 get "disabled". Even 5DT Glove Manager
can't accesss those ports after that. What I then do is
disable and re-enable com3 and com4 in the windows
hardware device manager.

Where exactly does Vizard look for plugins first?
Does it look in multiple directories?

farshizzo
08-23-2004, 09:30 AM
Hi Max,

Vizard first looks in the local directory of the script, then it looks in the Vizard20/plug-ins directory. Do you have an older version of the plugin in your local directory? I've placed the latest 5dt plugin in a zip file on our webpage. You can download it here (http://www.worldviz.com/download/files/plugin_5dt_217.zip) This is the same file that came with the 2.17 installer, but maybe the old version wasn't overridden. Just place this file in the Vizard20/plug-ins directory. Let me know if this helps.

tavaksai
08-23-2004, 10:04 AM
Hi,

After more extensive testing, I think I found the cause of the glove problem.

take a look at the following code:


import viz

viz.go(viz.PROMPT)


#####################################
# the following 4 lines must be at the top after viz.go !!!!!
# if you put them after the first if/else statement
# (if viz.get(viz.TRACKER): ..... else tracking = 0)
# glove plug-ins will not be loaded although everything
# else will work
#####################################
PORT_5DT = 3
xleft = viz.add('5dt.dls')
PORT_5DT = 4
xright = viz.add('5dt.dls')

if viz.get(viz.TRACKER):
v = viz.add('intersense.dls')
viz.tracker()
tracking = 1
else:
tracking = 0

left_gyro = viz.add('intersense.dls') # left hand
left_gyro.reset()

right_gyro = viz.add('intersense.dls') # right hand
right_gyro.reset()


light1 = viz.add('vizppt.dls')

light2 = viz.add('vizppt.dls')

light3 = viz.add('vizppt.dls')


See the comment in the box at the top.
My old version of Vizard did not have this problem.


BTW, the

euler = someobj.get(viz.EULER)
child.rotate(euler,viz.ABSOLUTE_WORLD)

method worked great in the new version of Vizard, but did
not work on my older one. So, thanks for that.

Max