基于Qlearning强化学习的机器人路线规划仿真

news2024/11/25 12:36:26

目录

1.算法概述

2.仿真效果预览

3.核心MATLAB代码预览

4.完整MATLAB程序


1.算法概述

       假设我们的行为准则已经学习好了, 现在我们处于状态s1, 我在写作业, 我有两个行为 a1, a2, 分别是看电视和写作业, 根据我的经验, 在这种 s1 状态下, a2 写作业 带来的潜在奖励要比 a1 看电视高, 这里的潜在奖励我们可以用一个有关于 s 和 a 的 Q 表格代替, 在我的记忆Q表格中, Q(s1, a1)=-2 要小于 Q(s1, a2)=1, 所以我们判断要选择 a2 作为下一个行为. 现在我们的状态更新成 s2 , 我们还是有两个同样的选择, 重复上面的过程, 在行为准则Q 表中寻找 Q(s2, a1) Q(s2, a2) 的值, 并比较他们的大小, 选取较大的一个. 接着根据 a2 我们到达 s3 并在此重复上面的决策过程. Q learning 的方法也就是这样决策的. 看完决策, 我看在来研究一下这张行为准则 Q 表是通过什么样的方式更改, 提升的.

          机器学习算法可以分为3种:有监督学习(Supervised Learning)、无监督学习(Unsupervised Learning)和强化学习(Reinforcement Learning),如下图所示:
 

在这里插入图片描述

有监督学习、无监督学习、强化学习具有不同的特点:

       有监督学习是有一个label(标记)的,这个label告诉算法什么样的输入对应着什么样的输出,常见的算法是分类、回归等;
无监督学习则是没有label(标记),常见的算法是聚类;
强化学习强调如何基于环境而行动,以取得最大化的预期利益。

主要学习内容:
强化学习是什么,奖励思想。
强化学习的三种途径。
深度强化学习的“深”是什么意思

Q-Learning的QTable标签更新公式:​

​Q-Learning的计算步骤:​

​1.判断在当前位置可以有几种操作;​

​2.根据当前位置允许的操作选择一个操作;​

​3.根据选择的操作进行奖赏;​

​4.修改当前行为的本次操作权重;

2.仿真效果预览

matlab2022a仿真结果如下:

 

3.核心MATLAB代码预览

function varargout =PathPlanning(varargin)
% 移动机器人路径规划仿真平台接口:仿真平台提供了机器人工作环境的仿真界面,利用inf=load('inf'),sp=inf.StartPoint,
% EP=inf.EndPoint,WS=inf.env得到机器人工作环境的出发点、目标点位置及障碍物位置信息,工作空间边界及障碍物区域设置为1,自由空间
%设置为0。 
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Simulation_OpeningFcn, ...
                   'gui_OutputFcn',  @Simulation_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 Simulation_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);
%cd D:\Simulation\EvolvingPath\path
cla
grid on
xlabel('X'); ylabel('Y');
%初始化,获取各对象句柄
handles.StartPoint=findobj('tag','StartPoint'); %获取“设置开始点”按钮句柄
handles.EndPoint=findobj('tag','EndPoint');     %获取“设置目标点”按钮句柄
handles.Obstacle=findobj('tag','Obstacle');     %获取“设置障碍物”按钮句柄
handles.Start=findobj('tag','Start');           %获取“开始运行”按钮句柄
handles.OldEnv=findobj('tag','OldEnv');           %获取“还原环境”按钮句柄
handles.MainAxes=findobj('tag','MainAxes');     %获取主坐标句柄
handles.MainFigure=findobj('tag','MainFigure'); %获取主窗口句柄
%初始化,设置各按钮显示状态
set(handles.StartPoint,'Enable','on')   %“设置开始点”按钮可用
set(handles.EndPoint,'Enable','off')    %“设置目标点”按钮禁用
set(handles.Obstacle,'Enable','off')    %“设置障碍物”按钮禁用
set(handles.Start,'Enable','off')       %“开始运行”按钮禁用
set(handles.OldEnv,'Enable','off')       %“还原环境”按钮可用
set(handles.MainFigure,'WindowButtonDownFcn','');   %
set(handles.MainFigure,'WindowButtonUpFcn','');     %
set(handles.MainAxes,'ButtonDownFcn','');           %
set(handles.MainAxes,'ButtonDownFcn','');           %
inf=load('inf');    %打开环境信息文件,inf.mat由save命令创建,存储了开始点、目标点、障碍物信息等
XLim=20;    %x轴最大取值
YLim=20;    %y轴最大取值
BreakTask=0;        %初始化终止任务变量
    for i=1:XLim  %将边界设置成障碍物
        for j=1:YLim
            if ((i==1)|(i==XLim)|(j==1)|(j==YLim))
                ws(i,j)=1;
            end
        end
    end
