基于SLAM算法的路径规划算法

1614 篇文章 1655 订阅
订阅专栏
218 篇文章 54 订阅
订阅专栏

function x=slam
% Basic Simultaneous Localisation and Mapping Algorithm usign EKF using Encoder and Laser
%  Juan Nieto         j.nieto@acfr.usyd.edu.au
%  Eduardo Nebot      nebot@acfr.usyd.edu.au
%  More information   http://acfr.usyd.edu.au/homepages/academic/enebot/summer_sch.htm 
%
%
%EkfSlam, this file is using "Nearest Neighbour" data association

close all; clear all;

%Beacons Positions, taken with a kinematic GPS ( 2cm ), used only to Compare results
global beacons;
FileBEACON='beac_juan3.mat';
load(FileBEACON);
beacons=estbeac; clear estbeac;

DeltaT=1;        
T0=0;
TF=112;     % max = 112 secs;

global GPSLon GPSLat

load('data_set');   % File with data stored according to spec provided

%-----------------------------------------------------
To=min([TimeGPS(1),Time_VS(1),TimeLaser(1)]);
TimeLaser=TimeLaser-To;
Time_VS=Time_VS-To;                 %Init time --> 0
TimeGPS=TimeGPS-To;
Time=Time-To;
%-----------------------------------------------------
[tf,If]=FINDT(TimeGPS,TF);% to plot the gps data till TF 
GPSLon=GPSLon(1:If);
GPSLat=GPSLat(1:If);

%----------------------------------------------------------------------------------------
%Prepare matrices to save data: f( Number of predictions + Number of updates Laser 
%                                  + Number of updates GPS)
global xest Pest TimeGlobal FlagS innov innvar;

numberbeacons=50;
NumPred=size(Time,2);
NumUpdaL=size(TimeLaser,2);
NumUpdaG=size(TimeGPS,2);

xest=zeros(3,NumPred+2*NumUpdaL+NumUpdaG);
Pest=zeros(numberbeacons,NumPred+2*NumUpdaL+NumUpdaG);
innov=zeros(2,2*(NumUpdaL+NumUpdaG));
innvar=zeros(2,2*(NumUpdaL+NumUpdaG));
TimeGlobal=zeros(1,NumPred+2*NumUpdaL+NumUpdaG);
FlagS=zeros(1,NumPred+2*NumUpdaL+NumUpdaG);          %This flag is used to know if we 
                                                     %saved an update or a prediction

%----------For the the Jacobians, states and covariances--------------------
global Pp Jh xp 

Pp=zeros(2*numberbeacons+3,2*numberbeacons+3);
Jh=zeros(2,2*numberbeacons+3);
xp=zeros(2*numberbeacons+3,1);
MatrixA=zeros(2*numberbeacons+3,2*numberbeacons+3);        %Auxiliar matrix for J*Pest*J'
MatrixB=zeros(2*numberbeacons+3,2*numberbeacons+3);

%-------------On Line Plot-----------------------------------------------------------------
global FlagWait FlagEnd hhh;
FlagWait = 0 ;
FlagEnd =0 ;

figure(10) ;clf ; 
hold on;
uicontrol('Style','pushbutton','String','PAUSE','Position',[10 5 50 30], 'Callback', 'fOnOff(1);');
uicontrol('Style','pushbutton','String','END  ','Position',[10 5+35 50 30], 'Callback', 'fOnOff(2);');

title('EKFSlam');xlabel('East (meters)');ylabel('North (meters)');
plot(GPSLon,GPSLat,'r.');axis([-10,20,-25,20]);%axis([2,33,-25,25]);%
plot(beacons(:,1),beacons(:,2),'b*')
hhh(1)=plot(0,0,'b','erasemode','none') ;   %path estimated
hhh(2)=plot(0,0,'r','erasemode','xor') ;   %what is used from the frame
hhh(3)=plot(0,0,'b.','erasemode','xor') ;   %laser, all the frame
hhh(4)=plot(0,0,'r+','erasemode','xor') ;   %high intensity only
hhh(5)=plot(0,0,'r','erasemode','xor') ;   %covariance ellipse x-y position
hhh(6)=plot(0,0,'r','erasemode','xor') ;   %covariance ellipse x-y beacon
hhh(7)=plot(0,0,'r','erasemode','xor') ;   %covariance ellipse x-y beacon

hhh(8)=plot(0,0,'sr','erasemode','xor') ;   %car
hhh(9)=plot(0,0,'go','erasemode','xor') ;   %beacons' position estimated
legend('GPS','Beacons','Estimated Path','Laser Data','All laser','H. Inten.')

hold off;

%-----------------------------------------------------------------
% Filter Tuning
% These are the parameter you need to modify to improve the operation
% of the filter  ( Good Luck :-) )
%
global sigmaU sigma_laser sigma_gps;

%Internal Sensors  ( dead - reckoning )
    sigmastear=(7)*pi/180;        %Qu=7
    sigmavel=0.7;                 %Qv=0.7
    
%Observations:  laser Range and Bearing   ( Sick laser )
%               We are estimating the centre of a 6 cm pole
    SIGMA_RANGE=0.10;             %Rr=0.1  
    SIGMA_BEARING=(1)*pi/180;     %Ro=1
    
% Observations: GPS
% This is only used at the beginning to estimate absolute heading
% and then compare the localisation results with GPS
    sigmagps=0.05;            
    
    
% sensors error covariance
    sigmaU=[sigmavel*sigmavel       0;
                0             sigmastear*sigmastear];
    
    sigma_laser=[SIGMA_RANGE^2     0;
                0          SIGMA_BEARING^2]  ;            
    
    sigma_gps=[sigmagps*sigmagps     0;
                0          sigmagps*sigmagps]  ;          


%--------------Initial conditions & some constants----------------------------------------

global Pt isave index_update beacon2show tglobal trefresh plotall;   %trefresh is to refresh 
                                                                     %the path in the plot

finit=-112*pi/180; % or you could use something like: atan2(GPSLat(2)-GPSLat(1),GPSLon(2)-GPSLon(1));

xinit=[GPSLon(1);GPSLat(1);finit];

Pinit= [0.1    0.0   0.0   ;
        0.0   0.1    0.0   ;
        0.0   0.0    (15)*pi/180  ];

