symbolic solving system of non-linear equations

I have system of 12 equations, they look something like these.
equation1 = - cos((pi*theta6)/180)*(sin((pi*theta5)/180)*(cos((pi*theta1)/180)*cos((pi*theta2)/180)*sin((pi*(theta3 - 90))/180) - cos((pi*theta1)/180)*sin((pi*theta2)/180)*cos((pi*(theta3 - 90))/180)) - cos((pi*theta5)/180)*(cos((pi*theta4)/180)*(cos((pi*theta1)/180)*cos((pi*theta2)/180)*cos((pi*(theta3 - 90))/180) + cos((pi*theta1)/180)*sin((pi*theta2)/180)*sin((pi*(theta3 - 90))/180)) + sin((pi*theta1)/180)*sin((pi*theta4)/180))) - sin((pi*theta6)/180)*(sin((pi*theta4)/180)*(cos((pi*theta1)/180)*cos((pi*theta2)/180)*cos((pi*(theta3 - 90))/180) + cos((pi*theta1)/180)*sin((pi*theta2)/180)*sin((pi*(theta3 - 90))/180)) - cos((pi*theta4)/180)*sin((pi*theta1)/180))==cos(pi*b1/180);
How I can transform them to get symbolic value of theta1...theta6? I tried to use solve() but my computer is working for 6 days and I still do not have any resoult.
sol = solve([equation1, equation2, equation3, equation4, equation5, equation6, equation7, equation8, equation9, equation10, equation11, equation12], [theta1, theta2, theta3, theta4, theta5, theta6], 'ReturnConditions', true);
Can I do it in easier and faster way?

1 Commento

For one thing, the calculation would be faster if you switched the angles to radians

Accedi per commentare.

Risposte (2)

Torsten
Torsten il 29 Nov 2023
Spostato: Torsten il 29 Nov 2023
A system of 12 equations in 6 unknowns usually has no solution since it is overdetermined. Or can you extract 6 of the 12 equations, solve them and the solution will also satisfy the remaining 6 ? If this is not the case, try a numerical solver, e.g. lsqnonlin, which is especially suited for overdetermined nonlinear systems of equations.

3 Commenti

Thx for answer, i will try with 6 equations. It is enough for me. If it does not give me correct result i will learn about lsqnonlin
Trigonometric equations typically have multiple solutions. How do you determine which solution yields the correct result? I wonder...
This equations describes positon of 6 axes robot so I can just try the solution. I thought about @Torsten answer and this system of 12 equations should have solutions because there are denpend on each other.

Accedi per commentare.

John D'Errico
John D'Errico il 29 Nov 2023
Modificato: John D'Errico il 29 Nov 2023
Solve does not apply to over-determined problems. But it does not know there may be some exact solution that solves the entire ssytem exactly. So it keeps on trying to find one. Worse, is that problems like this in symbolic form will end up with literally millions of terms. So the computations are incredibly time and memory consuming.
DON'T USE SOLVE! At best, you will need to use a numerical solver, perhaps lsqnonlin is best here for the over-determined problem. (Not vpasolve either.)
HOWEVER, remember there will be infinitely many solutions, if there are any. This is always the case for trig problems. But as much, remember there will be multiple solutions of a subtly different form. For example, what are the solutions to a problem as simple as
sin(x) == 1/2
You should see that x==pi/6 or 5*pi/6 are both solutions (30 or 150 degrees for you), and they come from different parts of the curve. As such, they can be viewed as are fundamentally different solutions. They may have different character in your problem, and some of these solutions may be more or less appropriate. This means you need to use intelligently chosen starting values.

12 Commenti

I am not sure if you understand me correctly. I do not need the value but i want to write equation for theta
example theta1= sin(b1)*cos(b2).....
John D'Errico
John D'Errico il 29 Nov 2023
Modificato: John D'Errico il 29 Nov 2023
Sorry, but you clearly don't understand me correctly. YOU CANNOT DO IT. Not in a finite amount of time, even if it is possible. Symbolic solvers end up generating millions of terms for this sort of problem, and that means the time required and the memory requirements, even if a solution exists, will be immense.
You have 12 equations. You have 6 unknowns. That makes it an over-determined problem, so more equations than variables. As such, it will almost always not have an exact solution.
Just wanting something to exist does not make that happen, well, not unless you have a magic wand, and I do not think your name is Harry Potter.
All of this means that IF you want to solve the problem, the only way to do so is using numerical solvers. Now go back and re-read the responses you have gotten.
Okey, thanks a lot. I will think one more time about my problem :D
If you can explain a bit more about the 12 (or 6) equations of the 6-axis robot arm (manipulator), and what to do with the 6 joint angles (theta1 to theta6), perhaps we can advise you how to solve the math problem in some ways.
Also, if I'm not mistaken, some joint angles cannot freely rotate from 0° to 360°. These are constraints of the problem.
Konrad
Konrad il 29 Nov 2023
Modificato: Sam Chak il 29 Nov 2023
@Sam Chak So starting one more time. I built a 6-axis robot. https://strefainzyniera.pl/images/artykuly/27539b555.jpg
This photo pretty well describes my construction. I created a transformation matrix using Danevit Hantenberg notation. Theta1, theta2, etc., are the angles of axis1, axis2, etc.
Now I can pass the angles of each motor and get the end position of my robot, but this isn't very useful. I want to pass the position of the robot and calculate, using the equations, the angles of the axes I need to set.
You forgot to explain the 12 (or 6) equations. What are they? Can you really reduce the 12 equations to only 6?
Number of equations is result of Danevit hantenbeg notation. 3 of them describe position end of robot (I can not reduce them) in space and others describe angles end of robot. The describe angle between x-x0, y-y0, z-z0 but also between x-y0, x-z0 .... so they are depend of each other and I can reduce from 9 to 3. I hope now evertyhing is clear :D
IMAO when this 9 equations are dependent and I can reduce them into 3 equations, the whole system of equations has only one solution. Am i still wrong?
What do you mean by "9 equations are dependent"? If they depend on each other, how exactly do they depend on each other?
You have 3 of 12 equations that describe the end position of the robot.
And then you have the 4th equation describe angles of robot.
Is the 5th equation derived from the 4th equation?
Is the 6th equation derived from the 5th equation or the 4th equation?
equation4 - x, equation8 - y, equation12 - z, equation1 cos(x0, x6), equation2 cos(x0,y6), equation3 cos(x0,z6), equation5 cos(y0,x6), equation6(y0,y6) equation7 cos(y0,y6), equation9 cos(z0, x6), equation10 cos(z0,y6), equation11 cos(z0,z6) https://drive.google.com/file/d/1Rq0Qz7St09E5jv14dmOqX3gZWpDztvRS/view?usp=sharing
it describe angles of end of robot, not angles of robot axis
If you can reduce the number of equation, try solving it again.

Accedi per commentare.

Prodotti

Release

R2023b

Richiesto:

il 29 Nov 2023

Commentato:

il 30 Nov 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by