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

Rajesh kumar #42

Open
wants to merge 16 commits into
base: Rajesh
Choose a base branch
from
Binary file added Assignment - 1/ITR_Assignment-1.pdf
Binary file not shown.
Binary file added Assignment - 2/ITR_Assignment-2.pdf
Binary file not shown.
21 changes: 21 additions & 0 deletions Assignment - 2/Task-10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import numpy as np

l1 = float(input('Length of link 1: '))
l2 = float(input('Length of link 2: '))
l3 = float(input('Length of link 3: '))
q1 = float(input('Angle of link 1: '))
q1 = (q1*np.pi)/180
q2 = float(input('Angle of link 2: '))
q2 = (q2*np.pi)/180
q3 = float(input('Angle of link 3: '))
q3 = (q3*np.pi)/180

J = [[-1*l1*np.sin(q1)-1*l2*np.sin(q1+q2)-1*l3*np.sin(q1+q2+q3), -1*l2*np.sin(q1+q2)-1*l3*np.sin(q1+q2+q3), -1*l3*np.sin(q1+q2+q3)],
[l1*np.cos(q1)+l2*np.cos(q1+q2)+l3*np.cos(q1+q2+q3), l2*np.cos(q1+q2)+l3*np.cos(q1+q2+q3), l3*np.cos(q1+q2+q3)],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[1, 1, 1]]

for i in J:
print(i)
22 changes: 22 additions & 0 deletions Assignment - 2/Task-3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import numpy as np

l1 = float(input('Length of link 1: '))
l2 = float(input('Length of link 2: '))
q1 = float(input('Angle of link 1: '))
q1 = (q1*np.pi)/180
q2 = float(input('Angle of link 2: '))
q2 = (q2*np.pi)/180
q3 = float(input('Displacement of link 3: '))

p3 = [[1], [2], [3], [1]]

H = [[np.cos(q1+q2), -1*np.sin(q1+q2), 0, l1*np.cos(q1)+l2*np.cos(q1+q2)], [np.sin(q1+q2), np.cos(q1+q2), 0, l1*np.sin(q1)+l2*np.sin(q1+q2)],[0, 0, 1, q3], [0, 0, 0, 1]]

p0 = [[0], [0], [0], [0]]
for i in range(len(H)):
for j in range(len(p3[0])):
for k in range(len(p3)):
p0[i][j] += H[i][k]*p3[k][j]

for r in p0:
print(r)
21 changes: 21 additions & 0 deletions Assignment - 2/Task-4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import numpy as np

l2 = float(input('Length of link 2: '))
q1 = float(input('Angle of link 1: '))
q1 = (q1*np.pi)/180
q2 = float(input('Angle of link 2: '))
q2 = (q2*np.pi)/180
q3 = float(input('Displacement of link 3: '))

p3 = [[1], [2], [3], [1]]

H = [[np.cos(q1)*np.cos(q2), -1*np.sin(q1), np.cos(q1)*np.sin(q2), q3*np.cos(q1)*np.sin(q2)-l2*np.sin(q1)], [np.sin(q1)*np.cos(q2), np.cos(q1), np.sin(q1)*np.sin(q2), q3*np.sin(q1)*np.sin(q2)+l2*np.cos(q1)], [-1*np.sin(q2), 0, np.cos(q2), q3*np.cos(q2)], [0, 0, 0, 1]]

p0 = [[0], [0], [0], [0]]
for i in range(len(H)):
for j in range(len(p3[0])):
for k in range(len(p3)):
p0[i][j] += H[i][k]*p3[k][j]

for r in p0:
print(r)
14 changes: 14 additions & 0 deletions Assignment - 2/Task-8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import numpy as np

l1 = float(input('Length of link 1: '))
l2 = float(input('Length of link 2: '))
q1 = float(input('Angle of link 1: '))
q1 = (q1*np.pi)/180
q2 = float(input('Angle of link 2: '))
q2 = (q2*np.pi)/180
q3 = float(input('Displacement of link 3: '))

J = [[-1*l1*np.sin(q1)-1*l2*np.sin(q1+q2), -1*l2*np.sin(q1+q2), 0, 0], [l1*np.cos(q1)+l2*np.cos(q1+q2), l2*np.cos(q1+q2), 0, 0], [0, 0, -1, 0], [0, 0, 0, 0], [0, 0, 0, 0], [1, 1, 0, -1]]

for i in J:
print(i)
Binary file added Mini - Project/Mini-Project_Task-0.pdf
Binary file not shown.
79 changes: 79 additions & 0 deletions Mini - Project/trial1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from cProfile import label
import numpy as np
import math
import matplotlib.pyplot as plt
import matplotlib.animation as anim
import cv2
import scipy
import sympy as sp
import os
import moviepy.video.io.ImageSequenceClip

# Task - 1: End Effoctor following a given trajectory
l1 = 15
l2 = 10
L = l1 + l2

t = 0

while t < 360:
x = 10*math.cos((t*math.pi)/(180))
y = 10*math.sin((t*math.pi)/(180))
filename = str(t) + '.png'
t += 1

if ((x**2)+(y**2)) <= (L**2):
theta = math.acos(((x**2) + (y**2) - (l1**2) - (l2**2))/(2*l1*l2))
q1 = math.atan(y/x) - math.atan((l2*math.sin(theta))/(l1 + l2*math.cos(theta)))
if 90 < t < 180 and q1 < 0:
q1 = math.pi + q1
q2 = q1 + theta

x1 , y1 = [0, l1*math.cos(q1)], [0, l1*math.sin(q1)]
x2 , y2 = [l1*math.cos(q1), l1*math.cos(q1)+l2*math.cos(q2)], [l1*math.sin(q1), l1*math.sin(q1)+l2*math.sin(q2)]
plt.plot(x1, y1, x2, y2)
plt.savefig(filename)
# plt.clf()
# plt.show()


image_folder='images'
fps=15

image_files = [os.path.join(image_folder,img)
for img in os.listdir(image_folder)
if img.endswith(".png")]
clip = moviepy.video.io.ImageSequenceClip.ImageSequenceClip(image_files, fps=fps)
clip.write_videofile('trialsim2.mp4')

# Task - 2: End effoctor arranges itself to apply the required force on the wall

x0 = float(input('x-coordinate of the point of application: '))
y0 = float(input('y-coordinate of the point of application: '))

theta = math.acos(((x0**2) + (y0**2) - (l1**2) - (l2**2))/(2*l1*l2))
q1 = math.atan(y0/x0) - math.atan((l2*math.sin(theta))/(l1 + l2*math.cos(theta)))
q2 = q1 + theta

Fx = float(input('X-component of Force: '))
Fy = float(input('Y-component of Force: '))
Tau_1 = -1*(Fx)*l1*math.sin(q1) + (Fy)*l1*math.cos(q1)
Tau_2 = -1*(Fx)*l2*math.sin(q2) + (Fy)*l2*math.cos(q2)

x1 , y1 = [0, l1*math.cos(q1)], [0, l1*math.sin(q1)]
x2 , y2 = [l1*math.cos(q1), l1*math.cos(q1)+l2*math.cos(q2)], [l1*math.sin(q1), l1*math.sin(q1)+l2*math.sin(q2)]
plt.text(L, L+1, 'Tau_1 = ' + str(Tau_1))
plt.text(L, L, 'Tau_2 = ' + str(Tau_2))
plt.plot(x1, y1, x2, y2)
plt.show()


# Task - 3: End Effector's virtual spring effect

x0 = 10
y0 = 10
k = 50

Fx = k*(x - x0)
Fy = k*(y - y0)