anadi anant jain
Post on 07-Jul-2018
231 Views
Preview:
TRANSCRIPT
-
8/18/2019 Anadi Anant Jain
1/118
NAME: ANADI ANANT JAIN
ROLL NO: 2K12/EC/024
REGN. NO: DTU/12/1224
GROUP-D2
-
8/18/2019 Anadi Anant Jain
2/118
1
-
8/18/2019 Anadi Anant Jain
3/118
INDE
X
S.no List of Experiments
1 To study various Spatial Descriptions and Transformationsusing Peter Corke Toolbox in MATLA!
" To study t#e $or%ard kinematics of a planar & degree of freedom ''' robot using Peter Corke toolbox
& To study t#e (nverse )inematics of a planar & degree of freedom ''' robot using Peter Corke toolbox
To perform t#e $or%ard )inematics of a & D*$ planarrobot+ Stanford manipulator+ P,MA robot for t#e given D-parameters using
. 'oboanalyser and calculate t#e end e/ector position for agiven set of 0oint values using MATLA and verify t#eresults %it# roboanalyser output!
To perform t#e (nverse )inematics of a & D*$ planar robotfor t#e given
D- parameter using roboanalyser soft%are and verify t#esolutions from t#e MATLA program!
2 To study velocity kinematics for planar &' robot
3 To study t#e $or%ard Dynamics of & D*$ &' robot usingPeter Corke toolbox!
4 To study Computer 5ision toolbox
6 To study )alman $ilter using MATLA
17 To study *b0ect Tracking using *ptical $lo%!
Page
DateNo.
&
17
14
"&
"6
&&
&3
.1
2&
26
Attendance(Out of 10 classes) Internal Assessment Marks Instructor’s Signature
-
8/18/2019 Anadi Anant Jain
4/118
"
-
8/18/2019 Anadi Anant Jain
5/118
Experiment 1
Aim: To study various spatial descriptions and transformations
using Pete r Corke toolbox in Matlab!
88T1 9 se":1+ "+ &7;pi(t represents a translation of :1+ "= and a rotation of &7?%!r!t %orld frame T1 9
7!4227 @7!777 1!77777!7777!4227 "!7777
7 7 1!7777
88trplot":T1+ frame+ 1+ color+ b+ axis+ B7 7 =>T#is option specify t#at t#e label for t#e frame is E1F and it is coloredblue
88#old on88T" 9se":"+ 1+ 7=
T" 9
1 7 "7 1 17 7 1
88trplot":T"+ frame+ "+ color+ r+ axis+ B7 7 =
88#old on>Go% displacement of :"+ 1= #as b een applied %it#respect to frame E1F 88T& 9 T1;T"
T& 9
7!4227
@7!777
"!"&"1
7!777
7!4227
&!4227
7 7 1!777788trplot":T&+ frame+ &+ color+ g+axis+ B7 7 = 88#old on>T#e non@commutativity of composition iss#o%n belo% 88T. 9 T";T1
T. 9
-
8/18/2019 Anadi Anant Jain
6/118
&
-
8/18/2019 Anadi Anant Jain
7/118
7!4227 @7!777 &!77777!7777!4227 &!7777
7 7 1!777788trplot":T.+ frame+ .+ color+ c+ axis+ B7 7 =
(a) (i),sing a HIH+ alp#a+ beta+ gam ma+ Juler angle convention+ %rites a Matlabprogra m t#e rotation matrix A R B %#en t#e user enters Juler angles alp#a+ beta+and gamma! J!g! K 9 17+ 9 "7+ 9 &7! Also demonstrate t#e inverse prop erty of rotational matrix %#ic# is B R A
A R B 1 9 : A R B =!
Code:
88 dr 9 piConverting angle in degree to radian
beta 9 ang:"=;drgamma 9 ang:&=;dr TN 9 rotN:alp#a= > 'otate a bout N@axis by angle alp#a Ty 9 roty:beta= > 'otate a bout current y@axis by angle beta Tx 9 rotN:gamma= >'otate about current N@axis by angle gamma'mult 9 TN;Ty;Tx >'esultan t 'otational matrix
Trpy 9 eul"tr:alp#a+beta+gamma= >C#anging euler angle totranslational matrix enter alp#a+ beta and gamma in degreesB17 "7&788 TN
.
-
8/18/2019 Anadi Anant Jain
8/118
TN 97!64.4 @7!13&2 77!13&27!64.4 7
7 7 1!7777
> Tx Tx 97!4227
@7!777 7
7!777 7!4227 7
7 71!777
7
88 Ty Ty 9
7!6&63 7 7!&."7
71!777
7 7@7!&."7 7
7!6&63
88'mult'mult9
7!31.2@
7!21&1 7!&&24
7!2&&3
7!331
& 7!76.@7!"62" 7!1317 7!6&63
88 Trpy Trpy9
7!31.2@
7!21&1 7!&&24 7
7!2&&37!331& 7!76. 7
@7!"62" 7!1317 7!6&63 7
7 7 7 1!777788'19inv:'mult=
> A R B 1 (nverse 'otational
matrix
'1 9
7!31.27!2&&3
@7!"62"
@7!21&
7!331& 7!1317
-
8/18/2019 Anadi Anant Jain
9/118
1
7!&&247!76. 7!6&63
88'"9'mult!
> ( A R B )' (nverse 'otational
matrix
'" 9
7!31.27!2&&3
@7!"62"
@7!21&1 7!331& 7!1317
7!&&247!76. 7!6&63
ii)Orite a Matlab program to calculate t#e Juler angles K+ + %#ent#e user enters t#e rotation matrix i!e! A R B !
88 ang 9 tr"eul:Trpy= > C#anging translational matrix to euler angle
-
8/18/2019 Anadi Anant Jain
10/118
ang 97!13.7!&.61 7!"&2
88ang 'otate about current y@axis byangle beta1 Pa 9 Ty;:Pb=
enter beta in degree"7
enter Pb column %iseB1
7 1
Pa 9
1!"4137
7!633
(b)(i) Write a Matlab program to calculate the homogenous transformation matrix AT B when the user
enters ZYX Juler angles K+ + and the position vector A P B . Test with case K =1! ="! =# and A
P B = $1 " #%&.
88 D'9pi
-
8/18/2019 Anadi Anant Jain
11/118
7!&1447!4"&"@
7!.264 7@
7!"7.67!.&4 7!41&4 77 77 1!7777
> Tba
Tba 9
7!6".
@7!12&" 7!&."7
1!7777
7!&144
7!4"&"
@7!.264
"!7777
@7!"7.6 7!.&4 7!41&4
&!7777
7 7 7 1!7777
(ii)'or =" ()=! =*! A P B is $# 1%& and
B P = $1 1%&. +se Matlab to calculate
A P .
Pb 9 input:enter Pb column %ise=Pa 9
Tba;BPb1 >Calculating A P using AT B and
B P
Ttrn1 9 transl:&+7+1=
Tba1 9rpy"tr:7+"7;D'+7= Tba" 9 Ttrn1;Tba1enter Pb column %iseB1 7 1
Ttrn19
1 7 7 &7 1 7 77 7 1 17 7 7 1
Tba"9
7!6&63 77!&."
7 &!7777
71!777
7 7 7@7!&."7 77!6&63 1!7777
7 77 1!7777
(iii) Orite a Matlab program to calculate t#e inverse #omogenous transformation
matrix i!e! BT A A T B
1 !
-
8/18/2019 Anadi Anant Jain
12/118
Also s#o%t#at AT
B
and AT 1 9 I 4 B
88 Tbainv9inv:Tba= eye:.=@ Tba;Tbainveye:.=@ Tbainv;Tba
3
-
8/18/2019 Anadi Anant Jain
13/118
ans 91!7e@1;
7 7 7!7@
7!1117@
7!7"34 7 7 7@7!7 7!1117 7 7
7 7 7 7
ans 91!7e@1;
7@7!7 7!74&&
@7!111
7@7!71&6 7
@7!7 7
7!74&&7!7 7 77 7 7 7
(c)Write a matlab program to calculate AT C and C T A given the fact that
AT B and
B T C are obtained from part a. ,efine
AT B to be the result from part (a* and
B T C from part b.
> angs"9input:enter alp#a"+ beta"+gamma"= alp#a"9angs":1=;D'beta"9angs":"=;D'gamma"9angs":&=;D'Pcb9input:enter Pcb valuecolumn%ise= Trpy" 9rpy"tr:gamma"+ beta"+alp#a"=
Ttrn"9 transl:Pcb= Tcb 9 Ttrn" ; Trpy" Tca 9 Tba ; Tcb Tac9inv:Tcb=;inv:Tba= Tac"9inv:Tca=
Tba"9Tca;inv:Tcb= Tcb"9inv:Tba=; Tcaenter alp#a"+ beta"+gamma"B17 "7 &7 enter Pcbvalue column%iseB1 " &> Tca Tca 9
7!3&.& @7!766& 7!231 "!2"1
-
8/18/2019 Anadi Anant Jain
14/118
7!2&3 7!&371 @7!2271"!2 @7!14"6 7!6"&37!&&23 2!&"."
7 77 1!7777
> Tac Tac 9
4
-
8/18/2019 Anadi Anant Jain
15/118
7!3&.& 7!2&3 @7!14"6@"!..1& @7!766& 7!&3717!6"&3 @2!"2 7!231@7!2271 7!&&23 @"!"71
7 77 1!7777
> Tac" Tac" 9
7!3&.& 7!2&3 @7!14"6@"!..1& @7!766& 7!&3717!6"&3 @2!"2 7!231@7!2271 7!&&23 @"!"71
7 77 1!7777
> Tcb" Tcb" 9
7!6". @7!12&"
7!&."71!77777!&144 7!4"&" @7!.264"!7777 @7!"7.6 7!.&47!41&4 &!7777
7 77 1!7777
> Tba" Tba" 9
7!6". @7!12&"7!&."71!7777
7!&144 7!4"&" @7!.264"!7777 @7!"7.6 7!.&47!41&4 &!7777
7 7 7 1!7777
-
8/18/2019 Anadi Anant Jain
16/118
6
-
8/18/2019 Anadi Anant Jain
17/118
Experiment 2
AimQ Orite do%n a Matlab program for t#e planar &@Degree of freedom '''robot %it# t#e
follo%ing parameters L1 9 .m+ L"9&m+ L& 9 "m!To derive t#efor%ard kinematics i!e!
7 T&+ %it#
t#efollo%ing input casesQ9 B7 7 7
T
9 B17 "7 &7 T
9 B67 67 67
-
8/18/2019 Anadi Anant Jain
18/118
17
-
8/18/2019 Anadi Anant Jain
19/118
11
-
8/18/2019 Anadi Anant Jain
20/118
88 L!A:7!=> obtain transformation matrix for t#eta 9 7!radian
ans 97!4332 @7!7777 7!.36. 7!13
7!.36.7!777
7 @7!4332 7!766
71!77777!7777 7!1777
7 7 7 1!777788L!'P
> gets type of 0oint+ ' represent 'evolute 0oint
ans 9'
88 L!a > gets link lengt#ans 9
7!"77788 L!o/set 97! > specify t#eta in advance i!e! 7! rad88L!A:7= > get transformation matrix no%
ans 9> produces same matrix as above as link o/set %asspeciRed initiaily
7!4332 @7!7777 7!.36. 7!13
7!.36.7!777
7 @7!4332 7!766
71!77777!7777 7!1777
7 7 7 1!7777L:1= 9 Link:B7 7 17= > create L:1= Link ob0ectL 9
t#eta9+ d97+
a9 1+ alp#a9 7 :'+stdD-=88 L:"= 9 Link:B7 71 7= > create L:"= Link ob0ectL 9
t#eta91+d9 7+ a9
1+alp#a9 7 :'+stdD-=
t#eta9"+d9 7+ a9 1+alp#a9 7 :'+stdD-=88 t%olink 9 SerialLink:L+ name+t%o link=
> Serial@link robot class represents a serial@link arm@
type robot!t%olink 9t%o link :" axis+ ''+ stdD-+slo%'GJ=
T@@@T@@@@@@@@@@@ T@@@@@@@@@@@ T@@@@@@@@@@@
T@@@@@@@@@@@
U 0 U t#eta U d U a Ualp#aU
-
8/18/2019 Anadi Anant Jain
21/118
T@@@T@@@@@@@@@@@ T@@@@@@@@@@@ T@@@@@@@@@@@
T@@@@@@@@@@@
U 1U 1U 7U 1U 7UU "U "U 7U 1U 7U
T@@@T@@@@@@@@@@@ T@@@@@@@@@@@ T@@@@@@@@@@@
T@@@@@@@@@@@
grav 97 base 9 1 7 7 7 tool 9 17 7 7
> grav speciRes t#at gravity %ill be applied inN direction
7 7 1 7 7 7 1 7 7 > base speciRes t#e initial position of robot6!41 7 7 1 7 7 7 1 7 > tool speciRes t#e end e/ector direction
7 7 71 7 7 7 1
88mdlt%olink > script to directly produce a t%o link robott%olink9t%o link :" axis+ ''+ stdD-+slo%'GJ= from Spong+-utc#inson+ 5idyasagar
1"
-
8/18/2019 Anadi Anant Jain
22/118
@@@T@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@ U 0 U t#eta U d U a U alp#a U@@@ T@@@@@@@@@@@
@@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@
U 1U 1U 7U 1U 7UU "U "U 7U 1U 7U@@@ T@@@@@@@@@@@
@@@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@
grav 9 7 base 9 1 7 7 7 tool 9 1 7 7 7
77 1 77 7 1 7 7
6!417 7 17 7 7 1 7
7 7 7 1 7 7 7 188
t%olink!n> get number of links inrobot
ans 9
"
88 links 9t%olink!links links9
t#eta91+d9
t#eta9"+d9
7+
a9
7+
a9
> get link information
1+ alp#a9 7 :'+stdD-=1+ alp#a9 7 :'+stdD-=
88 t%olink!fkine:B7 7= > fkine gives t#e pose :.x.= of t#e robot end@e/ector as a #omogeneous transformation
ans9
1 7 7 "7 1 7 77 7 1 7
7 7 7 1
> t%olink!fkine:Bpi for t#eta 9 B7 7 T
-
8/18/2019 Anadi Anant Jain
23/118
1&
-
8/18/2019 Anadi Anant Jain
24/118
88 t%olink!plot:Bpi
-
8/18/2019 Anadi Anant Jain
25/118
9 7 7 77 7 1 7 7 7 1 7 7
6!41 7 7 1 7 7 7 1 77 7 7 1 7 7 7 1
1.
-
8/18/2019 Anadi Anant Jain
26/118
88p27!plot:N=
88p27!plot:r=
88p27!plot:s=
88p27!plot:n=
-
8/18/2019 Anadi Anant Jain
27/118
1
-
8/18/2019 Anadi Anant Jain
28/118
Code:88 :1= 9 Link:B7 7. 7= 9
t#eta9+ d97+a9 7+ alp#a9
7:'+stdD-=
88 :"= 9 Link:B7 7& 7= 9
t#eta91+d9
7+a9 7+ alp#a9
7:'+stdD-=
t#eta9"+d9
7+a9 .+ alp#a9
7:'+stdD-=
88 :&= 9 Link:B7 7" 7=
9
t#eta91+d9
7+a9 .+ alp#a9
7:'+stdD-=
t#eta9"+d9
7+a9 &+ alp#a9
7:'+stdD-=
t#eta9&+d9
7+a9 "+ alp#a9
7:'+stdD-=
88 S)M 9 SerialLink:+ name+myot=
S)M 9 Tinku :& axis+ '''+ stdD-+slo%'GJ=
T@@@ T@@@@@@@@@@@ @@@@@@@@@@@T@@@@@@@@@@@
@@@@@@@@@@@ T
U 0 U t#eta U d U a U alp#a U
T@@@ T@@@@@@@@@@@ T@@@@@@@@@@@T@@@@@@@@@
@@
@@@@@@@@@@@ T
U 1U 1U 7U .U 7UU "U "U 7U &U 7UU &U &U 7U "U 7U
T@@@ T@@@@@@@@@@@T@@@@@@@@@
@@
T@@@@@@@@@
@@
@@@@@@@@@@
@ Tgrav9
7 base 9 1 7 7 7 tool 9 1 7 77
7 7 1 7 7 7 1 7 7
6!41 7 7 1 77 7 1
77 7 7 1 7 7 7 1
> dr 9 pi 1 9 B7 7 7;dr1 9
7 7 7
-
8/18/2019 Anadi Anant Jain
29/118
> " 9 B17 "7 &7;dr" 9
7!13. 7!&.61 7!"&2> & 9 B67 67 67;dr& 9
1!3741!374
1!37
4 T&71 9S)M!fkine:1=
T&719
1 7 7 67 1 7 77 7 1 7
7 7 7 1
88 T&7" 9 S)M!fkine:"=
T&7"9
7!777 @7!4227 7 3!&3&
12
-
8/18/2019 Anadi Anant Jain
30/118
7!4227 7!777
7&!6"22
7 7 1!7777 77 7 7 1!7777
> T&7& 9 S)M!fkine:&= T&7& 9
@7!7777 1!7777 7
@&!7777
@1!777
7 @7!7777 7"!777
77 7 1!7777 77 7 71!7777
S)M!plot:B7 7 7+ %orkspace+ B@ @ @ =
S)M!plot:B17;dr+ "7;dr+ &7;dr+ %orkspace+ B@ @ @ =
S)M!plot:B67;dr+ 67;dr+ 67;dr+ %orkspace+ B@ @ @ =
-
8/18/2019 Anadi Anant Jain
31/118
13
-
8/18/2019 Anadi Anant Jain
32/118
Experiment
Aim: !o st"d# t$e %n&erse 'inematics of a panar degree offreedom robot "sing Peter Cor*e toobox
!$eor#:We have shown how to determine the pose of the end-eector giventhe joint coordinates and optional tool and base transforms. A problem of real practical interest is the inverse problem: given thedesired pose of the end -effector ξE what are the required jointcoordinates !or e"ample# if we $now the %artesian pose of an object#what joint coordinates does the robot need in order to reach it &his isthe inverse $inematics problem which is written in functional form as
'n general this function is not unique and for some classes ofmanipulator no closed form solution e"ists# necessitating a numerical solution.
> mdlpuma27> n
n 9
7 7!34. &!1.12 7 7!34. 7
88 T 9 p27!fkine:n= > fkine gives t#e pose :.x.= of t#e robot end@e/ector as a #omogeneous transformation
T9@7!7777 7!7777 1!77777!62& @7!7777 1!7777
@7!7777 @7!171 @1!7777@7!7777 @7!7777 @7!71..
7 77 1!7777
> i 9 p27!ikine2s:T= > ikine2s gives t#e 0oint coordinates corresponding to t#erobot end@e/ector
%it# pose T
i 9@7!77777!34.&!1.12&!1.12 @7!34. @&!1.12
88 i 9p27!ikine2s:T=i 9@7!77777!34.&!1.12&!1.12 @7!34. @&!1.12
88
N
N
9
7 7 7 7 7 7
88 T 9 p27!fkine:N=
-
8/18/2019 Anadi Anant Jain
33/118
T 91!7777 7 7 7!."1
14
-
8/18/2019 Anadi Anant Jain
34/118
7 1!7777 7
@7!17
7
7 71!77777!.&1
47 77 1!7777
> i 9 p27!ikine2s:T=i 9
7 1!".6 @&!7.32 @&!1.12 @1!""4 @&!1.12
> N9Bpi i 9 p27!ikine2s:T=OarningQ point notreac#able 8 (nSerialLink!ikine2s at "71
i 9GaG GaG GaG GaG GaG GaG
88 i 9 p27!ikine2s:T+ ru= > gives t#e original set of 0oint angles byspecifying a rig#t #anded conRguration %it# t#e elbo% up
i 9"!2.42 @"!&741 &!1.12 @"!.23& @7!427.
@7!.47 88 p27!plot:i=
88 p27!ikine2s: transl:1+ 7+ 7= = > ,ue to mechanical limits on -oint angles and possible collisions between lins not all eight solutions are ph/sicall/ achievable0 no solution can be achieved
OarningQ point notreac#able 8 (nSerialLink!ikine2s at "71ans 9
-
8/18/2019 Anadi Anant Jain
35/118
GaG GaG GaG GaG GaG GaG
88 p27!ikine2s: transl:7!+ 7!+ 7!= =
16
-
8/18/2019 Anadi Anant Jain
36/118
ans 97!666"7!343& @1!4. &!1.12 @1!74" "!1.".
Code:
Orite do%n a Matlab program to solve planar ''' robot inverse kinematicsproblem #aving t#e lengt# parameters L19.m+ L"9&m+ L&9"m!
$or t#e follo%ing relative pose
:a= 7 T- 9 B1 7 7 6 7 1 7 7 7 7 1 7 7 7 7 1
:b= 7 T- 9 B7! @7!422 7 3!&3& 7!422 7!2 7 &!6"22 7 7 1 7 7 7 7 1
:c= 7 T- 9 B7 1 7 @& @1 7 7 " 7 7 1 7 7 7 7 1
:d= 7 T- 9 B7!422 7! 7 @&!1". @7! 7!422 7 6!123. 7 7 1 7 7 7 7 1
:a= T-79
1 7 7 67 1 7 77 7 1 77 7 7 1
dr 9pi
-
8/18/2019 Anadi Anant Jain
37/118
7 27 7 1!7777 77 77 1!7777
> 1 9 anadi!ikine:T-1+ B7 7 7+ B1 1 7 7 7 1=
matrix not ort#onormal rotation matrix
"7
-
8/18/2019 Anadi Anant Jain
38/118
T-1:1Q&+1Q&=;T-1:1Q&+1Q&= > T#e above can be proved as
ans 9 > for ort#onormal matrix t#e result s#ould be identitymatrix
1!7777 @7!7422 7@7!7422 1!1177 7
7 7 1!7777:c= T-" 9 B7 1 7 @& @1 7 7 " 77 1 7 7 7 7 1 T-" 9
7 1 7 @&@1 7 7 "7 7 1 77 7 7 1
88 S" 9 anadi!ikine:T-"+ B7 7 7C+ B1 17 7 7 1C=
"
9 anadi!ikine:T-"+ B67 @67 67C;dr+B1 1 7 7
71=
"9 " 9
1!374 1!374 1!374 "!434 @1!374 @"!434
88anadi!plot:"= 88anadi!plot:"=
T-& 9
7!4227 7!777 7 @&!1".@7!777 7!4227 7 6!123.
7 7 1!7777 77 77 1!7777
> & 9 anadi!ikine:T-&+ B7 7 7;dr+ B1 17 7 7 1= & 9
1!24" 1!22.6"!.76anadi!fkine:&=ans 9
7!4227 7!777 7 @1!262@7!777 7!4227 7 "!&"6
7 7 1!7777 77 7 7 1!7777
S&
9 anadi!ikine:T-&+ B67 @67 67;dr+ B1 1 77 7 1= >
for di/erent initial estimate
-
8/18/2019 Anadi Anant Jain
39/118
S& 9
"1
-
8/18/2019 Anadi Anant Jain
40/118
1!7e7. ;@"!23.22!.6&" @&!3741
88anadi!fkine:&=
ans 97!4326 7!.474 7 @1!21""
@7!.474 7!4326 7 "!&33"
7 71!777
7 77 7 7 1!7777
S& 9 anadi!ikine:'+ B7 7 7C+ B" 7 77 7 1C=
>for di/erentmask
& 9@"!72 @7!673 "!..6.
88anadi!fkine:&=
ans 97!42277!777 7@&!1".
@7!7777!4227
7@!7"&4
7 7 1!7777 77 7 7 1!7777
88anadi!plot:&=
T#e di/erent result for t#e same post7 T-is due to di/erent usage of (nitial
estimate :X7= and mask
:M=!
-
8/18/2019 Anadi Anant Jain
41/118
""
-
8/18/2019 Anadi Anant Jain
42/118
Experiment +
Aim: !o perform for,ard *inematics of D- panar robot/ Stanfordmanip"ator / p"ma robot for t$e gi&en D0 parameters "sing roboana#er and cac"ate t$e end eectors position for a gi&en set of 3oint &a"es "sing matab and &erif# t$e res"t ,it$ robo ana#er
o"tp"t.
!$eor#:
$or%ard )inematicsQ To determine t#e position and orientation of t#e end@e/ector given t#e values for t#e 0oint variables of t#e robot!
,sing 'oboanalyserQ 'oboAnalyNer is a &D Model ased 'obotics LearningSystem developed using *penT) and 5isual CY!
T#e aboveRgures#ave beensuitably
labeled for proper description! T#e ,( may be explained as follo%sQ
-
8/18/2019 Anadi Anant Jain
43/118
"&
-
8/18/2019 Anadi Anant Jain
44/118
1! (n t#is block+ one can select t#e D*$ and type of robot from tabs providedon t#e far left! T#e center table s#o%s t#e D- parameter for t#e robot!
T#ese can be c#anges as per t#e reuirement!"! -ere . tabs are present! *ne can see a D- paremeter animation for t#e
robot in Z5isualiNe D-[ tab! ZLink ConRg[ and ZJJ ConRg[ gives t#etransformation matrix for a particular link and for base to end@e/ectorrespectively!
&! *nce t#e robot is conRgured+ press t#e Z$)in[ button to completer t#efor%ard kinematic analysis! T#en press t#e play button to vie% t#etra0ectory of robot %it# initial and Rnal position as speciRed in block 1!*ne can also c#ange t#etime duration and no! of steps taken by robot forreac#ing from initial to Rnal position!
.! -ere one can see t#e actual robot+ coordinate axis %!r!t eac# link+ and t#etra0ectory plotted after #itting t#e play button!
! T#is screen is obtained by #itting t#e Z\rap#[ tab on top of t#e screen!-ere one can see t#e variation in position for eac# link separately %it#time and t#e 0oint parameters suc# as 0oint value+ velocity+ accelerationetc!
2! T#is block s#o%s t#e grap# for selected parameter in block !
D- panar robot88 Link
ans 9t#eta9+ d9 7+ a9 7+ alp#a9 7 :'+stdD-=> L:1= 9 Link:B7 7 7!& 7=> L:"= 9 Link:B7 7 7!" pi
-
8/18/2019 Anadi Anant Jain
45/118
grav9
7 base 9 1 7 7 7 tool 9 17 7 7
7 7 1 7 7 7 1 7 76!41 7 7 1 7 7 7 1 7
7 7 7 1 7 7 7 1
88 D'9pi
-
8/18/2019 Anadi Anant Jain
46/118
88 S19B 7 677C; D'
1 9
71!37
4 7
88 T&719fkine:t#reelink+1= T&719
7!7777@7!77771!7777
7!&777
1!7777 7!7777@
7!77777!&77
71!777
7 7!7777 77 7 7 1!7777
Stanford manip"ator
88 Link
ans 9t#eta9+ d9 7+ a9 7+ alp# a9 7 :'+stdD-=> L:1= 9 Link:B7 7!32" 7 @pi L:&= 9 Link:B@pi L:= 9 Link:B7 7 7 @pi
-
8/18/2019 Anadi Anant Jain
47/118
d9 alp#a9 :'+stdD-=t#eta9"+d9 7!&6&.+ a9
7+alp#a9
@1!31:'+stdD-=
t#eta9 @1!31+d9&+ a9
7+alp#a9
7:P+stdD-=
"
-
8/18/2019 Anadi Anant Jain
48/118
t#eta9.+d9
7!""24+a9
7+ alp#a9 @1!31:'+stdD-=
t#eta9+d9 7+ a9
7+alp#a9
@1!31:'+stdD-=
t#eta92+d9
7!.&14+a9
7+alp#a9
7:'+stdD-=
88 Stanlink 9 SerialLink:L+ name+ Stan link=
Stanlink 9Stan link :2 axis+ ''P'''+ stdD-+ slo%'GJ=
T
@@@T
@@@@@@@@@@@
T@@@@@@@@@@@
@@@@@@@@@@@ T
@@@@@@@@@@@
U 0 U t#eta U d U a U alp#a U
T
@@@T
@@@@@@@@@@@
T@@@@@@@@@@@
@@@@@@@@@@@ T
@@@@@@@@@@@
U 1U S1U 7!32"U 7U @1!31U
U "U S"U7!&6&.
U 7U @1!31UU &U @1!31U &U 7U 7U
U .U S.U7!""24
U 7U @1!31UU U SU 7U 7U @1!31U
U 2U S2U7!.&14
U 7U 7U
T
@@@T
@@@@@@@@@@@
T@@@@@@@@@@@
@@@@@@@@@@@ T
@@@@@@@@@@@
grav9
7 base 9 1 7 77 tool 9 1 7 7 7
7 7 1 7 7 7 1 7 7
6!41 7 7 1 7 7 7 1 77 7 7 1 7 7 7 1
88 19B 7 @pi
-
8/18/2019 Anadi Anant Jain
49/118
"2
-
8/18/2019 Anadi Anant Jain
50/118
P"ma robot88 L:1= 9 Link:B7 7!33."1 7 @pi
-
8/18/2019 Anadi Anant Jain
51/118
UT@@@ T
@@@@@@@@@@@
@@@@@@@@@@@
T@@@@@@@@@@@ @@@@@@@@@@@
U 1U 1U 7!33."U 7U @1!31U
U "U "U 7!1712U7!72
2U &!1."U
U &U &U @7!7&41U 7!7"U
@1!31U
U .U .U 7!"24U 7U 1!31U
U U U 7U 7U@1!31U
"3
-
8/18/2019 Anadi Anant Jain
52/118
U 2U S2U 7!74."U 7U 7U
T@@@
T@@@@@@@@@@@
@@@@@@@@@@@
T@@@@@@@@@
@@ @@@@@@@@@@@
grav9
7 base 9 1 77 7 tool 9
1 7 77
77 1 7 7
7 1 7
76!41 7 7 1 7 7 7 1 7
7 7 7 1 7 7 7 188 19B 7 7 7 77 71 9
7 7 7 7 7 788
T2719fkine:Pumalink+S1=
T2719
1!7777 7 7 7!"22
71!777
7 7 7!1&63
7 71!777
7 1!1772
7 7 7 1!7777
-
8/18/2019 Anadi Anant Jain
53/118
"
4
-
8/18/2019 Anadi Anant Jain
54/118
Experiment 4 To perform inverse kinematics of & D*$ planar robot of t#e
given D- parametersAimof$e experiment:
usingroboanalyNer! Derive t#e
analytical expression for t#e inverse kinematics problem of a " D*$ planar robot and
verify t#e solution from Matlab program!
%n&erse 'inematics (%'in) consists of determination of t#e 0oint variablescorresponding to a given end]e/ectors orientation and position! T#e solution tot#is problem is of fundamental importance in order to transform t#e motionspeciRcations assigned to t#e end]e/ector in t#e operational space into t#ecorresponding 0oint space motions! T#ere may be multiple or no results possiblefor a given end]e/ector position and orientation!
23+T425 2' 4645To select a robot and view the solutions of its 4nverse 6inematics! the following are the steps
1. 7lic on 46in button. 4t shows a separate window ('igure 18*". elect a 9obot#. :nter 4nput parameters;. 7lic on 46in buttoning 46in window?. elect an/ of the obtained solution as initial and final solution@. 7lic on 26. This step replaces the initial and final -oint values in ,A Barameter table
Code:
T#e solution may be obtained from Matlab using trigonometric analysis ordirectly from 'oboAnalyNer!
(a) D- panar robot
-
8/18/2019 Anadi Anant Jain
55/118
"6
-
8/18/2019 Anadi Anant Jain
56/118
a19" a"9"a&91
> Gon@Nero constant D-parameters
p#i9pi (nput
%x 9 px @ a&;cos:p#i=%y 9 py@a&;sin:p#i= del9%x;%x
%y;%yc" 9 :del@a1;a1@a";a"=<:";a1;a"=
> Calculation fort#eta"
s" 9 sSrt:1@c";c"=t#"19atan":s"+c"= t#""9atan":@s"+c"=
>Calculation for t#eta1
s119 ::a1a";cos:t#"1==;%y@a";sin:t#"1=;%x=
-
8/18/2019 Anadi Anant Jain
57/118
&7
-
8/18/2019 Anadi Anant Jain
58/118
(b) Artic"ated
> a"91 a&91
88px91py97
pN97
88delxy9px;pxpy;py del9delxypN;pN
> t#119atan":py+px=
> t#1"9piatan":py+px=
> c&9:del@a";a"@a&;a&= t#&19atan":s&+c&= t#&"9atan":@s&+c&=
> s"19:@:a"a&;cos:t#&1==;pN@a&;s&;delxy= c"19::a"a&;cos:t#&1==;delxya&;s&;pN= s""9:@:a"a&;cos:t#&1==;pNa&;s&;delxy= c""9::a"a&;cos:t#&1==;delxy@a&;s&;pN= t#"19atan":s"1+c"1=t#""9atan":s""+c""=
> t#"&9pi@t#"1 t#".9pi@t#""
> r"d9147 t#11d9t#11;r"d
> t#1"d9t#1";r"d
-
8/18/2019 Anadi Anant Jain
59/118
> t#"1d9t#"1;r"d
> t#""d9t#"";r"d
> t#"&d9t#"&;r"d
&1
-
8/18/2019 Anadi Anant Jain
60/118
> t#".d9t#".;r"d
> t#&1d9t#&1;r"d
> t#&"d9t#&";r"
d
> t#11d9t#11;r"d
oboAna#er-"tp"t
-
8/18/2019 Anadi Anant Jain
61/118
&"
-
8/18/2019 Anadi Anant Jain
62/118
Experiment 5
Aim: To study velocity kinematics using Peter Corke tool box!
!$eor#:
6eocit# 'inematics: 5elocity )inematics relates linear and angular
velocities oft#e end@e/ector to t#e 0oint velocities!
88mdlpuma2788 T7 9p27!fkine:n= > obtain transformation matrix
T7 9
@7!77777!7777 1!7777 7!62&
@7!77771!7777 @7!7777@7!171
@1!7777@7!7777 @7!7777@7!71..
7 7 71!777
788d 9 1e@2 > give slig#t disturbance88Tp 9 p27!fkine:n Bd 7 77 7 7=
> obtain ne% transformationmatrix
Tp 9
@7!7777
@7!7777 1!7777 7!62&
@7!7777 1!7777 7!7777 @7!177
@1!7777@7!7777 @7!7777@7!71..
7 7 71!777
788 dTd1 9 :Tp @
T7= < d > obtain t#e di/erentialdTd19
7@
1!7777 @7!7777 7!177
@7!7777
@7!7777 1!7777 7!62&
7 7 7 77 7 7 788 d'd1 9dTd1:1Q&+1Q&=
> get t#e &x& di/erentialrotation matrix
d'd19
7@
1!7777 @7!7777@7!7777 @ 1!7777
-
8/18/2019 Anadi Anant Jain
63/118
7!7777
7 7 788 ' 9
T7:1Q&+ 1Q&=> obtain rotational matrix from
T7
'9
@7!7777 7!7777
1!7777 @7!7777
1!7777 @7!7777
&&
-
8/18/2019 Anadi Anant Jain
64/118
@1!7777 @7!7777 @7!7777
88 S 9 d'd1 ; ' > obtain t#e ske% symmetric matrix
S9
@7!7777 @1!7777 7!7777
1!7777 @7!77777!77777 7 7
88vex:S=
> get vector from symmetricmatrix
ans9@7!7777
7!7777
1!777788 ^ 9p27!0acob7:n=
> get 0acobian %!r!t! %orldcoordinates
^ 9
7!1717!71.. 7!&163 7 7 7
7!62&7!7777 7!7777 7 7 7
7 7!62&7!"617 7 7 7
7 7!77777!7777 7!3731
7!7777 1!7777
7!7777 @1!7777 @1!7777 @7!7777 @1!7777 @7!7777
1!77777!7777
7!7777
@7!3731 7!7777@7!7777
88T 9 transl:1+ 7+7=;troty:pi get ne% 0acobian matrix %!r!t! ne% frame
^ 9
7!7777 7@1!7777 7 1!7777 77 1!7777 7 7 71!7777
1!7777 77!7777 7
@7!7777 7
7 7 7 7!7777 7@
1!7777
-
8/18/2019 Anadi Anant Jain
65/118
7 7 7 71!7777 77 7 7 1!7777 77!7777
88v 9 ^;B1 7 7 7 7 7
88v
ans 9
7!7777 7 1!7777 7 7 7
&.
-
8/18/2019 Anadi Anant Jain
66/118
88p27!0acobn:Sn=
> get 0acobian matrix %!r!t! end@e/ector
ans9
@7!7777 @7!62&@7!"617 7 7 7
7!62& 7!7777 7!7777 7 7 77!177 7!71.. 7!&163 7 7 7
@1!7777 7 77!373
1 7 7
@7!7777@
1!7777@
1!7777@
7!7777
@1!7777 7
@7!7777 7!77777!7777 7!3731
7!7777
1!7777
88p27!0acob7:n+eul=
> get 0acobian matrix for Jularvalues
ans9
7!171 7!71.. 7!&163 7 7 77!62& 7!7777 7!7777 7 7 7
7 7!62&7!"617 7 7 7
1!7777 7!7777 7!7777@7!3731 7!7777
7!7777
7!7777@
1!7777@
1!7777@
7!7777
@1!7777 7
@7!7777 7!77777!7777 7!3731
7!7777
1!7777
To study inverse kinematics and develop a MATLA program using petercoorke toolbox to calculate a 0acobianmatrix for planar &' robot+ given t#e
robots lengt# l19.m+ l"9&m+ l&9"m and initial 0oint angles _ :_1+_"+_&=9B17o+
"7o+&7o!
88L:1= 9 Link:B7 7 . 7 =
88L:"= 9 Link:B7 7 & 7 =
88L:&= 9 Link:B7 7 " 7 =
L 9
t#eta91+d9 7+ a9 .+alp#a9
7
:'+stdD-=
t#eta9"+d9 7+ a9
&+alp#a9
7:'+stdD-=
t#eta9&+d9 7+ a9
"+alp#a9
7:'+stdD-=
88t%olink0acob 9 SerialLink:L+ name+t%olink0acob= t%olink0acob 9t%olink0acob :& axis+ '''+ stdD-+ slo%'GJ=
-
8/18/2019 Anadi Anant Jain
67/118
T
@@@T
@@@@@@@@@@@
@@@@@@@@@@@
@@@@@@@@@@@
@@@@@@@@@@@
U 0 U t#eta U d U a U alp#a U
T
@@@T
@@@@@@@@@@@
@@@@@@@@@@@
@@@@@@@@@@@
@@@@@@@@@@@
U 1U 1U 7U .U 7U
U "U "U 7U &U 7UU &U &U 7U "U 7U
T
@@@T
@@@@@@@@@@@
@@@@@@@@@@@
@@@@@@@@@@@
@@@@@@@@@@@
grav9
7 base 9 1 77 7
tool 9 1 7 77
7 7 1 7 7 7 1 7 76!41 7 7 1 7 7 7 1 7
7 7 71 7 7 7 1
88dr9 pi
-
8/18/2019 Anadi Anant Jain
68/118
dr 97!713
88 7 9 B17 "7 &7;dr7 97!13. 7!&.61
7!"&2
880acobian 9 0acob7:t%olink0acob+ 7= 0acobian 9
@&!6"22 @&!"&"1 @1!3&"13!&3
&&!641
1!7777
7 7 77 7 77 7 7
1!7777
1!7777
1!7777
-
8/18/2019 Anadi Anant Jain
69/118
&2
-
8/18/2019 Anadi Anant Jain
70/118
Experiment 7
AimQ To study for%ard dynamics of a &D*$ of &' robot!
!$eor#:
DynamicsQ'obot dynamics is concerned %it# t#e relations#ip bet%een
t#e forces acting on a robot mec#anism and t#e accelerations t#eyproduce! $or%ard dynamics %orks out t#e accelerations given t#e forces!
88mdlpuma27
X 9 p27!rne:n+ N+N=
>0oint torue reuired for t#e robot ' to ac#ieve t#especiRed 0oint
position X+ velocity XD andacceleration XDD!
X 9@7!777
7
&1!2&6
62!7&1 7!77777!7"4& 7X 9 p27!rne:n+ N+ N+ B7 76!41= > B7 7 6!41 gives t#e gravitational vector
X 9@7!7777
&1!2&662!7&1 7!77777!7"4& 7
B+ 1+ " 9 0tra0:N+r+ 17=
> Compute a 0oint space tra0ectory bet%eent%o points
p27!links:1=!dyn
-
8/18/2019 Anadi Anant Jain
71/118
&3
-
8/18/2019 Anadi Anant Jain
72/118
p27!gravity
> Default gravity assumed bypuma robot
ans 9
7 76!4177
88p27!gravload:n=> TorSue reSuired to maintain t#e robot inposition
ans 9
@7!7777 &1!2&66 2!7&17!7777 7!7"4&
p27!gravity9 p27!gravity 'obot in Ws position
X 9 @7!7777 .2!7726 4!33"" 7!7777 7!7"4& 7
88 X 9 p27!gravload:r=
X 9
7 @7!33" 7!".46 7 7 7
8. To study for%ard dynamics of & D*$ &' robot and develop a MATLAprogram using peter coorke toolbox to calculate t#e for%ard dynamics for
planar &' robot+ given t#e robots parameters as L19.m+ L"9&m+ L&9"m and
m19"7)g+ m"91)g+ m&917)g and 97!)gm"+ 97!")gm"+
97!1)gm"!(gnore gravity by assuming t#at t#e gravity acts in a direction normal to t#eplane of motion! ,sing Peter Coorke toolbox and Matlab commands solve t#efor%ard dynamics problem :i!e! %it# t#eavailable driving 0oint torues an 0oint angles and initial 0oint rates=! Performt#is simulation for .
sec! 9 E + + F 9 E + + F
-
8/18/2019 Anadi Anant Jain
73/118
&4
-
8/18/2019 Anadi Anant Jain
74/118
9 E + + F 9 ` + +
!
F 9> Link1
+ +%it# a9.m+ m9"7kg+ (97!kgm
"L:1=
9 Link:B7 7 . 7 7 "7 "7 7 7 7
7!
7 7 7 7 1 7 7 7=
9 E + +
L:"
=
9 Link:B7 7 & 7 7 1 1! 7 7 7 7 7!" 7 7
7 7 1 7 7 7C=
> Link" %it# a9&m+ m91kg+
(97!"kgm"
L:&=
9 Link:B7 7 " 7 7 17 17 7 7 7
7!1 7 7 7 7 17 77=
> Link& %it# a9"m+ m917kg+
(97!1kgm"
L:1=!md#91 > ,se modiRed D- parameters
L:"=!md#91
L:&=!md#91
t%olinksau 9 SerialLink:L+ name+ t%o linksau=
t%olinksau 9
t%olinksau :& axis+ '''+ stdD-+ slo%'GJ=
T
@@@T
@@@@@@@@@@@
@@@@@@@@@@@
@@@@@@@@@@@
@@@@@@@@@@@
U 0 U t#eta U d U a U alp#a U
T
@@@T
@@@@@@@@@@@
@@@@@@@@@@@
@@@@@@@@@@@
@@@@@@@@@@@
U 1U 1U 7U .U 7UU "U "U 7U &U 7UU &U &U 7U "U 7U
T
@@@T
@@@@@@@@@@@
@@@@@@@@@@@
@@@@@@@@@@@
@@@@@@@@@@@
grav9 7 base 9 1 77 7 tool 9 1 7 777 7 1 7 7 7 1 7 7
6!41 7 7 1 7 7 7 1 77 7 7
1 7 7 7 1
t797 tf9. G9.7 dt9:tf@t7=
-
8/18/2019 Anadi Anant Jain
75/118
&6
-
8/18/2019 Anadi Anant Jain
76/118
.7
-
8/18/2019 Anadi Anant Jain
77/118
Experiment 8
AIM : To study Peter CorkeComputer Vision toolbox
Different Functions and Explanation:
//Spectral Representation of Light//
//define a range of wavelengths//
>>lambda = [300:10:1000]*1e-9; //in this case from 300 to 1 000 nm, and then compute the blackbody spectra// >>forT=1000:1000:6000>>plot( lambda*1e9, blackbody(lambda, T)); hold all >>end
as shown in Fig. 8.1a.
//The filament of tungsten lamp has a temperature of 2 600 K and glows white hot. The Sun has a surfacetemperature of 6 500 K. The spectra of these sourcesare compared in Fig. 8.1b.//
>>lamp = blackbody(lambda, 2600);>>sun = blackbody(lambda, 6500);>>plot(lambda*1e9, [lamp/max(lamp) sun/max(sun)])
//The Sun’s spectrum at ground level on the Earth has been measured and tabulated//
>>sun_ground = loadspectrum(lambda, 'solar.dat');>>plot(lambda*1e9, sun_ground)and is shown in Fig. 8.3a.
.1
-
8/18/2019 Anadi Anant Jain
78/118
AIM: Absorption
> [A, lambda] = loadspectrum([400:10:700]*1e-9,
'water.dat'); //A is the absorption coefficient// > d = 5; // d is the path length//
> T = 10. (̂-A*d);// Transmission T is the inverse of absorption// >>plot(lambda*1e9, T);
which is plotted in Fig. 8.3b.
Reflection
//the reflectivity of a red housebrick// >> [R, lambda] = loadspectrum([100:10:10000]*1e-9, 'redbrick.dat');>>plot(lambda*1e6, R);
."
-
8/18/2019 Anadi Anant Jain
79/118
which is plotted in Fig. 8.4. We see that it reflects red colors more than blue.
//The illuminance of the Sun in the visible region// >>lambda= [400:10:700]*1e-9; % visible spectrum >> E =loadspectrum(lambda, 'solar.dat');
//at ground level. The reflectivity of the brick is// > R = loadspectrum(lambda, 'redbrick.dat'); //andthe light reflected from the brick is// > L = E .* R;>>plot(lambda*1e9, L);
//which is shown in Fig. 8.5. It is this spectrum that is interpreted by our eyes as the color red.//
Color
//The luminosity function is provided by the Toolbox//>>human = luminos(lambda);>>plot(lambda*1e9, human) //andis shown in Fig. 8.6a. //
.&
-
8/18/2019 Anadi Anant Jain
80/118
//The spectral responses of the cones can be loaded and shown in fig 8.7.b// >>cones =loadspectrum(lambda, 'cones.dat');>>plot(lambda*1e9, cones)
Reproducing Colors
// cmfrgb function return the color matching functions//
>>lambda = [400:10:700]*1e-9;
>>cmf = cmfrgb(lambda);>>plot(lambda*1e9, cmf);
.
.
-
8/18/2019 Anadi Anant Jain
81/118
>>orange = cmfrgb(600e-9)// create the sensation of light at 600 nm (orange)// orange =
2.8717 0.3007 -0.0043
>>green = cmfrgb(500e-9)green =-0.2950 0.4906 0.1075
>> w = -green(1);>>white = [w ww ];>>feasible_green = green + whitefeasible_green =0 0.7856 0.4025
>>whitewhite =0.2950 0.2950 0.2950
//The Toolbox function cmfrgbcan also compute the CIE tristimulus for an arbitrary spectralresponse. //
>>RGB_brick = cmfrgb(lambda, L)RGB_brick =0.6137 0.1416 0.0374Chromaticity Space
// The Toolbox function lambda2rg computes the color matching function //
>> [r,g] = lambda2rg( [400:700]*1e-9 );>>plot(r, g)>>rg_addticks
>>primaries = cmfrgb( [700, 546.1, 435.8]*1e-9 );>>plot(primaries(:,1), primaries(:,2), 'd')
.
-
8/18/2019 Anadi Anant Jain
82/118
//chromaticity of the spectral green color//
>>green_cc = lambda2rg(500e-9); green_cc =
-0.9733 1.6187>>plot2(green_cc, 's')
>>white_cc = tristim2cc([1 1 1])//of white color//white_cc =0.3333 0.3333>>plot2(white_cc, '*')
Color Names
>>colorname('?burnt') ans='burntsienna' 'burntumber'
>>colorname('burntsienna') ans=0.5412 0.2118 0.0588
>>bs = colorname('burntsienna', 'xy') bs =
0.5258 0.3840
>>colorname('chocolate', 'xy') ans=0.5092 0.4026
>>colorname([0.54 0.20 0.06]) ans=burntsienna
>>colorname(bs, 'xy')ans ='burntsienna'
Other Color Spaces
//The function colorspacecan be used to perform conversions between different color spaces. //
>>colorspace('RGB->HSV', [1, 0, 0]) ans =
.
2
-
8/18/2019 Anadi Anant Jain
83/118
0 1 1>>colorspace('RGB->HSV', [0, 1, 0]) ans =
120 1 1>>colorspace('RGB->HSV', [0, 0, 1]) ans =
240 1 1 // the saturation is 1, the colors are pure, and the intensity is 1//
>>colorspace('RGB->HSV', [0, 0.5, 0]) ans =
120.0000 1.0000 0.5000 // intensity drops but hue and saturation are unchanged//
// Image Formation //
cam = CentralCamera('focal', 0.015); // creatinga model of a central-perspective camera // >> P = [0.3, 0.4, 3.0]';>>cam.project(P);
ans =0.00150.0020
cam.project(P, 'Tcam', transl(-0.5, 0, 0) ) // moving camera 0.5 m to the left // ans =
0.00400.0020
cam = CentralCamera('focal', 0.015, 'pixel', 10e-6, ... // displa/s the parameters of the imaging modelCC
'resolution', [1280 1024], 'centre', [640 512], 'name', 'mycamera') name:mycamera [central-perspective]focal length: 0.015pixel size: (1e-05, 1e-05)principal pt: (640, 512) numberpixels: 1280 x 1024
.3
-
8/18/2019 Anadi Anant Jain
84/118
T:1 0 0 00 1 0 00 0 1 00 0 0 1>>cam.project(P);ans =
790712
>>cam.Cans =
1.0e+03 *
1.5000 0 0.6400 0
0 1.5000 0.5120 0
0 0 0.0010 0
>>cam.fov() * 180/pi // field of view // ans =
46.2127 37.6930
// we create a 3×
3 grid of points in the xy-plane with overall side length 0.2 m and centred at (0, 0, 1) ,returns 3*9 matrix //
>> P = mkgrid(3, 0.2, 'T', transl(0, 0, 1.0));>>P(:,1:4);ans =
-0.1000 -0.1000 -0.1000 0
-0.1000 0 0.1000 -0.1000
1.0000 1.0000 1.0000 1.0000
>>cam.project(P) // The image plane coordinates of the vertices are //
ans =
490 490 490 640 640 640 790 790 790
362 512 662 362 512 662 362 512 662
>>cam.plot(P) h=
173.0022
.4
-
8/18/2019 Anadi Anant Jain
85/118
>>Tcam = transl(-1,0,0.5)*troty(0.9); // oblique view of the plane // >>cam.plot(P,'Tcam', Tcam)
>>cam.project([1 0 0 0]', 'Tcam', Tcam) ans =
1.0e+03 *
1.8303
0.5120>> p = cam.plot(P, 'Tcam', Tcam)
>>p(:,1:4) // oblique viewing case the image plane coordinates //
ans =
887.7638 887.7638 887.7638 955.2451
364.3330 512.0000 659.6670 374.9050
>>cube = mkcube(0.2, 'T', transl([0, 0, 1]) ); // projection of cube //
>>cam.plot(cube);
>> [X,Y,Z] = mkcube(0.2, 'T', transl([0, 0, 1.0]), 'edge');
>>cam.mesh(X, Y, Z)>>cam.T = transl(-1,0,0.5)*troty(0.8); // oblique view // >>cam.mesh(X,Y, Z, 'Tcam', Tcam);
.6
-
8/18/2019 Anadi Anant Jain
86/118
/ll //// Camera Calibration // // lHomogeneous Transformation Approach //
>> P = mkcube(0.2);>>T_unknown = transl(0.1, 0.2, 1.5) * rpy2tr(0.1, 0.2, 0.3);>>cam = CentralCamera('focal', 0.015, ...'pixel', 10e-6, 'resolution', [1280 1024], 'centre', [512 512], ...'noise', 0.05);
> p = cam.project(P, 'Tobj', T_unknown)> C = camcald(P, p)maxm residual 0.067393 pixels.
C =883.1620 -240.0720 531.4419 612.0432259.3786 994.1921234.8182 712.0180
-0.1043 0.0985 0.6494 1.0000
// lDecomposing the Camera Calibration Matrix //est = invcamcal(C) est=name: invcamcal [central-perspective] focallength: 1504pixel size: (1, 0.9985)principal pt: (518.6, 505)
Tcam:0.93695 -0.29037 0.19446 0.083390.31233 0.94539 -0.093208 -0.39143-0.15677 0.14807 0.97647 -1.46710 0 0 1
>>est.f/est.rho(1) // ratio of estimated parameters of camera // ans =
1.5044e+03
>>cam.f/cam.rho(2) // ratio of true parameters of camera //
ans =
1.500e+03
>>T_unknown*est.T // relative pose between the true and estimated camera pose//
ans =
0.7557 -0.5163 0.4031 -0.0000
0.6037 0.7877 -0.1227 -0.0001
-0.2541 0.3361 0.9069 -0.0041
0 0 0 1.0000
7
-
8/18/2019 Anadi Anant Jain
87/118
>>plot_sphere(P, 0.03, 'r')>>plot_frame(eye(4,4), 'frame', 'T', 'color', 'b', 'length', 0.3)>>est.plot_camera()
// Pose Estimation //
>>cam = CentralCamera('focal', 0.015, 'pixel', 10e-6, ...'resolution', [1280 1024], 'centre', [640 512]); // create acalibrated camera with known parameters//
>> P = mkcube(0.2); // cube determination // >>T_unknown = transl(0,0,2)*trotx(0.1)*troty(0.2) // pose estimation w.r.t camera// T_unknown =
0.9801 0 0.1987 0
0.0198 0.9950 -0.0978 0
-0.1977 0.0998 0.9752 2.0000
0 0 0 1.0000
>> p = cam.project(P, 'Tobj', T_unknown);
>>T_est = cam.estpose(P, p) // estimate relative pose of the object //
T_est =
0.9801 0.0000 0.1987 -0.0000
0.0198 0.9950 -0.0978 -0.0000
-0.1977 0.0998 0.9752 2.0000
0 0 0 1.0000
// lNon-Perspective Imaging Models //
>>cam = FishEyeCamera('name', 'fisheye', ...'projection', 'equiangular', ...'pixel', 10e-6, ...'resolution', [1280 1024]); //creating fishery camera // >> [X,Y,Z] = mkcube(0.2, 'centre', [0.2, 0, 0.3], 'edge'); // creating edge based model //>>cam.mesh(X, Y, Z)
1
-
8/18/2019 Anadi Anant Jain
88/118
l// // lCatadioptric Camera //>>cam = CatadioptricCamera('name', 'panocam', ...'projection', 'equiangular', ...maxangle',pi/4, ... 'pixel', 10e-6,... 'resolution', [1280 1024])>> [X,Y,Z] = mkcube(1, 'centre', [1, 1, 0.8], 'edge');>>cam.mesh(X, Y, Z)
// spherical camera //
>>cam = SphericalCamera('name', 'spherical')>> [X,Y,Z] = mkcube(1, 'centre', [2, 3, 1], 'edge');>>cam.mesh(X, Y, Z)
// lMapping Wide-Angle Images to the Sphere //>>fisheye = iread('fisheye_target.png', 'double', 'grey');> u0 = 528.1214; v0 = 384.0784; // camera calibration parameters // > l=2.7899;> m=996.4617;
"
-
8/18/2019 Anadi Anant Jain
89/118
> [Ui,Vi] = imeshgrid(fisheye); // domain of input image // > n = 500;>>theta_range = (0:n)/n*pi/2 + pi/2;>>phi_range = (-n:2:n)/n*pi;> [Phi,Theta] = meshgrid(phi_range, theta_range); // n is no of grid cells // > r = (l+m)*sin(Theta) ./ (l+cos(Theta));>> U = r.*cos(Phi) + u0; // Cartesian coordinates in the input image // >> V =r.*sin(Phi) + v0;>>spherical = interp2(Ui, Vi, fisheye, U, V); // applying wrap //>>idisp(spherical)
// lSynthetic Perspective Images //
>> W = 1000;
>> m = W / 2 / tan(45/2*pi/180) // 45 fied of view // m =
1.2071e+03> l = 0;> u0 = W/2; v0 = W/2;>> [Uo,Vo] = meshgrid(0:W-1, 0:W-1); // The domain of the output image // >> r =sqrt((Uo-u0).̂ 2 + (Vo-v0).^2); // polar coordinates // >>phi = atan2((Vo-v0), (Uo-u0)); >>Phi_o =phi; // spherical coordinates // >>Theta_o = pi - acos( ((l+m)*sqrt(r.^2*(1-l^2) + (l+m)^2) -l*r.^2) ./ (r.^2 + (l+m)^2) );>>idisp(perspective)>>spherical = sphere_rotate(spherical, troty(1.2)*trotz(-1.5));
&
-
8/18/2019 Anadi Anant Jain
90/118
1 Obtaing an image from a file
The toolbox consist of iread function to read an image
>>street = iread('street.png'); % Which returns a matrix
>>about(street) % Gives details related to street
street [uint8] : 851x1280 (1089280 bytes)
>>street(200,300) % The pixel at image coordinate (300,200)
ans =
42
>>street_d = idouble(street); % double precision number in the range [0, 1].>>about(street_d)>>street_d [double] : 851x1280 (8714240 bytes)
>>street_d = iread('street.png', 'double'); % specify this as an option whileloading>>idisp(street); % to display an image is idisp
.
-
8/18/2019 Anadi Anant Jain
91/118
>>flowers = iread('flowers8.png');>>about(flowers)flowers [uint8] : 426x640x3 (817920 bytes)
>>pix = flowers(276,318,:) %pixel at (318, 276)ans(:,:,1) =57 ans(:,:,2)= 91ans(:,:,3) =198
% The pixel value is
-
8/18/2019 Anadi Anant Jain
92/118
>>idisp( flowers(:,:,1) )
2 Images from an Attached Camera
Most laptop computers today have a builtin camera for video conferencing. For computerswithout a builtin camera an external camera can be easily attached via a USB. The meansof accessing a camera is operating system specificand the Toolbox provides a simple interface to a camera for MacOS, Linux and Windows.
% A list of all attached cameras and their capability can be obtained by>>VideoCamera('?')% We open a particular camera>>cam = VideoCamera('name')% which returns an instance of a VideoCamera object that is a subclass of the%ImageSource class.% The dimensions of the image returned by the camera are given by the size method
>>cam.size()% an image is obtained using the grab method
2
-
8/18/2019 Anadi Anant Jain
93/118
>>im = cam.grab();% which waits until the next frame becomes available.
3 Images from a Movie File
The Toolbox supports reading frames from a movie file stored in any of the popular
formats such as AVI, MPEG and MPEG4. For example we can open a movie file>>cam = Movie('traffic_sequence.mpg'); 720x 576 @ 2.999970e+01 fps350 frames
%This movie has 350 frames and was captured at 30 frames per second.
%The size of each frame within the movie is>>cam.size()ans =720 576% and the next frame is read from the movie file by >>im= cam.grab();>>about(im)
im [uint8] : 576x720x3 (1244160 bytes)% which is a 720 × 576 color image.
% With these few primitives we can write a very simple movie player 1 while12 im = cam.grab;3 if isempty(im), break; end4 image(im)5 end%where the test at line 3 is to detect the end of file, in which case grab returns an emptymatrix.
4 Images from Code
% The Toolbox function testpattern generates simple images with a variety of patterns
including lines, grids of dots or squares, intensity ramps and intensity sinusoids.
>>im = testpattern('rampx', 256, 2);>>im = testpattern('siny', 256, 2);>>im = testpattern('squares', 256, 50, 25);
3
-
8/18/2019 Anadi Anant Jain
94/118
>>im = testpattern('dots', 256, 256, 100);
We can also construct an image from simple graphical primitives. First we create a
blank canvascontaining all black pixels (pixel value of zero)
>>canvas = zeros(200, 200);
% then we create two squares> sq1 = 0.5 * ones(40, 40);> sq2 = 0.9 * ones(20, 20);The first has pixel values of 0.5 (medium grey) and is 40× 40. The second is smaller(just 20× 20) but brighter with pixel values of 0.9. Now we can paste these onto thecanvas>>canvas = ipaste(canvas, sq1, [20, 40]);>>canvas = ipaste(canvas, sq2, [60, 120]);>>circle = 0.6 * kcircle(30);%of radius 30 pixels with a grey value of 0.6.>>size(circle)ans =61 61
4
-
8/18/2019 Anadi Anant Jain
95/118
>>canvas = ipaste(canvas, circle, [100, 30]); %Finally, wedraw a line segment onto our canvas >>canvas =iline( canvas, [30, 40], [150, 190], 0.8);%which extends from (30, 40) to (150, 190) and its pixels are all set to 0.8.>>idisp(canvas)
5 Monadic Operations
Monadic image-processing operations result in an image of the same size W × H as the
input image, and each output pixel is a function of the corresponding input pixel.
Since an image is represented by a matrix any MATLAB® element -wise matrix functionor operator can be applied, for example scalar multiplication or addition, or functions suchabs or sqrt.The datatype of each pixel can be changed, for example from uint8 (integer pixels
in the range [0, 255]) to double precision values in the range [0, 1] >>imd =idouble(im);>>im = iint(imd);
A color image has 3-dimensions which we can also consider as a 2-dimensional imagewhere each pixel value is a 3-vector.
6
-
8/18/2019 Anadi Anant Jain
96/118
A monadic operation can convert a color image to a greyscale image where each output
pixel value is a scalar representing the luminance of the corresponding input pixel
>>grey = imono(flowers);The inverse operation is>>color = icolor(grey);
% the histogram of the street scene is computed and displayed by>>ihist( street )
>> [n,v] = ihist(street);
%where the elements of n are the number of times pixels occur with the value of %thecorresponding element of v.
>>ihist(street, 'cdf');
27
-
8/18/2019 Anadi Anant Jain
97/118
%The Toolbox function peak will automatically find the peaks>>peak(n, v)'ans =8 40 43 51 197 17 60 26 75 21388 92 218 176 153 108 111 147 113 119121 126 130 138 230 244
We can identify the pixels in
this peak by a logical monadic operation>>shadows = (street >= 30) & (street>idisp(shadows)
>>im = istretch(street);% ensures that pixel values span the full range_ which is either [0, 1] or [0, 255]
%A more sophisticated version is histogram normalization or histogramequalization>>im = inormhist(street);
%Such images can be gamma decoded by a non-linear monadic operation >>im =igamma(street, 1/0.45);which raises each pixel to the specified power, or >>im= igamma(street, 'sRGB');>>idisp( street/64 )
21
-
8/18/2019 Anadi Anant Jain
98/118
2"
-
8/18/2019 Anadi Anant Jain
99/118
Experiment 9
A%: !o st"d# -b3ect trac*ing "sing 'aman ;ter "sing matab.
!$eor#Q
T#e )alman Rlter keeps track of t#ee estimated state of t#e system and t#e
variance or uncertainty of t#e estimate! T#e estimate is updated using a state transition model and measurements! denotes t#e estimate of t#e syste ms state at time step k before t#e
k@t# measurem ent Nk #as been
taken into account is t#e corresponding uncertainty!
T#e )alman Rlter+ also kno%n as linnear uadratic estimation :LXJ=+ is an algorit#mt#a t uses a series of measurements observed over time+ containing noise :randomvariations= and ot#e r inaccuracies+ and produces estimates of unkno% n variablest#at tend to be more precise t#an t#o se based on a single measurement alone!More f ormally+ t#e )alman Rlter operates recursively on streams of noisy input datato produce a statistically optimal estimate of t#e underlying system state!
T#e algorit#m %orks in a t%o@st ep process! (n t#e prediction step+ t#e )almanRlter produces estimates of t#e current state variables+ along %it# t#eiruncertainties! *nce t#e outcome of t#e next measurement :necessarilycorrupted %it# some amount of error+ including ra ndom noise= is observed+t#ese estimates are updated using a %eig#ted average+ %it# more %eig#t beinggiven to estimates %it# #ig#er certainty! ecause of t#e algorit#ms recursivenature+ it can run in real time using only t#e present inpu t measurements andt#e previously calculated state and its uncertainty matrix no additional p astinformation is reuired!
)alman Rlter algorit#m
State model predictioneuation Pred 9 A; !;a
Prediction of state model covar iance
statePredCov 9 A;stateCov;A
prcGoise5ar
Prediction of observation mode l
covariance obsCov 9
C;statePredCov;C obsGoise5ar
Determine )alman gain
kal\ain 9 statePredCov ; C ; :obsCov=:@1=*bservation vector
prediction NPred 9C;Pred
NJrror 9 N @ NPredState estimation euation
Jst 9 Pred kal\ain ;
NJrror
Jstimated state covariance
stateCov 9 :eye:.= @ kal\ain ; C= ; statePredCov
-
8/18/2019 Anadi Anant Jain
100/118
C-DE:
2&
-
8/18/2019 Anadi Anant Jain
101/118
%ob0ect tracking using
kalman Rlter close all
%clear %orkspace
clear
all clc> read a video
vid*b0ect 9
5ideo'eader:car@"!avi= >
determine no! frames
n$rames 9 vid*b0ect!Gumber*f$rames
%detremine lengt# and %idt#
of frame len 9
vid*b0ect!-eig#t
%id 9 vid*b0ect!Oidt#
sum$rame 9 Neros:len+
%id=
%kalman Rlter variables
dt 9 7!1> time bet%een "
frames > initialiNe state
model matrix
A 9 B1 7 dt 7 7 1 7 dt7 7 1 77 7 7 1
9 Bdt"
-
8/18/2019 Anadi Anant Jain
102/118
:dt&
-
8/18/2019 Anadi Anant Jain
103/118
% iteration only
stateCov 9
prcGoise5ar
statePredCov 9 Neros:.+.=> state prediction
covariance obsGoise 9 B7!71 7!71 > noisein observation model
%variance of observation model noise+noise is gaussian innature and #ave
%Nero mean
obsGoise5ar 9 BobsGoise:1=" 77 obsGoise:"="
obsCov 9 B7 7 7 7 > initialiNe observation modelcovariance
%state vector consist of position and
velocity of ob0ect 9 B7 7 7 7
Pred 9 B7 7 7 7 > predicted
state vector Jst 9 B7 7 7 7 >
estimated state vector
N 9 B7 7 > observation vector i!e sensor
data:position of ob0ect= NPred 9 B7 7 > predicted
observation vector
%cnd is Nero till ob0ect is not detected for t#e Rrst time!
cnd 9 7
bboxPred 9
Neros:1+.=
bboxJst 9
Neros:1+.= box 9
Neros:&+.= absent
9 7
for k 9 1 Q n$rames
% read frames from
video frame 9
read:vid*b0ect+k=
gray$rame 9
rgb"gray:frame=
sum$rame 9 sum$rame double:gray$rame=
-
8/18/2019 Anadi Anant Jain
104/118
% background obtained by averaging
sum of frames background 9
:sum$rame !< k=
ob0ect 9 false:len+%id=
% binary image consist detected ob0ect obtained bybackground subtraction ob0ect:abs:double:gray$rame= @
background=817= 9 1
% morp#ological operation to remove clutter from binaryimage
ob0ect 9 imopen:ob0ect+strel:suare+&==
2
-
8/18/2019 Anadi Anant Jain
105/118
ob0ect 9
imclose:ob0ect+strel:suare+1"==
ob0ect 9 imRll:ob0ect+#oles=
% determine detected ob0ect siNe
and location blobAnalyser 9vision!lobAnalysis
blobAnalyser!MinimumlobArea 9
177
Barea+centroid+bbox 9
step:blobAnalyser+ ob0ect= if:centroid
9 7=
cnd 9 cnd
1 end% kalman algorit#m
if:cnd 99 1=
% for t#e Rrst time ob0ect detection+ initialiNestate vector
% %it# sensor observation data
:1= 9 centroid:1=
:"= 9
centroid:"=
elseif:cnd8 1=
if:centroid 9 7=
if:absent991=
:1Q"=9centroid:
1Q"= end
end
% state model prediction
euation Pred 9 A; !;a% prediction of state model
covariance statePredCov 9
A;stateCov;A prcGoise5ar
% prediction of observation model
covariance obsCov 9 C;statePredCov;C
obsGoise5ar
% determine kalman gain
-
8/18/2019 Anadi Anant Jain
106/118
kal\ain 9 statePredCov ; C ;
:obsCov=:@1= > observation
vector prediction
NPred 9
C;Pred
if:centroid
9 7=
22
-
8/18/2019 Anadi Anant Jain
107/118
N:1Q"= 9
centroid:1Q"=
NJrror 9 N @
NPred
absent 9 7 > %#en ob0ect ispresent in frame else
absent 9 1 > %#en ob0ect is
absent in frame end
% state estimation
euation Jst 9 Pred
kal\ain ; NJrror
% estimated state covariance
stateCov 9 :eye:.= @ kal\ain ; C= ;statePredCov 9 Jst
if:bbox 9 7=
bboxPred:1Q"= 9 int&":Pred:1Q"==@
:bbox:&Q.==!
-
8/18/2019 Anadi Anant Jain
108/118
frame 9 insertS#ape:frame+ rectangle+ box+ Color+
Eblue+red+greenF= ims#o%:frame=
title:outputQblue+red+green bounded box for
observation+prediction+estimated state= subplot:&+1+"=
23
-
8/18/2019 Anadi Anant Jain
109/118
ims#o%:uint4:background==
title:background=
subplot:&+1+&=
ims#o%:ob0ect=
title:binary image of detectedob0ects=
pause:7!771=
end
close all
-
-
8/18/2019 Anadi Anant Jain
110/118
24
-
8/18/2019 Anadi Anant Jain
111/118
Experiment 1=
A%: !o st"d# -b3ect !rac*ing "sing -ptica o,.
!0E->:
(n optical o%+ motion is estimated as instantaneous image velocities or
discrete image displacements! T#e met#od calculates t#e motion bet%een t%o
video seuences t#at are taken at t%o time instances t and tt at every pixel
position! (t is based on local taylor series approxi mation of image signal i!e! t#ey
used partial derivatives %it# respect to spatial and temporal c#anges!
$or a "D@time dimension video seuence+ a pixel at location :x+ y+ t=
#aving intensity (:x+ y+ t= #ave moved x+ y and t bet%een t#e t%o video
seuenc e! (n t#is %e consider a constrain t#at t#e brig#tness remains
unaltered at di/erent position i!e!
(:x+ y+ t= 9 (:xx + yy + tt=
Assuming t#e movement to be small and using taylor series %e obtain
(:xx + yy + tt= 9 (:x+ y+ t= x y N -ig#er orderterms
T#us from above euation
x y N 9 7
9 7 T#is result in+ 9 7
O#ere and are t#e x and y components of velocity or optical o% of(:x+ y+ t= and +
, are derivatives of video seuence at :x+y+t= in t#e corresponding direction!
Oe can also use derivation of intensity ( and ( as follo% x 9y `
T#e above euation is solved to determine t#e optical o% vectors in t%odirections x and y!
$ig! 1 s#o% t#e simulink model to track a moving ob0ect in a given video! T#e
video used in t#is model is viptrac!avi consisting of moving cars on a roadscenario!
1! T#e initial block is t#e scource block+ %#ic# is used to read a multimedia Rle!
26
-
8/18/2019 Anadi Anant Jain
112/118
"! T#e second block is used to convert t#e '\ values to \rayscaleintensity values!
&! T#e *ptical $lo% block is used to obtain t#e velocity vectors in x and y
direction in complex con0ugate form!
.! T#e fort# block is used t#res#olding to obtain t#e segmented ob0ects in
t#e video and to obtain t#e bounded box!
! T#e display box is used to display t#e original video+ optical o% vectors+t#e segmented ob0ects and t#e bounding box on t#e original video!
As in $ig "! t#e T#res#olding and 'egion $iltering Sub@lock initially obatins t#emagnitude of t#e velocity vector and t#en a t#res#old is computed byaveraging all t#e velocity vectors of t#e frame and using t#is t#res#old image isobtained! T#e image is t#en passed to t#e median Rlter to remove t#e noise int#e image! T#e lob Analysis Toolbox is used on t#is t#res#old image to obtaint#e bounding box of t#e ob0ect as given in $ig &!
As in $ig .!t#e display box consist of . inputsQ input video+ t#res#olded video+optical o% vectors and t#e tracked output result!
T#e input video and t#e t#res#old image is directly displayed! T#e optical o%vectors are passed t#roug# optical o% line function block to give t#edimensions of t#e optical o% vectors! T#ese dimensions are t#en ploted on t#eoriginal video and displayed! T#e bounding box are counted to obtain t#enumber of cars and t#e bounding box is diplayed on t#e original video to obatint#e result!
S%
-
8/18/2019 Anadi Anant Jain
113/118
37
-
8/18/2019 Anadi Anant Jain
114/118
$ig!" T#res#olding and 'egion $ilteringSubblock
$ig!& 'egion $ilteringSubblock
-
8/18/2019 Anadi Anant Jain
115/118
31
-
8/18/2019 Anadi Anant Jain
116/118
$ig!. Display 'esult Subblock
-
3"
-
8/18/2019 Anadi Anant Jain
117/118
(a) (b)
(c) (d)
(e)
$ig! :a= Gt# $rame of t#e video :b=G1t# $rame of t#e video :c= *ptical o%velocity vectors for frame :a= and :b= + :d= T#res#olding for ob0ect detection and:e= *b0ect detection
-
8/18/2019 Anadi Anant Jain
118/118
3&
top related