u=[Velocity(1) ; Steering(1) ];  

FlagStates=[-1;-1;-1];      %Initialization of flags to count the number of "hits" of each beacon

Pt=3;           %Pointer to the last state, at the beggining we have the three model's states  
t1=cputime; trefresh=T0+2;
iglobal=0; isave=1; index_update=1; tglobal=0;
xp(1:Pt)=xinit; Pp(1:Pt,1:Pt)=Pinit;
plotellipse=0;         %Flag to plot the covariance of the vehicle and some landmarks  
                       % 1: plot  0: no plot
plotall=1;             %check in the plot function
beacon2show=[4 5];     %These are the beacons which the covariance ellipse will be show
                       %In this example only two beacons are selected.

                       
%-----------------------------------Running filter------------------------------------------
disp('Running filter...')


%**************************  Navigation Loop Start **************************************

while (tglobal<TF)
    iglobal=iglobal+1;
    tglobal=Time(iglobal);
    if (iglobal>1)
        dt=tglobal-Time(iglobal-1);
    else
        dt=0.025;
    end
    
    %Perform a prediction with delta = previous time - actual time
    
    pred(dt,u);                                          %Prediction
    SaveStates(xp(1:3),diag(Pp(1:Pt,1:Pt)),tglobal,0);   %save data
    set(hhh(1),'XData',xp(1),'YData',xp(2)) ;
    if plotellipse
        plotCovariance; %plot the covariance ellipse (1-sigma)
    else  
        set(hhh(8),'XData',xp(1),'YData',xp(2)) ;
    end
    
    %New Information, If External: do update, if dead-reckioning : set u for next predition
    
    %------------------------------------------------------------------------------------------------------------------------      
    %  GPS is sensor 1, Only used for DeltaT to evaluate initial heading !!
    if (Sensor(iglobal)==1) & (tglobal<(T0+DeltaT))                     
        %GPS
        zgps=[GPSLon(Index(iglobal));GPSLat(Index(iglobal))];
        [in ins]=update_gps(zgps);
        SaveStates(xp(1:3),diag(Pp(1:Pt,1:Pt)),tglobal,1); SaveInnov(in,diag(ins));
    end 
    
    
    %------------------------------------------------------------------------------------------------
    %Sensor =2 are Dead reckoning sensors

    if Sensor(iglobal)==2 
        %Sensors
        u=[Velocity(Index(iglobal)) ;Steering(Index(iglobal))];    %SPEED IN m/s, stearing in rads.
    end
    
    %-----------------------------------------------------------------------------------------------
    % Sensor = 3 is the Laser   

    if (Sensor(iglobal)==3) & (tglobal>(T0+DeltaT))
       %Laser
       bias=0*pi/180;
       [LASERr LASERo RR a]=getdata(Laser(Index(iglobal),:), Intensity(Index(iglobal),:));  %estimate beacon centre
       zlaser=[LASERr ; LASERo+bias];          
       %------------------------------------------------------------------------------------------------
       laserview(RR,a,LASERr,LASERo);        %plot the laser frame
       
       %------------------------Update--------------------------------------------------------------------
       for w=1:size(LASERr,2)    
        index1=0;
        if Pt==3                % this is the first beacon and will be incorporated
                                % this can be improved building a list to avoid spurious observ.
            new_state(zlaser(:,w));
            Pt=Pt+2;            %pointer to the last state in the s.v.
            FlagStates(Pt-1:Pt)=1;
            [index1,in,ins]=asoc_update(zlaser(:,w),(Pt-1),1);       %Update of the new state
            SaveStates(xp(1:3),diag(Pp(1:Pt,1:Pt)),tglobal,1);       %save states
            SaveInnov(in,diag(ins));                                 %save innovations
            set(hhh(1),'XData',xp(1),'YData',xp(2)) ;                % on line plot
        else        
            [closest]=Zone_Probe(zlaser(:,w));       %if not first association is needed ( look only in reduced area )
            closest=4+2.*(closest-1);                %pointer to the X beacons position in the state vector
            j=1;i=0; qu=[];possible=[];
            while (j<=length(closest))                    
                i=closest(j);
                [index1,in,ins,q1]=asoc_update(zlaser(:,w),i,0);    %q1 is the likelihood value, assoc only here
                if index1==1
                    possible=[possible i];
                    qu=[qu q1];
                end
                j=j+1;
            end
            if ~isempty(possible)     
                if length(possible)>1
                    disp('Multi hypothesis problem');        % this may be a problem !
                end
                [value,index2]=min(qu);
                twin=possible(index2);                             %nearest nighbour==max. likelihood
                FlagStates(twin:twin+1)=FlagStates(twin:twin+1)+1; 
                [index1,in,ins]=asoc_update(zlaser(:,w),twin,1);     % perform the update with best
                SaveStates(xp(1:3),diag(Pp(1:Pt,1:Pt)),tglobal,1);
                SaveInnov(in,diag(ins));
                set(hhh(1),'XData',xp(1),'YData',xp(2)) ;
            else           
                new_state(zlaser(:,w));                 
                Pt=Pt+2;                
                FlagStates(Pt-1:Pt)=1;
                [index1,in,ins]=asoc_update(zlaser(:,w),Pt-1,1);         %Update of the new state
            end
        end    
                  
      end
  end   
  
  
  while FlagWait,
      if FlagEnd, return  
      end                          %This is for the buttons of "pause" and "end" in the animation plot
      pause(0.5) ;
  end;
  if FlagEnd; hold on;plot(xest(1,1:isave-1),xest(2,1:isave-1),'b');hold off; return 
  end  
end

%************************ Navigation Loop End **********************************

xest=xest(:,1:isave-1); Pest=Pest(:,1:isave-1);
innov=innov(:,1:index_update-1); innvar=innvar(:,1:index_update-1);
FlagS=FlagS(:,1:isave-1);
TimeGlobal=TimeGlobal(:,1:isave-1);


disp('Completed Filtering:')
t2=cputime;                     %To know the real time of the algorithm
treal=TF-T0,
time=t2-t1,
taverage=(t2-t1)/iglobal, 
%----------------------------Fiter completed --------------------------------------

