Inverse Kinematics

Gifs taken by another member of the development team

This is an attempt at simulating the inverse kinematics system of the Space Shuttle Canadarm. The goal of this function is to calculate the required angles of the joints given the position of the end effector. The general concept works well however there are severe bugs as you will see below. It seems that the major issues occur when the arm is directed to over-extend. The issue where the wrist angles without input is an issue that I have yet to resolve.

OPERATION
Player uses WASDQE inputs to direct the end effector to move appropriately. This passes the requested movements through a function which will calculate the joint angles and rotate the joints so that the specified end effector position and angle can be achieved. The arm has the ability to adjust the joints individually and then these need to be taken into account by and rendered by the function. The joints are Motor6Ds that are altered by adjusting the C0 CFrame Angles. The two gifs below illustrate the proper operation of the arm.

https://gyazo.com/9c5de306292b34ca8ef61555bc182e06
https://gyazo.com/fd57743d4458922c99d7de495b1aac37

INCORRECT OPERATION
It almost seems as though it faces issues with rounding values or some other odd error. It’s not near the origin which leaves me relatively dumbfounded when it begins to angle the wrist on it’s own. As for the “turn inside itself” issue as seen in the second gif, this is most likely due to trying to set the middle angle of the trigonomic function as 0 which it determines is impossible and then freaks out. Trying to figure out a way to resolve both of these issues. One of the bigger issues as well is being unable to determine current CFrame angles of the Motor6Ds as well.

https://gyazo.com/d7f29a7d0af7028dba11ccd8a27075d8
https://gyazo.com/6ccf0996b8be230f191c4630863a576e

If anyone has any suggestions or would like to assist me with the code, please let me know. I wouldn’t necessarily like to release this as open source as it’s rather sensitive and seems to be first of it’s kind but any help would be appreciated. I can share place access if necessary and I will only be sharing it with people who actually seem to know what they’re doing (ie no tire kickers).

Discord: FlightVector#9013

1 Like

Helloo, facing difficulties with IK as well? Same…

Yeet my IK broke

https://i.imgur.com/HaMwf28.mp4

Some questions I have.

Firstly what IK Method are you using? Seems like manual trigonometric calculations.

Secondly:

So about this did you make sure the clamp your trigonometric functions? The scenario where it freaks out is yes a rounding error I’ve had it happen before. Did you make sure to add a math.clamp?

                -- Obtains the CFrame rotation calculation for CFrame.fromAxis
                local limbVectorRelativeToOriginal = previousLimbCF:VectorToWorldSpace(originalVectorLimb)
                local dotProductAngle = limbVectorRelativeToOriginal.Unit:Dot(currentVectorLimb.Unit)
                local safetyClamp = math.clamp(dotProductAngle, -1, 1)
                local limbRotationAngle = math.acos(safetyClamp)
                local limbRotationAxis = limbVectorRelativeToOriginal:Cross(currentVectorLimb) -- obtain the rotation axis

I have a high suspicion one value went NAN and ruined everything like in your second gif. This has happened to mine as well with limbs disappearing as well.

Currently for performing constraints, the IK I’m stumped as well. There just seems to be a region where the IK can’t solve and will freak out when the end effector is in that area. The solution for mine was to just remove the constraints when it goes outside a predefined area which I defined using region 3 parts. It’s merely a bandaid solution and I don’t like it at all.

Hopefully, we can work out a way to resolve these odd IK glitches.

Currently, I’m using FABRIK to do IK, I have no idea if you want to try it out but here is the link anyway since I open-sourced mine.