Brute Force Inverse Kinematics for a 3 Link Planar Manipulator

Hello everyone, first time poster here on r/robotics . I am currently in a robotics class in college and as part of a final project we were asked to create MATLAB functions to solve forward and inverse kinematics cases for a 3 link planar manipulator.

For forward kinematics we were given three cases–the theta joint variables for each case, theta 1,2, and 3,–and were asked to find the matrix that described the position and orientation of the end effector with respect to the base frame for each case.

For inverse kinematics, we were given 4 matrices that described the position and orientation of the end effector with respect to the base frame, and were asked to find the joint variables–thetas 1,2, and 3–and return all of the solutions for each case. For this configuration, there are 2 solutions, elbow up and elbow down for the same end effector position.

Before I go on, I will say I did finish the project the non-brute-force-method way. So that means drawing out the configuration by hand and using trigonometric relationships to create governing equations to then create functions in MATLAB to solve the inverse kinematics.

My forward kinematics function will give you the end effector frame w.r.t. the base frame, for both real and symbolic variables, for any configuration, and that’s the easy part.

But I had a second thought today. Couldn’t you brute force your way to finding the solutions?

Here was my approach, and this is for this specific configuration only. Although, I could change it to brute force it for any configuration, but we’ll get in to that in just a second.

First, know what your configuration is, assign your frames, and make a DH table. Input the matrix that describes the position and orientation of the end effector with respect to to the base frame that you want to perform inverse kinematics on.

Second, if you don’t have any limiting factors for the joints (such as theta 1 can only move between -30 and 30 degrees and so on…), create 3 nested for-loops (that’s one for each link) that each count from 0 to 360, with an itterative resolution of your choice, such as itterate every 0.001 degrees.

Third, plug in the theta values and known link lengths (a values) into the forward kinematics function to obtain the matrix that describes the position and orientation of the end effector with respect to the base frame.

Fourth, compare that matrix with the matrix that you entered into the function. If your boolean return is true, store those theta values in a vector, and check the next combination of theta values. If the boolean returned a false, disregard those theta values.

What you end up doing here is brute-forcing your way to the solutions of the theta values for the links. And maybe something caught your eye, THE SIZE OF THOSE FOR-LOOPS. Yep, that’s right, even if you were going by 1 degree intervals, that’s almost 47 million loops. For a fine-tuned itteration like checking every 0.001 degrees, lets not talk about it…

But that fact is, it works! I ran it with 10 degree intervals for a configuration where I knew what the theta values were for both solutions, and it returned the correct solutions!

Again, this one is only functional for the 3-link planar manipulator in my project. But I’m fairly certain I could expand it to work for any configuration.

I can’t seem to find anything about using this type of method to solve inverse kinematics, have any of you heard of or tried this approach? I realize that its computationally exhaustive and inefficient, but…it works. Anyways, I’m just looking to get some feedback, let me know what your ideas/opinions are with an approach like this.

submitted by /u/Rhaegord
[link] [comments]