I’ve made a robotic arm, and I’m trying to get the rotations of the bones in Blender to send to the actual arm. I can get the rotation of the first two bones, but the last one is giving me all sorts of troubles. When I move the last segment up and down, it appears fine until you move the middle segment around.(Control using the empty)
When the tip crosses the x axis, neutral is at a different angle, and if you rotate the middle bone just a few degrees, the outer arm will suddenly switch from e.g. -84 to +84 as you move it up and down. It’s really hard to explain, but if you download the file, run the script, and keep your eye on the console as you move the empty around the cursor, you’ll hopefully understand what I’m saying.
My question is: How can I get reliable local rotations from each bone?
Thank you in advance for the help!
Robotic Arm.blend (418 KB)
did not understand (even with your blend) the problem ;-( …
One thing which may be connected what you try is that Euler-rotations have sometimes a problem “Gimbal-lock”
see e.g. http://ae.tutsplus.com/articles/news/the-rotation-problem-explained/
Quaternions do not have this problem?!
I’ll try to explain better. The last arm(arm2) is limited to rotating around one axis. If I move only that arm up and down, the printed angles appear fine. When I move only the middle arm(arm1) or the first arm(base), the printed rotation on arm2 will change. That should not happen.
Which Blender version do you use (an operating system?) because:
this morning I got and get an error with
import serial but this morning, after activating the script there were number printed to the (general) console .
Meanwhile I compiled a new Blender …
And nothing is printed anymore an no error-message ???
I think someone else has to try to understand …
Maybe you tell too what relations you have set ?!
Aah, the import serial thing is my fault. I forgot to comment that out, forgetting that it’s an installed module. I’ve attached a new version that shouldn’t need any external Python installed.
For constraints and relations, I have an IK constraint on Bone.002(The last bone) set for a chain length of 3, and target as the empty. Also for each bone, I’ve limited certain axes to a range under the Inverse Kinematics portion of the Bone tab.
Robotic Arm.blend (394 KB)
OK, for that small omission, but after activating and moving … nothing is printed in my latest vesion of Blender ;-( so I can not seen
Weird. I’m using a mac with Blender 2.61.0. I just press “Run Script”, select the empty, and move it. Values are printed out as you can see in the screenshot.
Sorry, did not realize (did not read the script) that an empty had to be moved.
Works… so I see the problem
Now I see the jump of sign moving the empty …(will try to find a reason …)
Oh no, do not know enough:
one problem is eventually your way of working:
base_rot = base.matrix.to_euler() * 57.325
arm1_rot = arm1.matrix.to_euler() * 57.325
arm2_rot = arm2.matrix.to_euler() * 57.325
I read something like this: to find the real matrix of a bone with parent you have to use the inverted matrix of a parent to find …
Further a bone has a matrix and matrix_local and though gessing I do not really know the difference
(world matrix? local matrix)
What do the components of the Euler mean? And I think that the values are in radians and not in degrees.
So you need some one who really knows how all this stuff is connected to find out angels (in degrees) you are interested in.
Sorry, more I do not know (yet)
Thanks guys. I’ll look at those links and see what I can find. I’ll post back here when I figure something out(or don’t).
I have a resolution to my problem. To get the proper rotations, I have to take the parent’s inverse matrix multiplied by the bone’s matrix. When I first did it, it took me 15 minutes to realize it was working. I was seeing stuff like “-6.00385729379e-10” and was just reading the first two digits, so I thought it was still giving me absurd values where it should be zero. Lesson learned: A glance at numbers isn’t always sufficient. :o
Thanks for all the help!
opk can you give the example you did so we can refer back to this thread
with a good example for it