EGjoni / Everything-Will-Be-IK

A Robust Inverse Kinematics Library
MIT License
42 stars 4 forks source link

please add a convenient means to get joint angles after solving IK #2

Closed adamscottv closed 8 years ago

adamscottv commented 8 years ago

Currently, an additional rotation calculation step is needed to get joint angles after solving for IK. Since the purpose of IK is to find joint parameters that provide a given end effector position, it is my opinion that an IK library should provide a means to get the joint angle. In this case, something like double bone.getXAngleRadians(), bone.getYAngleRadians(), bone.getZAngleRadians() or a single method like double[] bone.getXYZAnglesRadians() would be nice to have.

EGjoni commented 8 years ago

Acknowledged. Will add soon.

EGjoni commented 8 years ago

Added a Bone.getXYZAngle() method. Let me know if it works for your purposes.

adamscottv commented 8 years ago

Had another question I was thinking about. Not sure if this is something your code could easily support or if it would be a lot of work.

In robotics it's nice to be able to us Forward Kinematics (FK) to get xyz positions, especially of the end-effector, given a set of input angles. So it would be kind of the opposite process - call setXYZAngles, then call solveFK, then get vectors as result.

There are some practical applications of this functionality. You can get the actual xyz position vs the target position, in case you didn't actually there. It also allows you to do more types of dynamic adjustments if you know where you are. Another convenience is being able to manually arrange the bones, then get the resulting tip position in order to get IK target positions to use.

I could add an issue request if you think it's something you may consider adding in the future. But I understand if it's not a priority.

-Adam


From: Eron Gjoni notifications@github.com Sent: Friday, May 6, 2016 11:42:09 AM To: EGjoni/Everything-WIll-Be-IK Cc: adamscottv; Author Subject: Re: [EGjoni/Everything-WIll-Be-IK] please add a convenient means to get joint angles after solving IK (#2)

Added a Bone.getXYZAngle() method. Let me know if it works for your purposes.

You are receiving this because you authored the thread. Reply to this email directly or view it on GitHubhttps://github.com/EGjoni/Everything-WIll-Be-IK/issues/2#issuecomment-217478758

EGjoni commented 8 years ago

Not entirely sure if I understand your question. But as an attempt to answer it any way:

You can rotate any bone using FK by just calling any one of:

Bone.rotAboutFrameX(rad) Bone.rotAboutFrameY(rad) Bone.rotAboutFrameZ(rad)

Or by composing your own arbitrary Rotation using the Apache Commons Rotation library (included in the .jar) and then calling

Bone.localAxes().rotateTo(Rotation);

You can then just call Bone.getTip() to find where the tip of any Bone is in global space.

So, basically, if you want to figure out where the toe is after rotating the femur, just rotate the femur, then call toe.getTip().

You don't need to call anything to solve FK, because each bone's coordinate system is defined relative to its parent bone's coordinate system. On May 6, 2016 12:40 PM, "adamscottv" notifications@github.com wrote:

Had another question I was thinking about. Not sure if this is something your code could easily support or if it would be a lot of work.

In robotics it's nice to be able to us Forward Kinematics (FK) to get xyz positions, especially of the end-effector, given a set of input angles. So it would be kind of the opposite process - call setXYZAngles, then call solveFK, then get vectors as result.

There are some practical applications of this functionality. You can get the actual xyz position vs the target position, in case you didn't actually there. It also allows you to do more types of dynamic adjustments if you know where you are. Another convenience is being able to manually arrange the bones, then get the resulting tip position in order to get IK target positions to use.

I could add an issue request if you think it's something you may consider adding in the future. But I understand if it's not a priority.

-Adam


From: Eron Gjoni notifications@github.com Sent: Friday, May 6, 2016 11:42:09 AM To: EGjoni/Everything-WIll-Be-IK Cc: adamscottv; Author Subject: Re: [EGjoni/Everything-WIll-Be-IK] please add a convenient means to get joint angles after solving IK (#2)

Added a Bone.getXYZAngle() method. Let me know if it works for your purposes.

You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub< https://github.com/EGjoni/Everything-WIll-Be-IK/issues/2#issuecomment-217478758

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/EGjoni/Everything-WIll-Be-IK/issues/2#issuecomment-217493531