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

Avnish mini project #55

Open
wants to merge 5 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 22210009 A1.pdf
Binary file not shown.
191 changes: 191 additions & 0 deletions Assign_2.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"3. Postion vector for end effector SCARA."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Position :[10. 0. -3. 1.]\n",
"Jacobian :([[0.0, 10.0, 0.0], [0.0, 5.0, 0.0], [0, 0, 1]], [[0, 0, 1], [0, 0, 1], [0, 0, 1]])\n"
]
}
],
"source": [
"import numpy as np\n",
"from numpy import pi, sin, cos, sqrt, absolute, arccos, arctan, sign\n",
"import matplotlib.pyplot as plt\n",
"a1,a2 = 5,5\n",
"q = input(\"Enter the joint angles in degrees q1,q2 :\")\n",
"d = float(input(\"Enter extension of end-effector :\"))\n",
"ang1,ang2 = float(q.split(\",\")[0]) , float(q.split(\",\")[1])\n",
"q1,q2 = ang1*3.14/180, ang2*3.14/180\n",
"end_pos = [0,0,0,1]\n",
"theta,alpha,dis,a = 0,0,0,0\n",
"dh = [[cos(theta), -sin(theta)*cos(alpha), sin(theta)*sin(alpha), cos(theta)*a],\n",
"[sin(theta), cos(theta)*cos(alpha), -cos(theta)*sin(alpha), sin(theta)*a],\n",
"[0, sin(alpha), cos(alpha),d],\n",
"[0,0,0,1]]\n",
"t = [[cos(q1+q2),sin(q1+q2),0,a1*cos(q1)+a2*cos(q1+q2)],\n",
"[sin(q1+q2),-cos(q1+q2),0,a1*sin(q1)+a2*sin(q1+q2)],\n",
"[0,0,-1,-d],\n",
"[0,0,0,1]]\n",
"res = np.dot(t,end_pos)\n",
"print(\"Position :\" +str(res) )\n",
"z0,z1,z2 =np.array([0,0,1]),np.array([0,0,1]),np.array([0,0,1])\n",
"o,o1,o2,o3 = np.array([0,0,0]),np.array([a1*cos(q1),a1*sin(q1),0]),np.array([a1*cos(q1)+a2*cos(q1+q2),a1*sin(q1)+ a2*sin(q1+q2),0]),np.array([a1*cos(q1)+a2*cos(q1+q2),a1*sin(q1)+ a2*sin(q1+q2),d])\n",
"jacob = [np.transpose(np.cross(z0,o3-o)).tolist(),np.transpose(np.cross(z1,o3-o1)).tolist(),np.transpose(z2).tolist()],[np.transpose(z0).tolist(),np.transpose(z1).tolist(),np.transpose(z2).tolist()]\n",
"print(\"Jacobian :\"+ str(jacob))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"4. Postion vector for end effector Standford."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0. 0. 0.]\n",
"[0. 0. 0.]\n",
"[0.00000000e+00 2.82887083e-20 3.00000000e+00]\n",
"[0.00000000e+00 2.82887083e-20 3.00000000e+00 1.00000000e+00]\n"
]
}
],
"source": [
"import numpy as np\n",
"from numpy import pi, sin, cos, sqrt, absolute, arccos, arctan, sign\n",
"import matplotlib.pyplot as plt\n",
"a1,a2 = 5,5\n",
"q = input(\"Enter the joint angles in degrees q1,q2 :\")\n",
"d = float(input(\"Enter extension of end-effector :\"))\n",
"ang1,ang2 = float(q.split(\",\")[0]) , float(q.split(\",\")[1])\n",
"q1,q2 = ang1*3.14/180, ang2*3.14/180\n",
"end_pos = [0,0,0,1]\n",
"#theta,alpha,dis,a = 0,0,0,0\n",
"def get_dh(theta,alpha,d,a):\n",
" dh = [[cos(theta), -sin(theta)*cos(alpha), sin(theta)*sin(alpha), cos(theta)*a],\n",
" [sin(theta), cos(theta)*cos(alpha), -cos(theta)*sin(alpha), sin(theta)*a],\n",
" [0, sin(alpha), cos(alpha),d],\n",
" [0,0,0,1]]\n",
" return dh\n",
"qs = [q1,q2,0]\n",
"ds = [0,0,d]\n",
"aas = [0,0,0]\n",
"alphas = [-3.14/2,3.14/2,0]\n",
"t = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]\n",
"z0,z1,z2 =np.array([0,0,1]),np.array([0,0,1]),np.array([0,0,1])\n",
"o = [[],[],[]]\n",
"#t = get_dh(qs[0],alphas[0],ds[0],aas[0])\n",
"#print(t)\n",
"for i in range(0,3):\n",
" #t2 = get_dh(qs[i],alphas[i],ds[i],aas[i])\n",
" t = np.dot(t,get_dh(qs[i],alphas[i],ds[i],aas[i]))\n",
" o[i] = np.dot(t,[0,0,0,1])[0:3]\n",
" #print(o[i])\n",
" #print(t)\n",
"res = np.dot(t,end_pos)\n",
"print(res)\n",
"# print([-cos(q1)*sin(q2)*d, sin(q1)*sin(q2)*d, -cos(q2)*d,1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"8,10. Jacobian Matrix"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Jacob :([[-11.156448908138957, 9.335387362109374, 0.0], [-8.657598394923445, 5.004596890082059, 0.0], [-4.328799197461723, 2.5022984450410295, 0.0]], [[0, 0, 1], [0, 0, 1], [0, 0, 1]])\n"
]
}
],
"source": [
"import numpy as np\n",
"from numpy import pi, sin, cos, sqrt, absolute, arccos, arctan, sign\n",
"\n",
"a1,a2,a3 = 5,5,5\n",
"q = input(\"Enter the joint angles in degrees q1,q2,q3 :\")\n",
"\n",
"ang1,ang2,ang3 = float(q.split(\",\")[0]) , float(q.split(\",\")[1]),float(q.split(\",\")[2])\n",
"q1,q2,q3 = ang1*3.14/180, ang2*3.14/180,ang3*3.14/180\n",
"end_pos = [0,0,0,1]\n",
"#theta,alpha,dis,a = 0,0,0,0\n",
"def get_dh(theta,alpha,d,a):\n",
" dh = [[cos(theta), -sin(theta)*cos(alpha), sin(theta)*sin(alpha), cos(theta)*a],\n",
" [sin(theta), cos(theta)*cos(alpha), -cos(theta)*sin(alpha), sin(theta)*a],\n",
" [0, sin(alpha), cos(alpha),d],\n",
" [0,0,0,1]]\n",
" return dh\n",
"qs = [q1,q2,q3]\n",
"ds = [0,0,0]\n",
"aas = [a1,a2,a3]\n",
"alphas = [0,0,0]\n",
"t = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]\n",
"z0,z1,z2 =np.array([0,0,1]),np.array([0,0,1]),np.array([0,0,1])\n",
"o = [[],[],[]]\n",
"o0 = [0,0,0]\n",
"for i in range(0,3):\n",
" t = np.dot(t,get_dh(qs[i],alphas[i],ds[i],aas[i]))\n",
" o[i] = np.dot(t,[0,0,0,1])[0:3]\n",
"jacob = [np.transpose(np.cross(z0,o[2]-o0)).tolist(),np.transpose(np.cross(z1,o[2]-o[0])).tolist(),np.transpose(np.cross(z1,o[2]-o[1])).tolist()],[np.transpose(z0).tolist(),np.transpose(z1).tolist(),np.transpose(z2).tolist()]\n",
"print(\"Jacob :\" + str(jacob))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.2 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "570feb405e2e27c949193ac68f46852414290d515b0ba6e5d90d076ed2284471"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading