Turtlebot与Matlab入门教程-创建UI界面
说明:
- 介绍如何在Matlab创建UI界面
步骤:
在Matlab端:
运行代码turtlebot_UI.m文件
绘制一个控制turtlebot界面,里面包括:
按键“Forward”,“back”,“Left”,“Right”,移动turtlebot。
按键“Get Odom”,绘制一个新的里程计(蓝色)
按键“Get Scan”,绘制当前最新的扫描数据(黑色)
按键“Reset”,重置
按键“Clear”,清楚界面的数据代码如下:
function turtlebot_UI
f = figure('Visible','off','Position',[50,50,900,570]);
hforward = uicontrol('Style','pushbutton',...
'String','Forward','Position',[770,440,70,25],...
'Callback',@forwardCB);
hleft = uicontrol('Style','pushbutton',...
'String','Left','Position',[730,400,70,25],...
'Callback',@leftCB);
hright = uicontrol('Style','pushbutton',...
'String','Right','Position',[815,400,70,25],...
'Callback',@rightCB);
hback = uicontrol('Style','pushbutton',...
'String','Back','Position',[770,360,70,25],...
'Callback',@backCB);
hgetOdom = uicontrol('Style','pushbutton',...
'String','Get Odom','Position',[730,320,70,25],...
'Callback',@getOdomCB);
hreset = uicontrol('Style','pushbutton',...
'String','Reset','Position',[815,320,70,25],...
'Callback',@resetCB);
hgetScan = uicontrol('Style','pushbutton',...
'String','Get Scan','Position',[730,280,70,25],...
'Callback',@getScanCB);
hclear = uicontrol('Style','pushbutton',...
'String','Clear','Position',[815,280,70,25],...
'Callback',@clearCB);
ha = axes('Units','pixels','Position',[50,60,600,400]);
% Make UI visible
f.Visible = 'on';
效果图:
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号