radial basis function approximation

Post on 19-Jan-2016

40 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

Radial basis function approximation. K-mean Algorithm. function y=my_kmeans(X,M) mx =mean(X); Y=rand(M,2)*0.1-0.05+mx; change =1; wh ile change < 10.^-6 D = cross_distances(X,Y) [xx ind]=min(D'); for i=1:K ind2=find(ind == i); Y_new(i,:) = mean( X( ind2,:)); - PowerPoint PPT Presentation

TRANSCRIPT

軟體實作與計算實驗 1

Radial basis function approximation

軟體實作與計算實驗 2

K-mean Algorithm

function y=my_kmeans(X,M)mx=mean(X);Y=rand(M,2)*0.1-0.05+mx;change =1; while change < 10.^-6

D = cross_distances(X,Y)[xx ind]=min(D');

for i=1:K ind2=find(ind == i);

Y_new(i,:) = mean(X( ind2,:)); end change = mean(mean(Y-Y_new));

endreturn

軟體實作與計算實驗 3

Cross_Distance

function D=cross_distance(X,Y)M=size(Y,1);N=size(X,1);A=sum(X.^2,2)*ones(1,M);C=ones(N,1)*sum(Y.^2,2)';B=X*Y';D=sqrt(A-2*B+C);

軟體實作與計算實驗 4

Radial basis function

軟體實作與計算實驗 5

3.141

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=157&objectType=File

軟體實作與計算實驗 6

23 4.89

軟體實作與計算實驗 7

4.23TY

軟體實作與計算實驗 8

2.23TX

軟體實作與計算實驗 9

)2.12,81.8( TT YX

oT 200

軟體實作與計算實驗 10

Forward Kinematics

323

212

11

180

180

2 frame and matlabbetween Angle1802

1 frame and matlabbetween Angle

PP

PP

P

2P

3.141 1P

3P

軟體實作與計算實驗 11

Frame positions

)sin(

)cos(

112

112

Ply

Plx

x position of frame '2'

y position of frame '2'

2P

3.141

1P

3P

1l

),( 22 yx

軟體實作與計算實驗 12

Position of frame 3

)sin(

)cos(

2223

2223

Plyy

Plxx

2P

3.141

1P

3P

1l

),( 22 yx

2l

),( 33 yx

軟體實作與計算實驗 13

Position of tool

2P

3.141

1P

3P

1l

),( 22 yx

2l

),( 33 yxx position of frame 'tool'y position of frame 'tool'

)sin(

)cos(

333

333

Plyy

Plxx

t

t

3l ),( tt yx

軟體實作與計算實驗 14

http://www.learnaboutrobots.com/forwardKinematics.htm

軟體實作與計算實驗 15

Forward Kinematics

Problem statement A schematic of a simple robot lying in the X-Y plane Robot length

Three links of the robot

Given the ang joints, where is the robot's hand?

? 2P

3.141

1P

3P

1l

),(22yx

2l ),(33yx

3l

),(ttyx

1l 2l 3l

2P1P 3P

),( tt yx

軟體實作與計算實驗 16

Forward Kinematics for planar robot

)sin()sin()sin(

)cos()cos()cos(

332211

332211

PlPlPly

PlPlPlx

t

t

2P

1P

3P

1l

3l ),( tt yx

軟體實作與計算實驗 17

223

212

11

180

180

1802

PP

PP

P

)sin()sin()sin(

)cos()cos()cos(

332211

332211

PlPlPly

PlPlPlx

t

t

t

t

yPlPlPlF

xPlPlPlF

)sin()sin()sin(),(

)cos()cos()cos(),(

332211212

332211211

軟體實作與計算實驗 18

Inverse kinematics

At the position level, the problem is stated as, "Given the desired position of the robot's hand, what must be the angles at all of the robots joints? "

軟體實作與計算實驗 19

One link

Given Xt what is the joint angle P

x

Yxt

P

軟體實作與計算實驗 20

x

Yxt

P

l

xP

l

x(P)

Plx

t

t

t

arccos

cos

solutionposition forward

)cos(

軟體實作與計算實驗 21

multiple solutions

l

xP

l

x(P)

Plx

t

t

t

arccos

cos

solutionposition forward

)cos(

o

tx

l

45

71arccos0.70P

feet 7071.0

foot one :

軟體實作與計算實驗 22

Two links

x

Y

(xt yt)

P1

P2

1l

2l

軟體實作與計算實驗 23

x

Y

(xt yt)

P1

P2

1l

2l

222tt yxB

)atan2(1t

t

y

xq

軟體實作與計算實驗 24

x

Y

(xt yt)

P1

P2

1l

2l

222tt yxB

1q

211

1

22

221

2 )2

acos(

qqP

Bl

lBlq

2q

軟體實作與計算實驗 25

x

Y

(xt yt)

P1

P2

1l

2l

B

1q

2q

)2

acos(21

222

21

ll

Bll

)(12 PP

軟體實作與計算實驗 26

Forward kinematics of two-link robot

)sin()sin(

)cos()cos(

2211

2211

PlPly

PlPlx

t

t

21,PP

tt yx ,

21,PP

tt yx ,

軟體實作與計算實驗 27

Inverse kinematics of two-link robot

22tt yxB

)atan2(1t

t

x

yq

211

1

22

221

2 )2

acos(

qqP

Bl

lBlq

)2

acos(21

222

21

ll

Bll

)(12 PP

21,PP

tt yx ,

軟體實作與計算實驗 28

Exercise

Write matlab functions to implement forward and inverse kinematics of a two-link robot

軟體實作與計算實驗 29

Example

l1=1;l2=1;p1=pi/3;p2=pi/5;[x,y]=fkin(p1,p2,l1,l2)[p1,p2]=inverse_kin(x,y,l1,l2);p1/pip2/pi

軟體實作與計算實驗 30

Nonlinear system

0

04

21

2

2

2

1

xx

xx

軟體實作與計算實驗 31

A set of nonlinear functions

0),(

04),(

21212

2

2

2

1211

xxxxf

xxxxf

軟體實作與計算實驗 32

x=linspace(-2,2);plot(x,x); hold on; plot(x,sqrt(4-x.^2))plot(x,-sqrt(4-x.^2))

軟體實作與計算實驗 33

function F = myfun(x) F(1) = x(1).^2 + x(2)^2-4; F(2) = x(1) - x(2);return

軟體實作與計算實驗 34

Least square of nonlinear functions

i

ixxxxf 2

21,),(min

21

軟體實作與計算實驗 35

function demo_lsq()x0= ones(1,2)*2;x = lsqnonlin(@myfun,x0)y=myfun(x);sum(y.^2)returnfunction F = myfun(x) F(1) = x(1).^2 + x(2)^2 -4; F(2) = x(1) - x(2);return

Demo_lsq

軟體實作與計算實驗 36

012),(

0242),(22

212

2

2

2

1211

21

xxxxf

xxxxf

軟體實作與計算實驗 37

x=linspace(-5,5);plot(x,sqrt(24-2*x.^2),'r');hold on; plot(x,-sqrt(24-2*x.^2),'r')plot(x,sqrt(12+x.^2),'b')plot(x,-sqrt(12+x.^2),'b')

軟體實作與計算實驗 38

Demo_lsq_2c

source code

軟體實作與計算實驗 39

223

212

11

180

180

1802

PP

PP

P

)sin()sin()sin(

)cos()cos()cos(

332211

332211

PlPlPly

PlPlPlx

t

t

t

t

yPlPlPlF

xPlPlPlF

)sin()sin()sin(),(

)cos()cos()cos(),(

332211212

332211211

軟體實作與計算實驗 40

Nonlinear systems

)sin()sin(

)cos()cos(

2211

2211

PlPly

PlPlx

t

t

t

t

yPlPlPPF

xPlPlPPF

)sin()sin(),(

)cos()cos(),(

2211212

2211211

軟體實作與計算實驗 41

)sin()sin(2

)cos()cos(2

21

21

PP

PP

2)sin()sin(),(

2)cos()cos(),(

21212

21211

PPPPF

PPPPF

軟體實作與計算實驗 42

Exercise

Write a malab function to solve the following nonlinear system

2)sin()sin(),(

2)cos()cos(),(

21212

21211

PPPPF

PPPPF

軟體實作與計算實驗 43

軟體實作與計算實驗 44

puma3d.m

gen_path.m

PUMA Robot Matlab/Servo To Go software

MATLAB Central File Exchange - 3D Puma Robot Demo

top related