Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

matlab/wheelFFT.m

Go to the documentation of this file.
00001 function [phases, amplitudes] = wheelFFT(encData,steps,amplitudeMax)
00002 % function [phases, amplitudes] = trucksim(fencData,steps,amplitudeMax)
00003 %
00004 % determines phase and amplitudes on fr,fl,br,bl
00005 % returns phases of wheels and amplitudes of wheels
00006 % such that :
00007 %   fr - amplitudes(1) * cos(2*pi*fr/1620 + phases(1)) 
00008 % should not have much periodic disturbances due to 
00009 % the offcentered wheels
00010 
00011 % encoder ticks per wheel revolution
00012 ticksPerRevolution = 4*540;
00013 
00014 % make sure cols are data for each encoder
00015 [rows,cols] = size(encData)
00016 
00017 if rows < cols 
00018     encData = encData';
00019     [rows,cols] = size(encData)
00020 end
00021 
00022 % make a avg of each row of data
00023 encAvg = sum(encData,2) / cols;
00024 
00025 
00026 % for each cols (each encoder) :
00027 %  - first determine phase
00028 %  - then determine amplitude
00029 
00030 phases = zeros(cols,1);
00031 amplitudes = 2 * ones(cols,1);
00032 results = zeros(cols,steps);
00033 
00034 
00035 for i = [1:cols]
00036     for j = [1:steps]
00037         phase = 2*pi * j/steps;
00038         y = encData(:,i) - amplitudes(i) * cos(2*pi*encData(:,i)/ticksPerRevolution + phase);        
00039         results(i,j) = sum(y .* y);
00040     end
00041     figure(i)
00042     hold off;
00043     plot(2*pi*[1:steps]/steps,results(i,:));
00044 end
00045 
00046 [value,index] = min(results');
00047 phases = 2*pi * index/steps;
00048 
00049 results2 = zeros(cols,steps);
00050 
00051 for i = [1:cols]
00052     for j = [1:steps]
00053         amp = amplitudeMax * j/steps;
00054         y = encData(:,i) - amp * cos(2*pi*encData(:,i)/ticksPerRevolution + phases(i));        
00055         results2(i,j) = sum(y .* y);
00056     end
00057     figure(i+cols)
00058     hold off;
00059     plot(amplitudeMax*[1:steps]/steps,results2(i,:));
00060 end
00061 

Generated on Fri Sep 1 14:25:49 2006 for Raptor by  doxygen 1.4.4