Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

2dof py scripts added #5

Open
wants to merge 1 commit 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
File renamed without changes.
17 changes: 17 additions & 0 deletions python/2dof_scripts/circle_fxn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import math

radius = 10 #radius of the circle

parameters = []


for t in range(0,361):
theta=math.radians(t)
time = t/100 #in seconds
x =round(radius*math.cos(theta),4)
y= round(radius*math.sin(theta),4)
parameters.append((x,y,t,time))


print(parameters)

18 changes: 18 additions & 0 deletions python/2dof_scripts/ikine_fb0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import math

l1=20
l2=40

#assigningt he co-ordinates of the end effector
x,y = 0,25

d = math.sqrt(x**2 + y**2)

t = math.atan(x/y) #slope

#using cosine rule
t_eff = math.acos((l1**2 + d**2 - l2**2)/(2*l1*d))

t1,t2 = abs(t-t_eff),abs(t+t_eff) #compensating shift from reference

print(math.degrees(t1),math.degrees(t2))
38 changes: 38 additions & 0 deletions python/2dof_scripts/tracing_circle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import math

r = 10 #radius of the circle
offset = 48



for t in range(0,361):
theta=math.radians(t)
time = t/10 #in seconds
xe =round(r*math.cos(theta),4)
ye= round(r*math.sin(theta),4) + offset
#parameters.append((x,y,t,time))
l1 = 20
l2 = 40
f = 10

d1 = math.sqrt((xe + f )**2 + (ye)**2)
d2 = math.sqrt((xe - f )**2 + (ye)**2)
d = math.sqrt((xe)**2 + (ye)**2)

tx = math.acos(((l1*l1) - (l2*l2) + (d1**2))/(2*l1*d1))
temp = ((l1**2) - (l2**2) + (d2**2))/(2*l1*d1)
print(temp)
ty = math.acos(temp)

te1 = math.acos(((d1**2) + (f**2) - (d**2))/ (2*f*d1))
te2 = math.acos(((d2**2) + (f**2) - (d**2))/ (2*f*d2))

tl = math.radians(90) - (te1 + tx)
tr = te2 + ty - math.radians(90)


print(math.degrees(tl),math.degrees(tr))


#print(parameters)