⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gridsimulation.m

📁 matlab实现机器人基于栅格法的路径规划
💻 M
📖 第 1 页 / 共 2 页
字号:
function varargout = GridSimulation(varargin)
% GRIDSIMULATION M-file for GridSimulation.fig
%      GRIDSIMULATION, by itself, creates a new GRIDSIMULATION or raises the existing
%      singleton*.
%
%      H = GRIDSIMULATION returns the handle to a new GRIDSIMULATION or the handle to
%      the existing singleton*.
%
%      GRIDSIMULATION('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GRIDSIMULATION.M with the given input arguments.
%
%      GRIDSIMULATION('Property','Value',...) creates a new GRIDSIMULATION or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GridSimulation_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GridSimulation_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help GridSimulation

% Last Modified by GUIDE v2.5 25-Sep-2006 16:51:08
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @GridSimulation_OpeningFcn, ...
                   'gui_OutputFcn',  @GridSimulation_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before GridSimulation is made visible.
function GridSimulation_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to GridSimulation (see VARARGIN)

% Choose default command line output for GridSimulation
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GridSimulation wait for user response (see UIRESUME)
% uiwait(handles.mainfig);
cla
global GridNumber
GridNumber=20;
DrawRectangle(GridNumber);
handles.StartPoint=findobj('tag','StartPoint');
handles.EndPoint=findobj('tag','EndPoint');
handles.Obstacle=findobj('tag','Obstacle');
handles.Start=findobj('tag','Start');
set(handles.StartPoint,'Enable','on')
set(handles.EndPoint,'Enable','off')
set(handles.Obstacle,'Enable','off')
set(handles.Start,'Enable','off')

%DrawRectangle
function DrawRectangle(m)
Dxy=1/m;
XNum=round(1.4/Dxy);
for i=1:1:m+1
    line([0 1.4],[Dxy*(i-1) Dxy*(i-1)],'Color',[0 1 0]);
    i=i+1;
end
for i=1:1:XNum+1
    line([Dxy*(i-1) Dxy*(i-1)],[0 1],'Color',[0 1 0]);
    i=i+1;
end
% --- Outputs from this function are returned to the command line.
function varargout = GridSimulation_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

% --------------------------------------------------------------------
function GridSimulation_Callback(hObject, eventdata, handles)
% hObject    handle to GridSimulation (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function FileExit_Callback(hObject, eventdata, handles)
% hObject    handle to FileExit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close(gcf);
% --------------------------------------------------------------------
function TowPointExp_Callback(hObject, eventdata, handles)
% hObject    handle to TowPointExp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function GridSim_Callback(hObject, eventdata, handles)
% hObject    handle to GridSim (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function GridExp_Callback(hObject, eventdata, handles)
% hObject    handle to GridExp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function NNSim_Callback(hObject, eventdata, handles)
% hObject    handle to NNSim (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function NNExp_Callback(hObject, eventdata, handles)
% hObject    handle to NNExp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function FNNSim_Callback(hObject, eventdata, handles)
% hObject    handle to FNNSim (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function FNNExp_Callback(hObject, eventdata, handles)
% hObject    handle to FNNExp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns listbox1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox1


% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in Start.
function Start_Callback(hObject, eventdata, handles)
% hObject    handle to Start (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in End.
function End_Callback(hObject, eventdata, handles)
% hObject    handle to End (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in Obstacle.
function Obstacle_Callback(hObject, eventdata, handles)
% hObject    handle to Obstacle (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.StartPoint,'Enable','off')
set(handles.EndPoint,'Enable','off')
set(handles.Obstacle,'Enable','off')
set(handles.Start,'Enable','on')
global GridNumber;
for i=1:100 %设置障碍物
[x,y,k]=ginput(1);
if k==3 return;end %设置障碍物时按右键结束
x=x*GridNumber;y=y*GridNumber;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -