'How to solve equation sets with SymPy to find some angles?
I do not quite understand how to solve my equation set with SymPy in Python. I have tried using solve() and nsolve(). solve() gives me no answer, it just stands and goes, nsolve() gives me this error.
ValueError: Could not find root within given tolerance. (7378.8100001153525709 > 2.16840434497100886801e-19) Try another starting point or tweak arguments.
This is what I have written when I tried using solve():
from sympy import *
theta_1, theta_2, theta_3 = symbols('theta_1 theta_2 theta_3')
eq1 = -136.2*sin(theta_2)*sin(theta_3)*cos(theta_1) + 136.2*cos(theta_1)*cos(theta_2)*cos(theta_3) + 222.1*cos(theta_1)*cos(theta_2)
eq2 = -136.2*sin(theta_1)*sin(theta_2)*cos(theta_3) + 136.2*sin(theta_1)*cos(theta_2)*cos(theta_3) + 222.1*sin(theta_1)*cos(theta_2)
eq3 = 136.2*sin(theta_2)*cos(theta_3)+ 222.1*sin(theta_2) + 136.2*sin(theta_3)*cos(theta_2) + 100.9
eq1 = Eq(eq1, 0)
eq2 = Eq(eq2, (-323.90))
eq3 = Eq(eq3, 176.71)
ans = solve((eq1, eq2, eq3), (theta_1, theta_2, theta_3))
print(ans)
This is what I have written when I tried using nsolve():
from sympy import *
theta_1, theta_2, theta_3 = symbols('theta_1 theta_2 theta_3')
eq1 = -136.2*sin(theta_2)*sin(theta_3)*cos(theta_1) + 136.2*cos(theta_1)*cos(theta_2)*cos(theta_3) + 222.1*cos(theta_1)*cos(theta_2)
eq2 = -136.2*sin(theta_1)*sin(theta_2)*cos(theta_3) + 136.2*sin(theta_1)*cos(theta_2)*cos(theta_3) + 222.1*sin(theta_1)*cos(theta_2)
eq3 = 136.2*sin(theta_2)*cos(theta_3)+ 222.1*sin(theta_2) + 136.2*sin(theta_3)*cos(theta_2) + 100.9
ans = nsolve((eq1, eq2, eq3), (theta_1, theta_2, theta_3), (0, -323.9, 176.71))
print(ans)
I want to find an expression for theta1, theta2, and theta3. Preferably in the form of arctan2. Does anyone know how I can do this? or why this does not work?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
