I am making a robotic arm and the inverse kinematics to find where to move the servos requires solving a 4th degree polynomial with known coefficients. I only need real solutions but do need all the real solutions not just one.
It needs to be pretty accurate but doesn't have to be perfect, so methods that very closely approximate the roots would be fine. Thanks!
It is a computer algebra system. Something like yacas. Your polynomials will be something like
ax^4 + bx^3 + cx^2 + dx + e = 0
will they not? If any of {b, c, d, e} is guaranteed to always be 0, this can be simplified. The user gives the values of the coefficients and the lookup table spits out the real roots.
Yeah I remember hearing about newton's method in calculus class. Idk how to code it tho, to find all real roots. And if there are no real roots it will just get stuck in an infinite loop no?
Basically I set up a system of equations based on known lengths and positions (the user inputs a desired x and y coordinate). I solved it for the y co ordinate of one part of the arm, which then allows me to know where all the parts of the arm are located in space. If there are multiple real, positive solutions that corresponds to multiple ways to move the arm to the same end position.
Also I was using an ESP 32 for the robotic arm at first because it is way faster. However, I thought 3.3v instead of 5v signals was giving the servos issues but i think the problem might have been something else. so i switched to an arduino uno. either way i could probably switch back to the esp32 if i need the additional computational power. sadly i do not have a 3.3v to 5v logic level converter on hand either
I was gonna try to get the ESP32 to work with the arduino uno but thats way too much work im gonna get my arduino mega for this brb. Cause the servos hate the 3.3V and dont work with it!
If that equation is a result of trying to position that arm , you might get a better result by using the equations of motion of each arm part and solving those in turn .
If have to keep in mind the accuracy of positioning you will get with the mechanics you use ( repeatability , etc) and some of the values of each term in your equation may have zero affect on the position of the arm and can be eliminated making the job easier .
Well quite a lot to code
I guess the numeric approximation using newton will be easier to code
p_4(x) shall be the polynomic function p_4(x) = ax^4 + bx^3 + cx^2 + dx + e
and solutions of ax^4 + bx^3 + cx^2 + dx + e = 0
The basic thing is to calculate the slope of a point
slope m = ( p_4(x+h) - p_4(x) ) / h
and use this slope to get a linear function
l(x) = m x + b where b must be calculated from the given point
and then solve the linear equation mx + b = 0 which gives the next approximation for the next iteration until you have an x-value that results in p_4(x) is near to zero
quite some code bt not that complex as you can devide the whole calculation into many easy to code steps
I was looking up newtons method and it is a lot easier than described above
it boils down to
x_n+1 = x_n - f(x_n) / f ' (x_n)
f ' (x) can be calculated with the polynomrule of differentiation
If there is f(x) = ax^n
f ' (x) = a * n * x^(n-1)
or you could do a numerical approximation for f ' (x) with
f ' (x) = [ f(x + h) - f(x) ]/ h