cgxeiji / CGx-InverseK

Inverse Kinematic Library for Arduino for a three link-arm system with a rotating base.
GNU General Public License v3.0
63 stars 12 forks source link

Clarification on joint angle definitions #10

Open Tyler-Curnow opened 7 months ago

Tyler-Curnow commented 7 months ago

When you say that the arm is "stretched out" when all servos are at 90 degrees do you mean that the arm will be standing straight up? Why is it that all joint angles would be 90 degrees? Would it not be 90 degrees for the base with 0 degrees for the remaining angles (ie upperarm, forearm, wrist)?

Typically aren't joint angles measured from the projection of the previous link? For example, if you had the arm standing straight up with the elbow bent 90 degrees to the right, the joint angles would be as follows: Shoulder -> 90, Elbow -> 90 (or 270 depending on how you are measuring), wrist ->180

I am trying to adapt your code to an arm run by linear actuators and I keep getting no solution found and I believe this is the issue, if you could clarify with some drawings it would be very helpful.

cgxeiji commented 7 months ago

Thank you for your question!

The angle calculated by the ik solver is described here. This is the angle you get in radians that is based on the projection from link to link. This angle will be indeed 0 to pi. Then you need to transform this angle to the actual range of your servos (which is done by the a2b function in the README example) which could be 0 to 180.

If you assembled your arm so that your servo is stretched out at 180 degrees (or 0 degrees, in which case you will need to transform the angle with servo = 180-angle), then you are right! If you however assembled your arm so that your servo goes from 0 degrees left, 90 degrees stretched, 180 degrees right, then you need to transform you angle to account for that, in which case the arm will be stretched out at 90 degrees. The final angles depends on how you physically built the arm.

I hope this answered your question!

Tyler-Curnow commented 7 months ago

I think that answers my question, I am going to draw out what I am trying to do and send a more detailed explanation, I am still getting an error.

Tyler-Curnow commented 7 months ago

Image below,

So I have an arm that I built that has 3 links and 3 joints. The first link, the upperarm has a length of 24.7", the forearm has a length of 17.5", and the end of the arm has a length of 3.1". I have a shoulder/base joint, an elbow joint, and a wrist joint.

I understnad that your code is for the braccio arm but it should theoretically work for my arm as well given that I only move in the X,Z plane and only pass Y as zero as I do not have a rotating base.

I was unsure how you were getting your joint angles so I redrew my arm with the same method as your cosine rule, the joint angles are now measured from the previous link to the next. Again, this can be seen in the picture below.

The shoulder joint has a max min angle of: .1° to 62° The elbow joint has a max min angle of: 59° to 147° The wrist joint has a max min angle of: 128° to 180°

I follow your example and plug in these limits as well as joint lengths but when I pass a valid position to the solver I get an error saying that it is not a valid location. What do you think is the issue? IMG_3542

Tyler-Curnow commented 7 months ago

Hey any update? I am still struggling to get this to work...