three.js icon indicating copy to clipboard operation
three.js copied to clipboard

Robot Arm Example - Rotation about an Axis

Open dimitrii opened this issue 15 years ago • 9 comments

So, this topic was discussed in issue: #417 but I tried to set matrix.setAxisRotation.. and I couldn't figure it out; i am talking like it's been 3 days of me looking at this on and off and still no resolved.

Here is my issue explained:

1.) Take a look at this model: http://cloud.engineering-bear.com/apps/robot/robot.html (the model is loaded as one but eventually when i figure out how to set the axis of rotation i will load in each part individually)

2.) Now after looking at the model, imagine it would come to life and move around at the mechanical joints. The different parts would rotate around axis fixed to their parent object. I understand how to attach the objects together using parent child, but what I don't understand is how to offset the axis of rotation of the objects to when i say object.rotation.x or y or z it will rotate along a new axis. Currently it rotates around the zero, zero, zero point of the model from blender.

Can someone please help and write me an example of how to connect two objects parent and child and then set the axis of the child so it would pivot along a different axis?

And when you off set the axis I am guessing the offset is from the objects 0,0,0? is this correct? then do you simply give it a x,y,z offset and assume the direction of the axis is in the same direction of the initial axis? I am new to programming in general, plus I am new to 3D programming so sorry if this question just sucks.

dimitrii avatar Aug 30 '11 16:08 dimitrii

Did you tried using dummy objects as pivots instead?

var dummy = new THREE.Object3D();
dummy.position.set( end of lower_hand );
lower_hand.addChild( dummy );

middle_hand.position.set( start of middle_hand );
dummy.addChild( middle_hand );

And then..

dummy.rotate.x = 90 * Math.PI / 180;

mrdoob avatar Aug 30 '11 17:08 mrdoob

Thanks a lot mrdoob, that helped me figure it out. Here is what I was trying to do:

http://cloud.engineering-bear.com/apps/robot/robot.html

dimitrii avatar Aug 30 '11 21:08 dimitrii

Yay! :)

mrdoob avatar Aug 30 '11 22:08 mrdoob

@dimitrii That's seriously cool... I'd LOVE to see that with some http://en.wikipedia.org/wiki/Inverse_kinematics

OK, i have a new question relating to this example.

I have been trying to figure out how the world matrix works because in the robot arm example i have 5 meshes attached in a parent, child chain and I really want to know the world X,Y,Z coordinate of the arm (the last mesh in the chain).

Now, I know I can calculate this coordinate using some basic trig, but I am wondering if somewhere inside the hand object the world coordinate system exists. I only need to read the value to help control the robot.

dimitrii avatar Sep 02 '11 22:09 dimitrii

Try with this:

var position = child_mesh.matrixWorld.getPosition();

mrdoob avatar Sep 02 '11 23:09 mrdoob

@dimitrii I do not know how else to contact you. I love this: http://dimitriipokrovskii.appspot.com/robot_arm_joints.html I would like to use in a student project where the arm mimics a human arm observed from the web cam. What is the license of your code?

mdipierro avatar Jan 14 '15 18:01 mdipierro

You have my permission to use this code. If you create any media documenting your final product please share it with me. I would love to see what you have done.

you can find my email address here: engineering-bear.com

On Wed, Jan 14, 2015 at 10:49 AM, mdipierro [email protected] wrote:

@dimitrii https://github.com/dimitrii I do not know how else to contact you. I love this: http://dimitriipokrovskii.appspot.com/robot_arm_joints.html I would like to use in a student project where the arm mimics a human arm observed from the web cam. What is the license of your code?

— Reply to this email directly or view it on GitHub https://github.com/mrdoob/three.js/issues/472#issuecomment-69968732.

Dimitrii

dimitrii avatar Jan 15 '15 00:01 dimitrii

Thank you. I will. But I sill do not know how to contact you outside this thread. I am [email protected].

On Jan 14, 2015, at 6:05 PM, Dimitrii [email protected] wrote:

You have my permission to use this code. If you create any media documenting your final product please share it with me. I would love to see what you have done.

you can find my email address here: engineering-bear.com

On Wed, Jan 14, 2015 at 10:49 AM, mdipierro [email protected] wrote:

@dimitrii https://github.com/dimitrii I do not know how else to contact you. I love this: http://dimitriipokrovskii.appspot.com/robot_arm_joints.html I would like to use in a student project where the arm mimics a human arm observed from the web cam. What is the license of your code?

— Reply to this email directly or view it on GitHub https://github.com/mrdoob/three.js/issues/472#issuecomment-69968732.

Dimitrii — Reply to this email directly or view it on GitHub.

mdipierro avatar Jan 15 '15 00:01 mdipierro