Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment and mini project #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Assignment 1.pdf
Binary file not shown.
Binary file added miniproject 0.pdf
Binary file not shown.
51 changes: 51 additions & 0 deletions task 3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 26 00:27:59 2022

@author: turpa
"""

import math
import lmfit
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
x=5
y=3
l1=4
l2=3
Fx=0.2*(x-2)
Fy=0.2*(y-1)
#x=int(input("enter the value of x="))
#y=int(input("enter the value of y="))
#l1=int(input("enter the value of l1="))
#l2=int(input("enter the value of l2="))
def anglecalc(x,y,l1,l2):
D=((x**2+y**2-l1**2-l2**2)/(2*l1*l2))
theta=math.degrees(math.atan(math.sqrt(1-D**2)/D))
q1=math.degrees(math.atan(y/x))-math.degrees(math.atan((l2*math.sin(math.radians(theta)))/(l1+l2*math.cos(math.radians(theta)))))
q2=q1+theta
return(q1,q2,theta)

q1,q2,theta = anglecalc(x, y, l1, l2)
xout=l1*math.cos(math.radians(q1))+l2*math.cos(math.radians(q2))
yout=l1*math.sin(math.radians(q1))+l2*math.sin(math.radians(q2))
a=[]
b=[]
q1dis=np.linspace(0, q1,10)
for i in range(0,10):
x=l1*math.cos(math.radians(q1dis[i]))+l2*math.cos(math.radians(q1dis[i]))
a.append(x)
y=l1*math.sin(math.radians(q1dis[i]))+l2*math.sin(math.radians(q1dis[i]))
b.append(y)
q2dis=np.linspace(0,q2,10)
for i in range(0,10):
x=l1*math.cos(math.radians(q1))+l2*math.cos(math.radians(q2dis[i]))
a.append(x)
y=l1*math.sin(math.radians(q1))+l2*math.sin(math.radians(q2dis[i]))
b.append(y)
plt.plot(a,b)
plt.show()
Torq1=-l1*Fx*math.sin(math.radians(q1))+l1*Fy*math.cos(math.radians(q1))
Torq2=-l2*Fx*math.sin(math.radians(q2))+l1*Fy*math.cos(math.radians(q2))
print("Torques required at each joint", Torq1,Torq2)
38 changes: 38 additions & 0 deletions task 4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

import math
import lmfit
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
x=5
y=3
l1=4
l2=3
x0,y0 = 0,0
q1=35
q2=35
x1=l1*math.cos(math.radians(q1))
x2=x1+l2*math.cos(math.radians(q2))
y1=l1*math.sin(math.radians(q1))
y2=y1+l2*math.sin(math.radians(q2))
xout=l1*math.cos(math.radians(q1))+l2*math.cos(math.radians(q2))
yout=l1*math.sin(math.radians(q1))+l2*math.sin(math.radians(q2))
a=[]
b=[]
q1dis=np.linspace(35, 135,101)
for i in range(0,100):
x=l1*math.cos(math.radians(q1dis[i]))+l2*math.cos(math.radians(q1dis[i]))
a.append(x)
y=l1*math.sin(math.radians(q1dis[i]))+l2*math.sin(math.radians(q1dis[i]))
b.append(y)
xn=a[np.size(a)-1]
yn=b[np.size(a)-1]
plt.figure()
plt.plot([x0,x1],[y0,y1],linewidth=2)
plt.plot([x1,x2],[y1,y2],linewidth=2)
plt.plot(a,b,linewidth=2)
plt.plot(x0,y0,"ko",linewidth=4)
plt.plot([x0,xn],[y0,yn],linewidth=2)
#plt.plot([x0,a[np.size(a)-1]],[y0,np.size(b)-1],line=2)
plt.plot(x1,y1,"ko",linewidth=4)
plt.plot(x2,y2,"r*",linewidth=4)
45 changes: 45 additions & 0 deletions task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 6 21:09:59 2022

@author: turpa
"""
import math
import lmfit
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
x=5
y=3
l1=4
l2=3
#x=int(input("enter the value of x="))
#y=int(input("enter the value of y="))
#l1=int(input("enter the value of l1="))
#l2=int(input("enter the value of l2="))
def anglecalc(x,y,l1,l2):
D=((x**2+y**2-l1**2-l2**2)/(2*l1*l2))
theta=math.degrees(math.atan(math.sqrt(1-D**2)/D))
q1=math.degrees(math.atan(y/x))-math.degrees(math.atan((l2*math.sin(math.radians(theta)))/(l1+l2*math.cos(math.radians(theta)))))
q2=q1+theta
return(q1,q2,theta)

q1,q2,theta = anglecalc(x, y, l1, l2)
xout=l1*math.cos(math.radians(q1))+l2*math.cos(math.radians(q2))
yout=l1*math.sin(math.radians(q1))+l2*math.sin(math.radians(q2))
a=[]
b=[]
q1dis=np.linspace(0, q1,10)
for i in range(0,10):
x=l1*math.cos(math.radians(q1dis[i]))+l2*math.cos(math.radians(q1dis[i]))
a.append(x)
y=l1*math.sin(math.radians(q1dis[i]))+l2*math.sin(math.radians(q1dis[i]))
b.append(y)
q2dis=np.linspace(0,q2,10)
for i in range(0,10):
x=l1*math.cos(math.radians(q1))+l2*math.cos(math.radians(q2dis[i]))
a.append(x)
y=l1*math.sin(math.radians(q1))+l2*math.sin(math.radians(q2dis[i]))
b.append(y)
plt.plot(a,b)
plt.show()
44 changes: 44 additions & 0 deletions task2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import math
import lmfit
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
x=5
y=3
l1=4
l2=3
Fx=0
Fy=-1
#x=int(input("enter the value of x="))
#y=int(input("enter the value of y="))
#l1=int(input("enter the value of l1="))
#l2=int(input("enter the value of l2="))
def anglecalc(x,y,l1,l2):
D=((x**2+y**2-l1**2-l2**2)/(2*l1*l2))
theta=math.degrees(math.atan(math.sqrt(1-D**2)/D))
q1=math.degrees(math.atan(y/x))-math.degrees(math.atan((l2*math.sin(math.radians(theta)))/(l1+l2*math.cos(math.radians(theta)))))
q2=q1+theta
return(q1,q2,theta)

q1,q2,theta = anglecalc(x, y, l1, l2)
xout=l1*math.cos(math.radians(q1))+l2*math.cos(math.radians(q2))
yout=l1*math.sin(math.radians(q1))+l2*math.sin(math.radians(q2))
a=[]
b=[]
q1dis=np.linspace(0, q1,10)
for i in range(0,10):
x=l1*math.cos(math.radians(q1dis[i]))+l2*math.cos(math.radians(q1dis[i]))
a.append(x)
y=l1*math.sin(math.radians(q1dis[i]))+l2*math.sin(math.radians(q1dis[i]))
b.append(y)
q2dis=np.linspace(0,q2,10)
for i in range(0,10):
x=l1*math.cos(math.radians(q1))+l2*math.cos(math.radians(q2dis[i]))
a.append(x)
y=l1*math.sin(math.radians(q1))+l2*math.sin(math.radians(q2dis[i]))
b.append(y)
plt.plot(a,b)
plt.show()
Torq1=-l1*Fx*math.sin(math.radians(q1))+l1*Fy*math.cos(math.radians(q1))
Torq2=-l2*Fx*math.sin(math.radians(q2))+l1*Fy*math.cos(math.radians(q2))
print("Torques required at each joint", Torq1,Torq2)