%This is to select just the beacons we saw more than "hits" times. ( for display purposes
global estbeacons
hits=4;
aux=FlagStates(4:2:Pt);
ii=find(aux>=hits);
xpos=4+2.*(ii-1);
estbeacons(:,1)=xp(xpos) ; estbeacons(:,2)=xp(xpos+1); 
numbeac=size(estbeacons,1);


plots;

return;
%--------------------------------------------------------------------------------------------------------------------------------------
%---------------------------------End of the main function-----------------------------------------------------------------------------
%--------------------------------------------------------------------------------------------------------------------------------------

%------------------------------------------------------------------------------
%      Auxiliary functions
%-------------------------------------------------------------------------------

function pred(dt,u)
% Function to generate a one-step vehicle prediction .
    global Pt;
    global Pp xp MatrixA MatrixB;
    global sigmaU;
    %----------------------------------------------------------------------
    %Car parameters
    L=2.83 ; h=0.76;  b = 1.21-1.42/2;  a = 3.78;   
    %-----------------------------------------------------------------------
    XSIZE=Pt; N=(Pt-3)/2;     %Pt=3+2*N
    
    % input error transfer matrix      (df/du)
    ve=u(1);
    vc=ve/(1-tan(u(2))*h/L);          %The velocity has to be translated from the back
                                      %left wheel to the center of the axle
    dvc_dve=(1-tan(u(2))*h/L)^-1;
    dvc_dalpha=ve*h/(L*(cos(u(2)))^2*(1-tan(u(2))*h/L));
    aux=(cos(u(2))^(-2));
    T1=a*sin(xp(3))+b*cos(xp(3));
    T2=a*cos(xp(3))-b*sin(xp(3));

    b1=(cos(xp(3))-tan(u(2))/L*T1)*dvc_dve;
    b3=(sin(xp(3))+tan(u(2))/L*T2)*dvc_dve;
    b5=tan(u(2))/L*dvc_dve;
    b2=-T1*vc/L*aux+b1*dvc_dalpha;
    b4=T2*vc/L*aux+b1*dvc_dalpha;
    b6=vc/L*aux+tan(u(2))/L*dvc_dalpha;

    Bv=dt*[b1   b2;
          b3   b4;
          b5   b6];

% state transition matrix evaluation    (df/dx) -------------------------------
    J1=[1 0 -dt*(vc*sin(xp(3))+vc/L*tan(u(2))*(a*cos(xp(3))-b*sin(xp(3))))       
        0  1  dt*(vc*cos(xp(3))-vc/L*tan(u(2))*(a*sin(xp(3))+b*cos(xp(3))))       %Jacobian
        0  0                              1                               ];  
        I=eye(Pt-3,Pt-3);             

% first state prediction -------------------------------------------------------

    xp(1)=xp(1) + dt*vc*cos(xp(3))-dt*vc/L*tan(u(2))*(a*sin(xp(3))+b*cos(xp(3)));
    xp(2)=xp(2) + dt*vc*sin(xp(3))+dt*vc/L*tan(u(2))*(a*cos(xp(3))-b*sin(xp(3)));         
    xp(3)=xp(3) + dt*vc/L*tan(u(2));
    xp(3)=NormalizeAngle(xp(3));

%J*Pest*J' ---------------------------------------------------------------------
    P1=Pp(1:3,1:Pt);
    P2=Pp(4:Pt,1:Pt);
    Aux=[J1*P1
        I*P2];
    Aux1=Aux(1:3,1:3); Aux2=Aux(1:3,4:Pt); Aux3=Aux(4:Pt,1:3); Aux4=Aux(4:Pt,4:Pt);

    MatrixA(1:Pt,1:Pt)=[Aux1*J1' Aux2*I
                        Aux3*J1' Aux4*I];
    clear Aux Aux1 Aux2 Aux3 Aux4;
%---------------------------------------------------------------------------------

%B*sigmaU*B'----------------------------------------------------------------------
    MatrixB(1:Pt,1:Pt)=[Bv*sigmaU*Bv'  zeros(3,Pt-3)
                            zeros(Pt-3,Pt)        ];
%---------------------------------------------------------------------------------     
    Pp(1:Pt,1:Pt)= MatrixA + MatrixB;
return;


%---------------------------------------------------------------------------------------------------------------------------------------    
%Update with GPS data
function [innov, S]=update_gps(zgps)
    global xp Pp Pt
    global sigma_gps;

    H=zeros(2,Pt); H(1,1)=1; H(2,2)=1;

    S=H*Pp(1:Pt,1:Pt)*H' + sigma_gps;           
    W=Pp(1:Pt,1:Pt)*H'* inv(S);
    Pp(1:Pt,1:Pt)=Pp(1:Pt,1:Pt)-W*S*W';
    innov=[zgps-H*xp(1:Pt)];
  
    xp(1:Pt)=xp(1:Pt)+W*innov;
return;


%---------------------------------------------------------------------------------------------------------------------------------------    
% This function perfor association or update accoding to the value of updatee
% updatee=0 -> association only, updatee=1 -> association and update
function [index,innov, S, q1]=asoc_update(zlaser,pointer,updatee)
    global Pt;
    global Pp xp Jh;
    global sigma_laser;
 
    beacon=[xp(pointer) xp(pointer+1)];       %Xi,Yi
    dx=xp(1)-beacon(1);
    dy=xp(2)-beacon(2);
    d=(dx^2+dy^2)^0.5;

    Jh(1:2,1:3)=[dx/d     dy/d      0;
                -dy/(d^2) dx/(d^2) -1];
    Jh(1:2,4:Pt)=zeros(2,(Pt-3));    
    Jh(1:2,(pointer):(pointer+1))=[-dx/d -dy/d ; dy/(d^2) -dx/(d^2)];

    H=[d ; atan2((beacon(2)-xp(2)),(beacon(1)-xp(1)))-xp(3) + pi/2];         %h(xpred)
                                                                       
    H(2)=NormalizeAngle(H(2));
    S=Jh(1:2,1:Pt)*Pp(1:Pt,1:Pt)*(Jh(1:2,1:Pt))' + sigma_laser;           
    innov=[zlaser-H];       
    innov(2)=NormalizeAngle(innov(2));

    if updatee==1                                    %is an update, if this flag is zero is an asociation 
        W=Pp(1:Pt,1:Pt)*(Jh(1:2,1:Pt))'* inv(S);
        Pp(1:Pt,1:Pt)=Pp(1:Pt,1:Pt)-W*S*W';          %Update of the error covariance matrix
        xp(1:Pt)=xp(1:Pt)+W*innov;
        xp(3)=NormalizeAngle(xp(3));
        index=0;  q1=0; 
    else
    
        chi=5.99;       %95% confidence            
        q=(innov')*(inv(S))*innov;
        if (q<chi)          %Chi square test 
            index=1;       
            q1=q+log(det(S));
        else
            index=0; q1=0;
        end;
        clear q W; 
    end
return;


%---------------------------------------------------------------------------------------------------------------------------------------    
% Insert a new state assigning a large error ( simpler approach )
function new_state(zlaser)
    global Pt xp Pp;

    %First of all, calculate position beacon in the cartesian global coordiante.
    xx = xp(1)+zlaser(1)*cos(zlaser(2)+xp(3)-pi/2) ;yy = xp(2)+zlaser(1)*sin(zlaser(2)+xp(3)-pi/2) ; 

    xp(Pt+1)=xx;
    xp(Pt+2)=yy;
    clear xx yy;

    Pp(Pt+1,1:(Pt))=0;          %x row
    Pp(1:Pt,Pt+1)=0;            %x column
    Pp(Pt+1,Pt+1)=10^6;         %x diagonal

    Pp(Pt+2,1:(Pt+1))=0;        %y row
    Pp(1:Pt+1,Pt+2)=0;          %y column
    Pp(Pt+2,Pt+2)=10^6;         %y diagonal  ( this may introduce numerical problems if not choosen properly )

return;

%---------------------------------------------------------------------------------------------------------------------------------------    
%Function to find index in data between TO and TF
function [t,I]=FINDT(Var,ttt)
    ii=find(Var>=ttt);               
    I=ii(1);
    t=Var(I);
return;

%---------------------------------------------------------------------------------------------------------------------------------------    
%function for the on-line plot 
function fOnOff(x)                                          
    global FlagWait FlagEnd;
    if x==1, FlagWait=~FlagWait ; return ; end ;
    if x==2, FlagEnd=1 ; return ; end ;
return ;

%---------------------------------------------------------------------------------------------------------------------------------------
%Transform GPS lat and Long to local navigation frame centred at a reference pt
function [GPSTIME,LONG,LAT] =ReadGpsData(file)
    load(file) ;
    file;
    LONG = GPS(:,4)' ;
    LAT  = -GPS(:,3)' ;           %We are in the south, the latitude is negative
    GPSTIME = GPS(:,1)'/1000 ;

    LAT0  = -33.8884;          %put any point on the map, is not a good idea to put "magic numbers" (as in this case), the best 
    LONG0 = 151.1948;          %would be to take the average of the initial points
    
    a =  6378137.0; b  = a*(1-0.003352810664747);         %Linalization from latitude and long. to meters in a local area
    kpi = pi/180 ;
    cf = cos(LAT0*kpi) ; sf = abs(sin(LAT0*kpi)) ;
    Ro = a*a*cf/abs(sqrt(a*a*cf*cf + b*b*sf*sf))  ;
    RR = b/a  * abs(sqrt( a*a-Ro*Ro))/sf ;

    LAT =(LAT - LAT0 )*RR*kpi   ;
    LONG=(LONG- LONG0)*Ro*kpi   ;
return ;
%-----------------------------------------------------------------------------------------------------------------------------------------
%read steering data, not used in this case
function [Time,STEERING,SPEED1] = ReadUteData(file)
    load(file) ;
    STEERING = SENSORS(:,4)' ;
    SPEED1   = SENSORS(:,6)' ;
    Time     = SENSORS(:,1)'/1000 ;
return ;


%-----------------------------------------------------------------------------------------------------------------------------------------
%This function perform the estimation of the beacon centre, It can be improved
%There is a more general version: detectrees that works well for all cylindrical
%objects
function [LASERr,LASERo,RR,a]=getdata(laser,intensity)
LASERr=[];                                          
    LASERo=[];
    first=0;
    max_range=30; min_range=1;
    angleDiff=3;
    RR=laser; a=intensity;
    for i=1:361
        if (min_range<RR(i)<max_range) & (a(i)>0)
            primera=0;
            last=[RR(i),i];
            if first==0
                init=[RR(i),i];
                first=1;
            end
        else
            if first==1
                if primera==0
                    primera=1;
                else
                    if (i-last(2))>2
                    first=0;
                    range=mean([init(1),last(1)]);
                    angle=mean([init(2),last(2)]);
                    LASERr=[LASERr range];
                    LASERo=[LASERo (angle-1)/2*pi/180]; 
                    end          
                end
            end
        end
    end
return;

%---------------------------------------------------------------------------------------------------------------------------------
%Is looking for the beacons that are "min_dist" close to te observation
% in this case it is set to 3 meters. Modify if necesary
function   [closest]=Zone_Probe(zlaser);   
    global Pt xp;
    min_dist=3;
    ii=[4:2:Pt-1];
    xx = xp(1)+zlaser(1)*cos(zlaser(2)+xp(3)-pi/2) ;yy = xp(2)+zlaser(1)*sin(zlaser(2)+xp(3)-pi/2) ;   %Position
    d=((xx-xp(ii)).^2+(yy-xp(ii+1)).^2).^0.5;
    iii=find(d<min_dist);
    closest=iii;
    clear xx yy;
    return;
return;


%---------------------------------------------------------------------------------------------------------------------------------
%Plot the laser scan
function laserview(RR,a,LASERr,LASERo)
    global xp hhh;
    global isave xest tglobal trefresh;
    aa = [0:360]*pi/360 ;
    ii=find(RR<50 & RR>1) ;
    aa2=aa(ii) ; xx = RR(ii).*cos(aa2+xp(3)-pi/2) ;yy = RR(ii).*sin(aa2+xp(3)-pi/2) ;     %All points
    set(hhh(3),'XData',xx+xp(1),'YData',yy+xp(2)); 
    pause(0.01);

    ii=find(a>0) ;
    aa2=aa(ii) ; xx = RR(ii).*cos(aa2+xp(3)-pi/2) ;yy = RR(ii).*sin(aa2+xp(3)-pi/2) ;     %High intensity points
    set(hhh(4),'XData',xx+xp(1),'YData',yy+xp(2)); 
    pause(0.01);
              
    ll = length(LASERr) ;
    if ll>0,
        xx = LASERr.*cos(LASERo+xp(3)-pi/2) ;               %The points we are taking from one frame
        yy = LASERr.*sin(LASERo+xp(3)-pi/2) ;
        set(hhh(9),'XData',xx+xp(1),'YData',yy+xp(2));
        
        index=[1:3:3*ll];
        xpoints=zeros(3*ll,1); ypoints=zeros(3*ll,1);           %this is to plot the lines between the beacons and the car
        xpoints(index)=xp(1); ypoints(index)=xp(2);
        xpoints(index+1)=xx+xp(1); ypoints(index+1)=yy+xp(2);
        xpoints(index+2)=NaN;ypoints(index+2)=NaN;
        set(hhh(2),'XData',xpoints,'YData',ypoints)
        pause(0.01);
    else
        set(hhh(2),'XData',0,'YData',0)
    end ;
    if (tglobal-trefresh)>2                                             %every "trefresh" seconds is doing s refresh of the whole path
        set(hhh(1),'XData',xest(1,1:isave-1),'YData',xest(2,1:isave-1))
        trefresh=tglobal;    
    end
 return;

 %---------------------------------------------------------------------------------------------------------------------------------
% saving the state
function SaveStates(states,diagcov,times,Flag)
    global isave xest Pest TimeGlobal Pt FlagS;
    xest(:,isave)=states;
    Pest(1:Pt,isave)=diagcov;
    TimeGlobal(1,isave)=times;
    FlagS(1,isave)=Flag;
    isave=isave+1;
return;

%----------------------------------------------------------------------------------------------------------------------------------
%saving innovations
function  SaveInnov(in,ins);
    global innov innvar index_update;
    innov(:,index_update)=in;
    innvar(:,index_update)=ins;
    index_update=index_update+1;
return;

%----------------------------------------------------------------------------------------------------------------------------------
%transform angles to -pi to pi
function ang2 = NormalizeAngle(ang1)
    if ang1>pi, ang2 =ang1-2*pi ;  return ; end ;
    if ang1<-pi, ang2 =ang1+2*pi ;  return ; end ;
    ang2=ang1;
return 

%----------------------------------------------------------------------------------------------------------------------------------
%plot 1-sigma uncertainty region for a P covariance matrix.
% Jose-1999
function xxx=ellipse(X0,P,veces,color,figu)


    R = chol(P)';  % R*R'= P, X = R*X2
    r = 1 ;  %circle's radius in space X2 
    aaa = [0:veces]*2*pi/veces ;            % sample angles
    xxx = [ r*cos(aaa) ; r*sin(aaa) ] ; % polar to x2,y2
    xxx = R*xxx ;                                % x2,y2 to x,y
    xxx(1,:) = X0(1)+xxx(1,:);                % reference to center X0
    xxx(2,:) = X0(2)+xxx(2,:);
return;

%----------------------------------------------------------------------------------------------------------------------------------
function Rxx=auto(x)        %This is used just for the plot

    [N,nul]=size(x'); 
    M=round(N/2);

    Xpsd=fft(x);
    Pxx=Xpsd.*conj(Xpsd)/N;

    % the inverse is the autocorrelation
    Rxx=real(ifft(Pxx));
    Rxx=Rxx(1:M);
    fact=Rxx(1); 
    for i=1:M
        Rxx(i)=Rxx(i)/fact;
    end
return


%---------------------------------------------------------------------------------------------------------------------------------
%Include all your off-line plots here ( runs when finish )
function plots
    global xest Pest GPSLon GPSLat beacons;
    global innov innvar;
    global FlagS TimeGlobal estbeacons plotall;
    ii=find(FlagS==1);
    timeinnov=TimeGlobal(ii);           %Innovations time stamps

figure(1);clf
plot(xest(1,:),xest(2,:),'c',xest(1,:),xest(2,:),'b.',estbeacons(:,1),estbeacons(:,2),'r*',beacons(:,1),beacons(:,2),'bo',GPSLon,GPSLat,'g.');grid on;
legend('Estimated','Est. Sample','Est. Beac.','Beacons','GPS')
xlabel('East Meters')
ylabel('North Meters')
title('Path')

if plotall
    figure(2);clf
    plot(xest(1,:),xest(2,:),'r');grid on;
    xlabel('East Meters')
    ylabel('North Meters')
    title('Path Estimated')

    figure(3);clf
    hold on
    axis([timeinnov(1) timeinnov(size(timeinnov,2)) -0.5 0.5]);grid on;
    plot(timeinnov(1,:),innov(1,:)), title('Zr Innovations')%
    plot(timeinnov(1,:),2*sqrt(innvar(1,:)),'r')
    plot(timeinnov(1,:),-2*sqrt(innvar(1,:)),'r')
    xlabel('Time(secs)');ylabel('Desviation(m)');
    legend('Innovations','Sta. Desv. Inn. (95%)')
    hold off

    figure(4);clf
    Rxx1=auto(innov(1,:));
    Rxx2=auto(innov(2,:));
    M=round(size(innov,2)/2);
    bounds=2*sqrt(1/(M));
    plot([1:M],Rxx1,'b',[1:M],Rxx2,'r',[1:M],bounds,'g',[1:M],-bounds,'g');grid on;
    title('Autocorrelation of Innovation Sequence')
    legend('Var. Zr','Var. Ztheta','95% Confi. Bounds')

    figure(5);clf
    hold on
    axis([TimeGlobal(1) TimeGlobal(size(TimeGlobal,2)) 0 1]);grid on;
    plot(TimeGlobal,sqrt(Pest(1,:)),'b')
    plot(TimeGlobal,sqrt(Pest(2,:)),'r')
    plot(TimeGlobal,sqrt(Pest(3,:)),'g')
    xlabel('Time(secs)');ylabel('Desviation(m)');
    title('Model Covariance');
    legend('X var.','Y var.','Steer.')
    hold off

    figure(6);clf
    hold on
    axis([TimeGlobal(1) TimeGlobal(size(TimeGlobal,2)) 0 1]);grid on;
    plot(TimeGlobal,sqrt(Pest(4,:)),'b'); plot(TimeGlobal,sqrt(Pest(5,:)),'b.')
    plot(TimeGlobal,sqrt(Pest(8,:)),'r'); plot(TimeGlobal,sqrt(Pest(9,:)),'r.')
    plot(TimeGlobal,sqrt(Pest(12,:)),'g'); plot(TimeGlobal,sqrt(Pest(13,:)),'g.')
    plot(TimeGlobal,sqrt(Pest(16,:)),'m'); plot(TimeGlobal,sqrt(Pest(17,:)),'m.')
    xlabel('Time(secs)');ylabel('Desviation(m)');
    title('Beacons Covariances');
    legend('Beac.1(east)','Beac.1(north)','Beac.3(east)','Beac.3(north)','Beac.5(east)','Beac.5(north)','Beac.7(east)','Beac.7(north)')
    hold off
end
return;
%---------------------------------------------------------------------------------------------------------------------------------
function plotCovariance
    global hhh xp Pp beacon2show Pt;
    xxx=ellipse(xp(1:2),Pp(1:2,1:2),50); set(hhh(5),'XData',xxx(1,:),'YData',xxx(2,:)) ;    %Position 
    if Pt>=(3+2*beacon2show(2))
        xxx=ellipse(xp(4+2*(beacon2show(1)-1):4+2*(beacon2show(1)-1)+1),Pp(4+2*(beacon2show(1)-1):4+2*(beacon2show(1)-1)+1,4+2*(beacon2show(1)-1):4+2*(beacon2show(1)-1)+1),50);
        set(hhh(6),'XData',xxx(1,:),'YData',xxx(2,:)) ;
        xxx=ellipse(xp(4+2*(beacon2show(2)-1):4+2*(beacon2show(2)-1)+1),Pp(4+2*(beacon2show(2)-1):4+2*(beacon2show(2)-1)+1,4+2*(beacon2show(2)-1):4+2*(beacon2show(2)-1)+1),50);
        set(hhh(7),'XData',xxx(1,:),'YData',xxx(2,:)) ;
    end
return;
%---------------------------------------------------------------------------------------------------------------------------------

D61

(11-4-01)基于SLAM的自主路径导航系统:路径规划(1)
码农三叔
08-07 458
通过传感器获取的环境信息,机器人在地图上进行自主导航,以达到指定目标点的目的。路径规划算法可以根据不同的SLAM方法进行选择,包括gmapping、cartographer、hector、karto、frontier_exploration等,用户可以根据需要选择合适的方法进行路径规划。整个项目通过ROS的launch文件进行配置和启动,可视化部分使用RViz工具实时展示机器人的运动轨迹和地图信息,为用户提供了一个方便直观的界面来监控和调试路径规划的效果。同时,节点会打印距离信息和控制指令以进行调试。
自治机器的SLAM路径规划SLAM(同时定位和地图绘制)对于自治系统在太空中定位自身并绘制其周围环境至关重要。 然后,它可以决定要做什么,即“计划下一步行动”。 该项目是相同的实施
02-16
自治机器的SLAM路径规划 SLAM(同时定位和地图绘制)对于自治系统将自己定位在太空中并绘制其周围环境至关重要。 然后,它可以决定要做什么,即“计划下一步行动”。 该项目是相同的实施。 作者: ,
(11-4-03)基于SLAM的自主路径导航系统:路径规划(3)
最新发布
码农三叔
08-09 1047
此文件实现了多个功能函数,包括全局变量的初始化、移动基地客户端、坐标转换函数、距离计算函数、旋转函数、前往目标函数、路径跟随函数、订阅里程计和地图信息的回调函数、地图转换为图像函数以及发布路径点函数。RRT(Rapidly-exploring Random Tree,快速探索随机树)算法是一种用于路径规划的基于树结构的算法,通过在自由空间中随机生成点,并将这些点逐渐连接起来形成树结构,以便找到起点到目标点的可行路径。在指定的地图上生成随机点并逐步连接,最终找到起点到目标点的可行路径。
路径规划SLAM机器人路径规划(含激光雷达数据(2D))【含Matlab源码 4350期】
Matlab武动乾坤的博客
04-24 1604
SLAM机器人路径规划(含激光雷达数据(2D)) 完整的代码,方可运行;可提供运行操作视频!适合小白!
一起自学SLAM算法:11.3 路径规划
机器人研究猿-CSDN
01-29 2035
(先占个坑,有时间再来补充详细内容,大家可以直接看文后的参考文献)
机器人SLAM路径规划总结(1)
zjguilai的博客
04-17 6418
1)路径规划算法: 【1】基于采样的算法(PRM) 【2】基于节点的算法(A star ,D star,theta star)–grid map 【3】基于数学模型的算法(PNLP) 【4】生物启发式算法(cnn,bp,ACA):需要增强实时性!!! 【5】多融合算法(多数据融合,多算法融合) 2)典型算法讲解 1.A*算法 https://blog.csdn.net/autonavi2012/a...
三维SLAM路径规划
FPGA/MATLAB学习教程/源码/项目合作开发
05-18 1633
% 3D SLAM with linear KF - Moving vehicle - Relative measurement - Limited % Sensor Range - Observing (x,v,landmarks) - Landmarks updated once % observed % % A 3 DOF underwater robot is moving along a path detecting some % motionless landmarks; the positio
基于激光雷达的SLAM路径规划算法研究与实现1
08-03
这篇由哈尔滨工业大学刘文之硕士研究生撰写的学位论文《基于激光雷达的SLAM路径规划算法研究与实现》深入探讨了这些关键问题。 论文首先介绍了SLAM(Simultaneous Localization and Mapping,即同步定位与建图)...
_移动机器人SLAM路径规划在ROS框架下的实现.pdf
04-17
SLAM的经典算法包括基于粒子滤波的FastSLAM算法、A*算法和动态窗口法(Dynamic Window Approach,DWA)。这些算法在ROS环境下得到了良好的应用和优化。 在ROS框架中,gmapping功能包利用激光雷达(LIDAR)等传感器...
基于ROS实现的激光雷达SLAM建图与路径规划c++源码+文档说明,包括SLAM建图、定位、路径规划算法介绍,主要事项
06-11
基于ROS实现的激光雷达SLAM建图与路径规划c++源码+文档说明,包括SLAM建图、定位、路径规划算法介绍,主要事项已获导师指导并通过的97分的高分大作业设计项目,可作为课程设计和期末大作业,下载即用无需修改,...
无人车规划算法Slam算法
04-10
包含了可运行出实际成果的,典型的路径规划算法,也包含了较简单典型的slam算法,通过Python实现。
基于分层分段的SLAM算法优化(IROS 2021)
3D视觉工坊
11-12 1747
Hierarchical Segment-based Optimization for SLAM作者:Yuxin Tian, Yujie Wang, Ming Ouyang, Xueson...
路径规划】基于卡尔曼滤波的即时定位与地图构建SLAM多机器人路径规划附matlab实现
matlab_dingdang的博客
02-01 981
为了解决多机器人路径规划问题,本文提出了一种基于卡尔曼滤波的 SLAM 算法。该算法利用卡尔曼滤波器估计机器人的位姿和环境地图,并利用估计结果进行路径规划。实验结果表明,该算法能够有效地解决多机器人路径规划问题,并具有较高的精度和鲁棒性。
【计算机科学】【2016.10】基于SLAM地图的路径规划与优化
weixin_42825609的博客
04-07 907
本文为德国斯图加特大学(作者:Daniel Estler)的学士论文,共55页。 本文通过一个实例说明了基于同步定位与建图(SLAM)方法生成的地图如何用于路径规划和路径优化。为此,讨论了SLAM问题的求解方法,并描述了由此产生的映射的性质。此外,还讨论了路径规划和优化的原理。以TurtleBot为例,说明了在路径规划中适当处理基于SLAM的地图特性的可能性。特别需要注意k阶马尔可夫优化,可用于...
自主移动机器人:slam路径规划的关系
热门推荐
寻玉
02-28 1万+
我们先来看看SLAM路径规划的关系。 实际上,SLAM算法本身只是完成了机器人的定位和地图构建两件事情,与我们说的导航定位并不是完全等价的。这里的导航,其实是SLAM算法做不了的。它在业内叫做运动规划(Motion Planning)。运动规划是一个很大的概念,从机械臂的运动、到飞行器的飞行,再到这里我们说的扫地机的清扫路径规划,都是运动规划的范畴。我们先谈谈针对扫地机这类轮式机器人的运...
【计算机科学】【2019】基于视觉SLAM和对象检测的多目标映射与路径规划
weixin_42825609的博客
12-12 899
本文为加拿大滑铁卢大学(作者:Ami Woo)的硕士论文,共104页。 自主机器人的路径规划是移动机器人智能穿越环境所需的关键任务之一。机器人路径通常是通过利用在一定时间内可访问的地图来规划的,例如最小化旅行距离或时间。本文提出了一种采用图优化和目标检测的基于同时定位和映射(SLAM)多目标路径规划方法。该方法的目的不仅在于找到一条使行驶距离最小化的路径,而且还在于最小化路径中的障碍物数量。本文...
(11-4-02)基于SLAM的自主路径导航系统:路径规划(1)
码农三叔
08-07 922
(3)下面代码实现了基于A*算法路径规划功能,核心功能是A_STAR函数,用于在给定网格地图上计算从起始位置到目标位置的最优路径。订阅了来自激光传感器和里程计的数据,根据接收到的目标位置参数进行路径规划,并通过控制机器人的运动来导航至目标位置。该节点在 ROS 框架中运行,通过订阅机器人的激光雷达和里程计信息,实时更新机器人的位置和地图信息,并根据新的目标点进行路径规划和路径跟踪。(2)下面这段代码实现了感知部分的功能,包括了多个功能函数,这些函数共同实现了机器人感知环境并在RVIZ中进行可视化的功能。
激光SLAM导航系列(四)全局路径规划
月黑风高云游诗人的博客
05-08 7520
全局路径规划简介 机器人移动到目的地需要在做出具体移动策略之前先进行全局路径规划,ROS的navigation中使用global_planner包提供的一系列全局规划的算法接口(包括A*,Dijkstra)。 在本文中我们主要使用A*算法来进行全局路径规划。 A算法* A*(A-Star)算法是一种静态路网中求解最短路径最有效的直接搜索方法,也是解决许多搜索问题的有效算法算法中的距
视觉SLAM算法解析:从基础到应用
文章提到了基于视觉的SLAM算法,它分为初始化、跟踪和映射三个主要步骤,并讨论了视觉SLAM的分类,包括仅视觉SLAM、视觉惯性SLAM和RGB-D SLAM。" 可视化SLAM算法是一种关键的技术,它利用摄像头等传感器数据来同步...
写文章

热门文章

  • 在算法研究过程中如何进行算法创新 150245
  • Verilog中输入数据范围的判断方法整理 102512
  • 217维特比译码器的FPGA设计 101851
  • 收发多径都考虑的情况 100708
  • 【H∞控制】H无穷控制器的matlab仿真 77072

分类专栏

  • ★MATLAB算法仿真经验 付费 338篇
  • ★FPGA项目经验 付费 160篇
  • ★教程1:matlab入门100例 付费 128篇
  • ★教程2:fpga入门100例 付费 117篇
  • ★教程3:Simulink入门60例 付费 78篇
  • ★教程4:fpga/matlab联合开发入门与进阶X例 付费 2篇
  • 第1章·FPGA/MATLAB联合开发软件 付费 15篇
  • 第2章·通信—低阶调制解调 付费 26篇
  • 第3章·通信—高阶调制解调 付费 23篇
  • ★专题1:信道编译码matlab仿真 付费 32篇
  • ★专题2:信息解析与盲处理 付费 25篇
  • ★求职1:深度学习/FPGA/机器视觉/算法手撕代码 付费 127篇
  • ★求职2:大厂笔试面试总结 付费 172篇
  • 前言技术汇集 3篇
  • 通信 1篇
  • 芯片 1篇
  • 机器人 2篇
  • 人工智能 4篇
  • 虚拟现实
  • FPGA/MATLAB精品资源专栏 9篇
  • FPGA技巧整理专栏 15篇
  • MATLAB技巧整理专栏 23篇
  • 部分上传资源仿真展示与分析 134篇
  • MATLAB 1614篇
  • python
  • FPGA 265篇
  • System Generator 10篇
  • 板块1:通信与信号处理 625篇
  • 板块2:图像-特征提取处理 317篇
  • 板块3:AI/神经网络/深度学习 234篇
  • 板块4:编码译码 69篇
  • 板块5:网络通信 67篇
  • 板块6:图像跟踪识别 45篇
  • 板块7:优化类问题 141篇
  • 板块8:控制器 98篇
  • 板块9:二维三维空间定位 27篇
  • 板块10:FPGA接口开发 46篇
  • 板块11:MATLAB数值仿真 33篇
  • 板块12:MATLAB仪器联合应用 3篇
  • 板块13:常见信号处理/ECG/EEG等 10篇
  • 板块14:三维视觉图像处理 20篇
  • 板块15:小波变换 36篇
  • 板块16:语音信号处理 37篇
  • 板块17:加解密 27篇
  • 板块18:FPGA/SIMULINK电路仿真 57篇
  • 板块19:信号发生器 27篇
  • 板块20:新能源 19篇
  • 板块21:混沌 11篇
  • 板块22:参数辨识算法 12篇
  • 板块23:FPGA游戏 3篇
  • 板块24:电动汽车/电池控制 11篇
  • 板块25:电机系统 18篇
  • 面试就业技能——FPGA/芯片/算法工程师 11篇
  • 其他 218篇

最新评论

  • 【教程4>第2章>第13节】 π/4-QPSK解调系统的FPGA开发与matlab对比验证

    fpga和matlab: 我发你私信了,你看下私信

  • 【教程4>第2章>第13节】 π/4-QPSK解调系统的FPGA开发与matlab对比验证

    weixin_53788939: 请问ip核是怎么配置的

  • 【FPGA教程案例36】通信案例6——基于vivado核的FFT傅里叶变换开发以及verilog输入时序配置详解,通过matlab进行辅助验证

    fpga和matlab: 这个是根据FFT核处理时间,得到的延迟值,这样就同步了。你可以对照仿真图自己对比下

  • 【FPGA教程案例36】通信案例6——基于vivado核的FFT傅里叶变换开发以及verilog输入时序配置详解,通过matlab进行辅助验证

    lip__: 请问为啥i_enable要经过#1050+2048*10而不是经过#2048*10后变成0呢?为啥要加1050呢?

  • 基于强化学习的MPC模型预测控制算法仿真,并应用到车辆变道轨迹跟踪控制领域

    嘿大娇: 请问您这篇文章有哪几篇论文可以参考一下吗?

最新文章

  • 基于Actor-Critic结构强化学习的贪吃蛇游戏控制策略研究
  • 【教程4>第3章>第22节】基于双向链路的自适应调制解调通信链路FPGA实现1——MATLAB仿真
  • 【精品资源】基于 CNN 卷积神经网络的调制信号检测识别算法原理
2024
10月 12篇
09月 22篇
08月 25篇
07月 28篇
06月 25篇
05月 26篇
04月 33篇
03月 48篇
02月 38篇
01月 32篇
2023年409篇
2022年1261篇
2021年543篇
2020年472篇
2019年12篇

目录

目录

分类专栏

目录

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fpga和matlab

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或 充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值

玻璃钢生产厂家资兴玻璃钢长颈雕塑铜陵抽象玻璃钢雕塑销售厂家玻璃钢商城广场美陈雕塑加工阳江玻璃钢座椅雕塑制作亳州学校玻璃钢雕塑定制北仑玻璃钢花盆花器动物玻璃钢雕塑厂家直供湛江玻璃钢卡通雕塑现货上海走廊商场美陈厂家直销济宁玻璃钢花盆520商场美陈装修效果图阳泉玻璃钢雕塑设计淮北景观玻璃钢雕塑玻璃钢瓜果雕塑现货淮南特色玻璃钢雕塑生产厂家工业玻璃钢花盆北京景观玻璃钢雕塑批发玻璃钢民俗雕塑设计哪家好革命主题玻璃钢雕塑费用是多少海口玻璃钢雕塑精准推荐上海开业商场美陈售价贵州玻璃钢喷水雕塑定做鹿邑制作玻璃钢雕塑厂选哪家河北常见商场美陈厂家直销金昌动物玻璃钢雕塑制作温州玻璃钢果蔬雕塑广东常见商场美陈北京玻璃钢人像雕塑厂家淮南学校玻璃钢雕塑浙江玻璃钢大猩猩雕塑香港通过《维护国家安全条例》两大学生合买彩票中奖一人不认账让美丽中国“从细节出发”19岁小伙救下5人后溺亡 多方发声单亲妈妈陷入热恋 14岁儿子报警汪小菲曝离婚始末遭遇山火的松茸之乡雅江山火三名扑火人员牺牲系谣言何赛飞追着代拍打萧美琴窜访捷克 外交部回应卫健委通报少年有偿捐血浆16次猝死手机成瘾是影响睡眠质量重要因素高校汽车撞人致3死16伤 司机系学生315晚会后胖东来又人满为患了小米汽车超级工厂正式揭幕中国拥有亿元资产的家庭达13.3万户周杰伦一审败诉网易男孩8年未见母亲被告知被遗忘许家印被限制高消费饲养员用铁锨驱打大熊猫被辞退男子被猫抓伤后确诊“猫抓病”特朗普无法缴纳4.54亿美元罚金倪萍分享减重40斤方法联合利华开始重组张家界的山上“长”满了韩国人?张立群任西安交通大学校长杨倩无缘巴黎奥运“重生之我在北大当嫡校长”黑马情侣提车了专访95后高颜值猪保姆考生莫言也上北大硕士复试名单了网友洛杉矶偶遇贾玲专家建议不必谈骨泥色变沉迷短剧的人就像掉进了杀猪盘奥巴马现身唐宁街 黑色着装引猜测七年后宇文玥被薅头发捞上岸事业单位女子向同事水杯投不明物质凯特王妃现身!外出购物视频曝光河南驻马店通报西平中学跳楼事件王树国卸任西安交大校长 师生送别恒大被罚41.75亿到底怎么缴男子被流浪猫绊倒 投喂者赔24万房客欠租失踪 房东直发愁西双版纳热带植物园回应蜉蝣大爆发钱人豪晒法院裁定实锤抄袭外国人感慨凌晨的中国很安全胖东来员工每周单休无小长假白宫:哈马斯三号人物被杀测试车高速逃费 小米:已补缴老人退休金被冒领16年 金额超20万

玻璃钢生产厂家 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化