save('inf','ws','-append');
save('inf','BreakTask','-append');

% --- Outputs from this function are returned to the command line.
function varargout = Simulation_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;
% --- Executes on button press in StartPoint.
function StartPoint_Callback(hObject, eventdata, handles)
% hObject    handle to StartPoint (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','on')
set(handles.Obstacle,'Enable','off')
set(handles.Start,'Enable','off')
flag=0;
save('inf','flag','-append');
set(handles.MainFigure,'WindowButtonDownFcn','');
set(handles.MainFigure,'WindowButtonUpFcn','');
set(handles.MainAxes,'ButtonDownFcn','PathPlanning(''MainAxes_ButtonDownFcn'',gcbo,[],guidata(gcbo))');
% --- Executes on button press in EndPoint.
function EndPoint_Callback(hObject, eventdata, handles)
% hObject    handle to EndPoint (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','on')
set(handles.Start,'Enable','on')
flag=1;
save('inf','flag','-append');
%set(handles.MainFigure,'WindowButtonDownFcn','');
%set(handles.MainFigure,'WindowButtonUpFcn','');
set(handles.MainAxes,'ButtonDownFcn','PathPlanning(''MainAxes_ButtonDownFcn'',gcbo,[],guidata(gcbo))');
% --- Executes on mouse press over axes background.
function MainAxes_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to MainAxes (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
inf=load('inf');
flag=inf.flag;
start_end=inf.start_end;
p=get(handles.MainAxes,'CurrentPoint');
hold on;
if(flag==0)
    p=round(p);
    start_end(1,1)=p(1,1);start_end(1,2)=p(1,2);   %记录起点信息,给inf.mat文件赋值
    StartPoint(1,1)=p(1,1);StartPoint(1,2)=p(1,2);       %为当前点赋值,当前点为起点的位置信息

    save('inf','StartPoint','-append');
    HRobot=plot(start_end(1,1),start_end(1,2),'pentagram');                %画开始点位置
    text(start_end(1,1)-.5,start_end(1,2)-.5,'Start');
    RobotDirection=inf.RobotDirection;%机器人方向应该是传递参数
    x=start_end(1,1);
    y=start_end(1,2);
    RobotPosX=x;
    RobotPosY=y;
   save('inf','RobotPosX','-append');
   save('inf','RobotPosY','-append');
else
    p=round(p);
    start_end(2,1)=p(1,1);start_end(2,2)=p(1,2);
    EndPoint(1,1)=p(1,1);EndPoint(1,2)=p(1,2);       %为当前点赋值,当前点为结束点的位置信息
    EndPoint=round(EndPoint);
    save('inf','EndPoint','-append');
    plot(start_end(2,1),start_end(2,2),'*','color','r')
    text(start_end(2,1)-.5,start_end(2,2)+.5,'Goal');
end
save('inf','start_end','-append');
set(handles.MainAxes,'ButtonDownFcn','');
set(handles.MainAxes,'ButtonDownFcn','');

% --- 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)
env=zeros(50);
save('inf','env','-append');
set(handles.StartPoint,'Enable','off')
set(handles.EndPoint,'Enable','off')
set(handles.Obstacle,'Enable','on')
set(handles.Start,'Enable','on')
set(handles.OldEnv,'Enable','on')       %“开始运行”按钮禁用
set(handles.MainFigure,'WindowButtonDownFcn','PathPlanning(''MainFigure_WindowButtonDownFcn'',gcbo,[],guidata(gcbo))');
%set(handles.MainFigure,'WindowButtonUpFcn','PathPlanning(''MainFigure_WindowButtonUpFcn'',gcbo,[],guidata(gcbo))');
function MainFigure_WindowButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to MainFigure (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
    inf=load('inf'); 
    ws=inf.env;
    Pos=get(handles.MainAxes,'CurrentPoint');
    Pos=round(Pos);
    XPos=Pos(1,1);YPos=Pos(1,2);       %当前点坐标
    X=[XPos-.5,XPos-.5,XPos+.5,XPos+.5];
    Y=[YPos-.5,YPos+.5,YPos+.5,YPos-.5];
    fill(X,Y,[0 0 0])                   %画障碍物
    text(13-.2,12,'B','color',[1 1 1]);
    text(7-.2,8,'A','color',[1 1 1]);
  %  for i=XPos-1:XPos+1
   %     for j=YPos-1:YPos+1
  %          if((i>0)&(i<=XLim))           %防止出现环境矩阵元素下标为零
  %              if((j>0)&(j<=YLim))
                    ws(XPos,YPos)=1;
  %              end
  %          end
  %      end
  %end
   env=ws;
    save('inf','env','-append');

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


% Hint: get(hObject,'Value') returns toggle state of SensorChecked

function RobotVelocity_Callback(hObject, eventdata, handles)    %设置机器人运行速度
% hObject    handle to RobotVelocity (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of RobotVelocity as text
%        str2double(get(hObject,'String')) returns contents of RobotVelocity as a double   
 
function RobotRadius_Callback(hObject, eventdata, handles)      %设置机器人半径
% hObject    handle to RobotRadius (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of RobotRadius as text
%        str2double(get(hObject,'String')) returns contents of RobotRadius as a double
% --- Executes during object creation, after setting all properties.

function SensorMaxValue_Callback(hObject, eventdata, handles)       %设置传感器测量范围
% hObject    handle to SensorMaxValue (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of SensorMaxValue as text
%        str2double(get(hObject,'String')) returns contents of SensorMaxValue as a double    
    
function Handbook_Callback(hObject, eventdata, handles)                 %系统简介
% hObject    handle to Handbook (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
uiopen('系统简介.txt',1)

function ClearScreen_Callback(hObject, eventdata, handles)      %重新开始
% hObject    handle to ClearScreen (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','on')   %“设置开始点”按钮可用
set(handles.EndPoint,'Enable','off')    %“设置目标点”按钮禁用
set(handles.Obstacle,'Enable','off')    %“设置障碍物”按钮禁用
set(handles.Start,'Enable','off')       %“开始运行”按钮禁用
cla
clear all
% --- Executes on button press in OldEnv.
function OldEnv_Callback(hObject, eventdata, handles)
% hObject    handle to OldEnv (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
XLim=20;    %x轴最大取值
YLim=20;    %y轴最大取值
inf=load('inf');
ws=inf.env;  %得到障碍物信息
SP=inf.StartPoint; %出发点位置
EP=inf.EndPoint;   %目标点位置
set(handles.StartPoint,'Enable','off')
set(handles.EndPoint,'Enable','off')
set(handles.Obstacle,'Enable','off')
set(handles.Start,'Enable','on')
HandleStart=line([SP(1,1) SP(1,1)],[SP(1,2) SP(1,2)]);  %设置开始点
text(SP(1,1)-.5,SP(1,2)-.5,'Start');
HandleTarget=line([EP(1,1) EP(1,1)],[EP(1,2) EP(1,2)]); %设置目标点
text(EP(1,1)-.5,EP(1,2)+.5,'Goal');
set(HandleStart,'marker','pentagram')
set(HandleTarget,'marker','*','color','r')
    for i=1:XLim  %将边界设置成障碍物
        for j=1:YLim
            if ((i==1)|(i==XLim)|(j==1)|(j==YLim))
                ws(i,j)=1;
            end
        end
    end
for i=2:XLim-1                          %还原障碍物信息
    for j=2:YLim-1
        if((ws(i,j)==1))
           X=[i-.5,i-.5,i+.5,i+.5];
            Y=[j-.5,j+.5,j+.5,j-.5];
         fill(X,Y,[0 0 0]);  %设置障碍物
        end
    end
end
           X=[1-.5,1-.5,1+.5,1+.5];
            Y=[6-.5,6+.5,6+.5,6-.5];
         fill(X,Y,[0 0 0]);  %设置障碍物
          X=[1-.5,1-.5,1+.5,1+.5];
            Y=[14-.5,14+.5,14+.5,14-.5];
         fill(X,Y,[0 0 0]);  %设置障碍物
                   X=[10-.5,10-.5,10+.5,10+.5];
            Y=[1-.5,1+.5,1+.5,1-.5];
         fill(X,Y,[0 0 0]);  %设置障碍物
text(13-.2,12,'B','color',[1 1 1]);
text(7-.2,8,'A','color',[1 1 1]);
X=[0,0,.5,.5];
Y=[0,YLim,YLim,0];
fill(X,Y,[0 0 0]);  %设置边界为障碍物
X=[XLim-.5,XLim-.5,XLim,XLim];
Y=[0,YLim,YLim,0];
fill(X,Y,[0 0 0]);  %设置边界为障碍物
X=[0,0,XLim,XLim];
Y=[YLim-.5,YLim,YLim,YLim-.5];
fill(X,Y,[0 0 0]);  %设置边界为障碍物
X=[0,0,XLim,XLim];
Y=[0,.5,.5,0];
fill(X,Y,[0 0 0]);  %设置边界为障碍物
%axis([0 20 0 20])
%机器人当前位置设置为开始位置
RobotPosX=SP(1,1);
RobotPosY=SP(1,2);
    save('inf','RobotPosX','-append');
    save('inf','RobotPosY','-append');
    
function RobotSingleLength_Callback(hObject, eventdata, handles)    %设置单步运行距离
% hObject    handle to RobotSingleLength (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of RobotSingleLength as text
%        str2double(get(hObject,'String')) returns contents of RobotSingleLength as a double

function BreakTask_Callback(hObject, eventdata, handles)
% hObject    handle to BreakTask (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
BreakTask=1;
inf=load('inf');
save('inf','BreakTask','-append');
function SaveAs_Callback(hObject, eventdata, handles)
% hObject    handle to SaveAs (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%saveas(hObject,'g.bmp');
%print(gcf, '-depsc','-tiff','-r600','test.eps')
%saveas(gcf, 'test.eps', 'psc2')
%pause
axes(handles.MainAxes); %取得axes1的句柄
if isempty(handles.MainAxes)
   return;
end
newFig = figure;%由于直接保存axes1上的图像有困难,所以保存在新建的figure中的谱图
set(newFig,'Visible','off','color',[1,1,1])%设置新建的figure为不可见
newAxes = copyobj(handles.MainAxes,newFig);   %将axes1中的图复制到新建的figure中
set(newAxes,'Units','default','Position','default');    % 设置图显示的位置
[filename,pathname] = uiputfile({ '*.tif','figure type(*.tif)'}, '结果另存为');
if isequal(filename,0)||isequal(pathname,0)%如果用户选择“取消”,则退出
    return;
else
    fpath=fullfile(pathname,filename);
end
f = getframe(newFig);
f = frame2im(f);
imwrite(f, fpath);
%saveas(newFig,'filename.eps')
%close(newFig)
%移动机器人路径规划仿真平台程序 END END END END END END END END END END END END END END END END END END END
% --------------------------------------------------------------------
function MainFigure_WindowButtonMotionFcn(hObject, eventdata, handles)
% hObject    handle to MainFigure (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)    
%h=get(handles.MainFigure,'SelectionType')

function RobotRadius_CreateFcn(hObject, eventdata, handles)
% hObject    handle to RobotRadius (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit 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


function mainfig_CreateFcn(hObject, eventdata, handles)
% hObject    handle to mainfig (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% --- Executes during object creation, after setting all properties.
function MainFigure_CreateFcn(hObject, eventdata, handles)
% hObject    handle to MainFigure (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% --- Executes on button press in Start.







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

% Hint: edit 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 during object creation, after setting all properties.
function SensorMaxValue_CreateFcn(hObject, eventdata, handles)
% hObject    handle to SensorMaxValue (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit 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 during object creation, after setting all properties.
function RobotVelocity_CreateFcn(hObject, eventdata, handles)
% hObject    handle to RobotVelocity (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit 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



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

% Hints: get(hObject,'String') returns contents of Sensor1Length as text
%        str2double(get(hObject,'String')) returns contents of Sensor1Length as a double


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

% Hint: edit 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




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

% Hints: get(hObject,'String') returns contents of Sensor2Length as text
%        str2double(get(hObject,'String')) returns contents of Sensor2Length as a double


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

% Hint: edit 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


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

% Hints: get(hObject,'String') returns contents of Sensor3Length as text
%        str2double(get(hObject,'String')) returns contents of Sensor3Length as a double


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

% Hint: edit 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


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

% Hints: get(hObject,'String') returns contents of Sensor4Length as text
%        str2double(get(hObject,'String')) returns contents of Sensor4Length as a double


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

% Hint: edit 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


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

% Hints: get(hObject,'String') returns contents of Sensor5Length as text
%        str2double(get(hObject,'String')) returns contents of Sensor5Length as a double


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

% Hint: edit 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


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

% Hints: get(hObject,'String') returns contents of Sensor6Length as text
%        str2double(get(hObject,'String')) returns contents of Sensor6Length as a double


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

% Hint: edit 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


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

% Hints: get(hObject,'String') returns contents of Sensor7Length as text
%        str2double(get(hObject,'String')) returns contents of Sensor7Length as a double


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

% Hint: edit 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



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

% Hints: get(hObject,'String') returns contents of Sensor8Length as text
%        str2double(get(hObject,'String')) returns contents of Sensor8Length as a double


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

% Hint: edit 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


% --------------------------------------------------------------------

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

% Hints: get(hObject,'String') returns contents of RobotPosX as text
%        str2double(get(hObject,'String')) returns contents of RobotPosX as a double


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

% Hint: edit 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



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

% Hints: get(hObject,'String') returns contents of RobotPosY as text
%        str2double(get(hObject,'String')) returns contents of RobotPosY as a double


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

% Hint: edit 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 selection change in popupmenu6.
function popupmenu6_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu6 (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 popupmenu6 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu6


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

% Hint: popupmenu 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





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

% Hints: get(hObject,'String') returns contents of RobotDirection as text
%        str2double(get(hObject,'String')) returns contents of RobotDirection as a double


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

% Hint: edit 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 selection change in Tasklistbox.
function Tasklistbox_Callback(hObject, eventdata, handles)
% hObject    handle to Tasklistbox (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 Tasklistbox contents as cell array
%        contents{get(hObject,'Value')} returns selected item from Tasklistbox


% --- Executes during object creation, after setting all properties.
function Tasklistbox_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Tasklistbox (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 selection change in AlgorithmListBox.
function AlgorithmListBox_Callback(hObject, eventdata, handles)
% hObject    handle to AlgorithmListBox (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 AlgorithmListBox contents as cell array
%        contents{get(hObject,'Value')} returns selected item from AlgorithmListBox


% --- Executes during object creation, after setting all properties.
function AlgorithmListBox_CreateFcn(hObject, eventdata, handles)
% hObject    handle to AlgorithmListBox (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
A_006

4.完整MATLAB程序

matlab源码说明_我爱C编程的博客-CSDN博客

V

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/13853.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

C++ Reference: Standard C++ Library reference: Containers: deque: deque: assign

C官网参考链接&#xff1a;https://cplusplus.com/reference/deque/deque/assign/ 公有成员函数 <deque> std::deque::assign C98 范围 (1) template <class InputIterator> void assign (InputIterator first, InputIterator last); 填充 (2) void ass…

用户体验成为继MAU后,手机银行竞争分化的下一分水岭,易观千帆重磅发布手机银行APP用户体验GX评测

作为银行金融服务线上场景渗透的有效抓手&#xff0c;当前手机银行APP已经成为其触达用户的重要渠道。随着银行发力场景服务平台成为发展趋势&#xff0c;5G技术问世对金融服务场景端提出新要求&#xff0c;用户体验反馈成为银行线上场景化运营的重要一环。 手机银行APP作为银…

自定义node版本,实现node多版本控制

这是我在安装依赖时报的两个错&#xff0c;一个是关于Cant find Python的问题&#xff0c;一个是node版本过高的问题。我一开始解决这边的Python的问题&#xff0c;网上找了好几个方法&#xff0c;安装了Python&#xff0c;环境配置也配置了&#xff0c;但是还是在报这个错&…

【python3】6.pickle json 序列化

2022.11.17 本学习内容总结于莫烦python:6.pickle/json 序列化 https://mofanpy.com/tutorials/python-basic/interactive-python/pickle-json 参考&#xff1a;https://blog.csdn.net/weixin_43625577/article/details/866997896 pickle/json 序列化 6.1 序列化 序列化&…

Linux-RPM与YUM

RPM包 rpm用于互联网下载包的打包及安装工具&#xff0c;它包含在某些Linux分发版中&#xff0c;它生成具有.RPM扩展名的文件&#xff0c;RPM是RedHat Package Manager&#xff08;RedHat软件包管理工具&#xff09;的缩写&#xff0c;类似于windows的setup.exe rpm包的管理 …

【Hack The Box】windows练习-- Timelapse

HTB 学习笔记 【Hack The Box】windows练习-- Timelapse &#x1f525;系列专栏&#xff1a;Hack The Box &#x1f389;欢迎关注&#x1f50e;点赞&#x1f44d;收藏⭐️留言&#x1f4dd; &#x1f4c6;首发时间&#xff1a;&#x1f334;2022年11月17日&#x1f334; &…

原理图与 PCB 绘制备忘

PCB 绘制 考虑到各制板厂的工艺水平的不同&#xff0c;过孔不可过小&#xff0c;最小为 12/25 mil&#xff0c;常用过孔为 16/28 mil 和 24/40mil 。铺铜时&#xff0c;与管脚有连接时做成部分相连。这是因为整体相连后&#xff0c;焊接元器件时因为铜皮散热快而难以化开焊锡。…

如何使用 Spring Data JPA 在存储过程中使用 IN、OUT 和 INOUT 参数

介绍 在本教程中&#xff0c;我将向您展示如何使用 Spring Data JPA 在存储过程中使用 IN、OUT 和 INOUT 参数。我还将调用一个完全没有参数的存储过程。 我将使用 MySQL 服务器&#xff0c;因此 MySQL 服务器可能存在一些限制&#xff0c;或者 Spring Data JPA 本身在调用存…

【网络安全】记一次APP登录爆破

使用工具 安卓12 jadx-gui 抓取登录HTTP请求包 安装burp证书&#xff0c;并抓取登录请求。 POST /loginUser HTTP/1.1 Host: api.xxxx.xxxxx.comapiaccountvrpuc-aaf91f835147ce2d01216bd3bd5c3516&phonexxxx&sign72C132B392873B3F4F6C0872E5EC4B5A&encM%2F8h…

经典排序方法思路简介

参考&#xff1a;https://zhuanlan.zhihu.com/p/166199924&#xff0c;https://www.runoob.com/w3cnote/ten-sorting-algorithm.html **稳定性&#xff1a;**是表示相同值的数据在排序好的结果中的位置前后关系依然不会变&#xff0c;例如[3,1,3],排序后的最后一个3位置不变&am…

java项目-第141期ssm美好生活日志网-ssm毕业设计_计算机毕业设计

java项目-第141期ssm美好生活日志网-ssm毕业设计 【源码请到资源专栏下载】 今天分享的项目是《ssm美好生活日志网》 该项目分为2个角色&#xff0c;管理员和用户。 用户可以浏览前台,包含功能有&#xff1a; 首页、日记信息、美食信息、景点信息、新闻推荐 、日记展示、论坛信…

【现代密码学原理】——数字签名(学习笔记)

&#x1f4d6; 前言&#xff1a;数字签名&#xff08;又称公钥数字签名&#xff09;是只有信息的发送者才能产生的别人无法伪造的一段数字串&#xff0c;这段数字串同时也是对信息的发送者发送信息真实性的一个有效证明。它是一种类似写在纸上的普通的物理签名&#xff0c;但是…

解读JVM级别本地缓存Caffeine青出于蓝的要诀3

Caffeine的异步淘汰清理机制 在惰性删除实现机制这边&#xff0c;Caffeine做了一些改进优化以提升在并发场景下的性能表现。我们可以和Guava Cache的基于容量大小的淘汰处理做个对比。 当限制了Guava Cache最大容量之后&#xff0c;有新的记录写入超过了总大小&#xff0c;会…

HTML---表单详解

目录 一、表单介绍 二、表单元素 1&#xff1a;input输入表单元素 &#xff08;1&#xff09; text和password &#xff08;2&#xff09;radio和checkbox &#xff08;3&#xff09;button 2&#xff1a;label标签 3&#xff1a;select下拉表单元素 4&#xff1a;textar…

喜报 | 强强联手,这件大事终于有着落了

近日&#xff0c;擎创科技与国产数据库领先品牌——达梦数据库达成战略合作伙伴关系&#xff0c;双方将在品牌、产品、技术、渠道等方面进行全方位合作&#xff0c;共同完成产品整合、资源共享、联合方案等事宜&#xff1b;共同赋能于金融、能源、交通等行业的数字化转型&#…

2019年1+X 证书 Web 前端开发中级理论考试题目原题+答案——第一套

&#x1f4da;文章目录 &#x1f3af;关于1X标准 &#x1f3af;关于中级考点 ⏩&#x1f4bb;答案速查 一、单选题&#xff08;每小题2分&#xff0c;共30小题&#xff0c;共60分&#xff09; 二、多选题&#xff08;每小题2分&#xff0c;共15小题&#xff0c;共30分&…

Java入门-Java语言概述

1、Java语言基本概述 1.1、什么是计算机编程语言 人与人之间是如何沟通的呢&#xff1f;从小父母就教会我们说话&#xff0c;在长期的熏陶和自我学习中&#xff0c;我们就学会了普通话&#xff0c;学会了表达自己的需求&#xff0c;父母收到我们的信号或者听到我们的要求也会尽…

C# 自定义控件

一 自定义控件 1 自定义控件的三种方式&#xff1a; 1&#xff09;复合控件&#xff1a;将标准控件组合起来 class YourControl:UserControl{}2) 扩展控件&#xff1a;继承于标准控件 class YourControl:Button{}3) 自定义控件&#xff1a;完全地自定义一个控件 class You…

CSSStyleSheet 对象(css 样式表)- 你不知道的有趣功能

1.概念 CSSStyleSheet 对象 代表着&#xff0c;css文件被浏览器解析后生成的css样式表。 CSS 样式表由 CSS 规则组成&#xff0c;可以通过 CSSRule 对象操作每条规则。CSSStyleSheet 对象允许您查询、插入和删除样式表规则。 例如&#xff1a;好玩儿的尝试&#xff08;改变页…

基于经验论述:实现k-NN算法

以兰普威尔小镇为例,那里的人们为他们的两支球队——兰普威尔红队和兰普威尔蓝队——而疯狂。红队已经存在很长时间了,人们很喜欢这支队伍。 但是后来,一些外地来的富翁买下了红队的最佳射手,成立了一支新的球队——蓝队。令多数红队球迷不满的是,这位最佳射手将继续带领蓝…