Radial basis function approximation 1 Kmean Algorithm function
Radial basis function approximation 軟體實作與計算實驗 1
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 ind 2=find(ind == i); Y_new(i, : ) = mean(X( ind 2, : )); end change = mean(Y-Y_new)); end return 軟體實作與計算實驗 2
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); 軟體實作與計算實驗 3
Radial basis function 軟體實作與計算實驗 4
http: //www. mathworks. com/matlabcentral/fileexchange/load. File. do? object. Id=157&object. Type=File 軟體實作與計算實驗 5
Forward Kinematics 軟體實作與計算實驗 10
Frame positions x position of frame '2' y position of frame '2' 軟體實作與計算實驗 11
Position of frame 3 軟體實作與計算實驗 12
Position of tool x position of frame 'tool' y position of frame 'tool' 軟體實作與計算實驗 13
http: //www. learnaboutrobots. com/forward. Kinematics. htm 軟體實作與計算實驗 14
Forward Kinematics Problem statement l A schematic of a simple robot lying in the X-Y plane Robot length l Three links of the robot l Given the ang joints, where is the robot's hand? l l ? 軟體實作與計算實驗 15
Forward Kinematics for planar robot 軟體實作與計算實驗 16
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? " 軟體實作與計算實驗 18
One link l Given Xt what is the joint angle P Y xt P x 軟體實作與計算實驗 19
multiple solutions 軟體實作與計算實驗 21
Two links (xt yt) Y P 2 P 1 x 軟體實作與計算實驗 22
Forward kinematics of two-link robot 軟體實作與計算實驗 26
Inverse kinematics of two-link robot 軟體實作與計算實驗 27
Exercise l Write matlab functions to implement forward and inverse kinematics of a twolink robot 軟體實作與計算實驗 28
Example l 1=1; l 2=1; p 1=pi/3; p 2=pi/5; [x, y]=fkin(p 1, p 2, l 1, l 2) [p 1, p 2]=inverse_kin(x, y, l 1, l 2); p 1/pi p 2/pi 軟體實作與計算實驗 29
Nonlinear system 軟體實作與計算實驗 30
A set of nonlinear functions 軟體實作與計算實驗 31
x=linspace(-2, 2); plot(x, x); hold on; plot(x, sqrt(4 -x. ^2)) plot(x, -sqrt(4 -x. ^2)) 軟體實作與計算實驗 32
function F = myfun(x) F(1) = x(1). ^2 + x(2)^2 -4; F(2) = x(1) - x(2); return 軟體實作與計算實驗 33
Least square of nonlinear functions 軟體實作與計算實驗 34
Demo_lsq function demo_lsq() x 0= ones(1, 2)*2; x = lsqnonlin(@myfun, x 0) y=myfun(x); sum(y. ^2) return function F = myfun(x) F(1) = x(1). ^2 + x(2)^2 -4; F(2) = x(1) - x(2); return 軟體實作與計算實驗 35
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') 軟體實作與計算實驗 37
Demo_lsq_2 c source code 軟體實作與計算實驗 38
Nonlinear systems 軟體實作與計算實驗 40
Exercise l Write a malab function to solve the following nonlinear system 軟體實作與計算實驗 42
PUMA Robot Matlab/Servo To Go software MATLAB Central File Exchange - 3 D Puma Robot Demo puma 3 d. m gen_path. m 軟體實作與計算實驗 44
- Slides: 44