From: Manan on 15 Mar 2010 12:42 i am trying to write a code for anfis in a three link robotic arm which has: 1) a rotating base (with 360 degree rotation) 2) link1 : a link on top of rotating base which can have angles 0 to 90 degree 3) link2 : a link on top of link1 which can have angles from 0 to 180 degree with respect to link1 i used reference given on http://www.mathworks.com/products/fuzzylogic/demos.html?file=/products/demos/shipping/fuzzy/invkine_codepad.html for writing the code please explain why THETA1P, THETA2P, THETA3P values are not accurate given below is the code for the same which gives unsatisfactory result for theta values: function [ data1, data2, data3, THETA1P, THETA2P, THETA3P ] = anfisdata(XYZ) %UNTITLED Summary of this function goes here % Detailed explanation goes here %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % theta1 : link1 angle % theta2 : link2 angle % theta3 : rotation angle % a : link1 length % b : link2 (end effector link) length % c : base link length % % Training ANFIS data: % anfis function parameters: % The first parameter to anfis is the training data % The second parameter is the number of membership functions used to characterize each input and output (increasing value of this parameter will give improved accuracy but takes a lot of time to train anfis data) % The third parameter is the number of training epochs % The last parameter is the options to display progress during training. % The values for number of epochs and the number of membership functions have been arrived at after a fair amount of experimentation with different values. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% a = 1; % set length of first arm b = 1; % set length of second arm c = 0; % set length of base arm theta1 = 0:1:pi/2; % all possible theta1 values theta2 = 0:1:pi; % all possible theta2 values theta3 = 0:1:2*pi; % all possible theta3 values [THETA1, THETA2, THETA3] = meshgrid(theta1, theta2, theta3); % generate a grid of theta1,theta2 and theta3 values Z = c + a * sin(THETA1) + b * sin(THETA1 + THETA2); % compute Z coordinates r = (((a * sin(THETA1) + b * sin(THETA1 + THETA2)).^2 + (a * cos(THETA1) + b * cos(THETA1 + THETA2)).^2).^(.5)); theta = atan((a * sin(THETA1) + b * sin(THETA1 + THETA2))./(a * cos(THETA1) + b * cos(THETA1 + THETA2))); X = r .* cos(THETA3) .* cos(theta); % compute x coordinates Y = r .* sin(THETA3) .* cos(theta); % compute y coordinates data1 = [X(:) Y(:) Z(:) THETA1(:)]; % create x-y-z-theta1 dataset data2 = [X(:) Y(:) Z(:) THETA2(:)]; % create x-y-z-theta2 dataset data3 = [X(:) Y(:) Z(:) THETA3(:)]; % create x-y-z-theta3 dataset % plot(X(:), Y(:), Z(:)); % axis equal; % xlabel('X') % ylabel('Y') % zlabel('Z') % title('X-Y-Z co-ordinates generated for all theta1, theta2 and theta3 combinations using forward kinematics formulae') fprintf('-->%s\n','Start training first ANFIS network. It may take one minute depending on your computer system.') anfis1 = anfis(data1, 4, 100, [0,0,0,0]); % train first ANFIS network fprintf('-->%s\n','Start training second ANFIS network. It may take one minute depending on your computer system.') anfis2 = anfis(data2, 4, 100, [0,0,0,0]); % train second ANFIS network fprintf('-->%s\n','Start training third ANFIS network. It may take one minute depending on your computer system.') anfis3 = anfis(data3, 4, 100, [0,0,0,0]); % train third ANFIS network XYZ=[sqrt(5) 0 0] THETA1P = evalfis(XYZ, anfis1); % theta1 predicted by anfis1 THETA2P = evalfis(XYZ, anfis2); % theta2 predicted by anfis2 THETA3P = evalfis(XYZ, anfis3); % theta3 predicted by anfis3 end please explain why THETA1P, THETA2P, THETA3P values are not accurate
|
Pages: 1 Prev: fmincon minimisation Next: how to get similar result of pixel region |