找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5956|回复: 1
打印 上一主题 下一主题
收起左侧

机械臂运动学动力学及轨迹规划GUI界面MATLAB源码

[复制链接]
跳转到指定楼层
楼主
基于MATLAB的机械臂运动学动力学及轨迹规划GUI界面

单片机源程序如下:
  1. function varargout = jacobface(varargin)
  2. % JACOBFACE MATLAB code for jacobface.fig
  3. %      JACOBFACE, by itself, creates a new JACOBFACE or raises the existing
  4. %      singleton*.
  5. %
  6. %      H = JACOBFACE returns the handle to a new JACOBFACE or the handle to
  7. %      the existing singleton*.
  8. %
  9. %      JACOBFACE('CALLBACK',hObject,eventData,handles,...) calls the local
  10. %      function named CALLBACK in JACOBFACE.M with the given input arguments.
  11. %
  12. %      JACOBFACE('Property','Value',...) creates a new JACOBFACE or raises the
  13. %      existing singleton*.  Starting from the left, property value pairs are
  14. %      applied to the GUI before jacobface_OpeningFcn gets called.  An
  15. %      unrecognized property name or invalid value makes property application
  16. %      stop.  All inputs are passed to jacobface_OpeningFcn via varargin.
  17. %
  18. %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
  19. %      instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES

  22. % Edit the above text to modify the response to help jacobface

  23. % Last Modified by GUIDE v2.5 16-Nov-2011 20:35:50

  24. % Begin initialization code - DO NOT EDIT
  25. gui_Singleton = 1;
  26. gui_State = struct('gui_Name',       mfilename, ...
  27.                    'gui_Singleton',  gui_Singleton, ...
  28.                    'gui_OpeningFcn', @jacobface_OpeningFcn, ...
  29.                    'gui_OutputFcn',  @jacobface_OutputFcn, ...
  30.                    'gui_LayoutFcn',  [] , ...
  31.                    'gui_Callback',   []);
  32. if nargin && ischar(varargin{1})
  33.     gui_State.gui_Callback = str2func(varargin{1});
  34. end

  35. if nargout
  36.     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  37. else
  38.     gui_mainfcn(gui_State, varargin{:});
  39. end
  40. % End initialization code - DO NOT EDIT


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

  48. % Choose default command line output for jacobface
  49. handles.output = hObject;

  50. % Update handles structure
  51. guidata(hObject, handles);

  52. % UIWAIT makes jacobface wait for user response (see UIRESUME)
  53. % uiwait(handles.figure1);


  54. % --- Outputs from this function are returned to the command line.
  55. function varargout = jacobface_OutputFcn(hObject, eventdata, handles)
  56. % varargout  cell array for returning output args (see VARARGOUT);
  57. % hObject    handle to figure
  58. % eventdata  reserved - to be defined in a future version of MATLAB
  59. % handles    structure with handles and user data (see GUIDATA)

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


  62. % --- Executes on selection change in popupmenu1.
  63. function popupmenu1_Callback(hObject, eventdata, handles)
  64. % hObject    handle to popupmenu1 (see GCBO)
  65. % eventdata  reserved - to be defined in a future version of MATLAB
  66. % handles    structure with handles and user data (see GUIDATA)

  67. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
  68. %        contents{get(hObject,'Value')} returns selected item from popupmenu1


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

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



  79. function edit1_Callback(hObject, eventdata, handles)
  80. % hObject    handle to edit1 (see GCBO)
  81. % eventdata  reserved - to be defined in a future version of MATLAB
  82. % handles    structure with handles and user data (see GUIDATA)

  83. % Hints: get(hObject,'String') returns contents of edit1 as text
  84. %        str2double(get(hObject,'String')) returns contents of edit1 as a double


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

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


  95. % --- Executes on button press in pushbutton1.
  96. function pushbutton1_Callback(hObject, eventdata, handles)
  97. % hObject    handle to pushbutton1 (see GCBO)
  98. % eventdata  reserved - to be defined in a future version of MATLAB
  99. % handles    structure with handles and user data (see GUIDATA)
  100. %从外部文件导入关节速度数据
  101. global Q6;
  102. Q6=csvread('关节速度.txt');
  103. set(handles.uitable1,'data',Q6);

  104. % --- Executes on button press in pushbutton2.
  105. function pushbutton2_Callback(hObject, eventdata, handles)
  106. % hObject    handle to pushbutton2 (see GCBO)
  107. % eventdata  reserved - to be defined in a future version of MATLAB
  108. % handles    structure with handles and user data (see GUIDATA)
  109. %将关节速度数据导入外部文件进行保存
  110. global Q6;
  111. csvwrite('关节速度.txt',get(handles.uitable1,'data'));

  112. % --- Executes on selection change in popupmenu2.
  113. function popupmenu2_Callback(hObject, eventdata, handles)
  114. % hObject    handle to popupmenu2 (see GCBO)
  115. % eventdata  reserved - to be defined in a future version of MATLAB
  116. % handles    structure with handles and user data (see GUIDATA)

  117. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
  118. %        contents{get(hObject,'Value')} returns selected item from popupmenu2


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

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



  129. function edit2_Callback(hObject, eventdata, handles)
  130. % hObject    handle to edit2 (see GCBO)
  131. % eventdata  reserved - to be defined in a future version of MATLAB
  132. % handles    structure with handles and user data (see GUIDATA)

  133. % Hints: get(hObject,'String') returns contents of edit2 as text
  134. %        str2double(get(hObject,'String')) returns contents of edit2 as a double


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

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


  145. % --- Executes on button press in pushbutton3.
  146. function pushbutton3_Callback(hObject, eventdata, handles)
  147. % hObject    handle to pushbutton3 (see GCBO)
  148. % eventdata  reserved - to be defined in a future version of MATLAB
  149. % handles    structure with handles and user data (see GUIDATA)
  150. %将末端操作器速度数据导入外部文件进行保存
  151. global Q7;
  152. Q7=csvread('末端速度.txt');
  153. set(handles.uitable2,'data',Q7);
  154. % --- Executes on button press in pushbutton4.
  155. function pushbutton4_Callback(hObject, eventdata, handles)
  156. % hObject    handle to pushbutton4 (see GCBO)
  157. % eventdata  reserved - to be defined in a future version of MATLAB
  158. % handles    structure with handles and user data (see GUIDATA)
  159. %将末端操作器速度数据导入外部文件进行保存
  160. global Q7;
  161. csvwrite('末端速度.txt',get(handles.uitable2,'data'));

  162. % --- Executes on button press in pushbutton5.
  163. function pushbutton5_Callback(hObject, eventdata, handles)
  164. % hObject    handle to pushbutton5 (see GCBO)
  165. % eventdata  reserved - to be defined in a future version of MATLAB
  166. % handles    structure with handles and user data (see GUIDATA)
  167. %正向雅克比:由关节速度推算末端操作器的速度
  168. global L Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q QD QDD ICAN DH JACOB;
  169. Q7=Q6*JACOB';
  170. set(handles.uitable2,'data',Q7);%将关节速度写入表格2
  171. % --- Executes on button press in pushbutton6.
  172. function pushbutton6_Callback(hObject, eventdata, handles)
  173. % hObject    handle to pushbutton6 (see GCBO)
  174. % eventdata  reserved - to be defined in a future version of MATLAB
  175. % handles    structure with handles and user data (see GUIDATA)
  176. global L Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q QD QDD ICAN DH JACOB;
  177. Q6=Q7/JACOB';
  178. set(handles.uitable1,'data',Q6);%将关节速度写入表格2

  179. % --- Executes on button press in pushbutton7.
  180. function pushbutton7_Callback(hObject, eventdata, handles)
  181. % hObject    handle to pushbutton7 (see GCBO)
  182. % eventdata  reserved - to be defined in a future version of MATLAB
  183. % handles    structure with handles and user data (see GUIDATA)
  184. %该界面消失返回主界面
  185. set(jacobface,'visible','off');

  186. % --- Executes on button press in pushbutton8.
  187. function pushbutton8_Callback(hObject, eventdata, handles)
  188. % hObject    handle to pushbutton8 (see GCBO)
  189. % eventdata  reserved - to be defined in a future version of MATLAB
  190. % handles    structure with handles and user data (see GUIDATA)
  191. %计算雅克比矩阵
  192. global L Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q QD QDD ICAN DH JACOB;
  193. JACOB=jacob0(ICAN,Q);
  194. set(handles.uitable3,'data',JACOB);%将雅克比矩阵写入表格一


  195. % --- Executes on button press in pushbutton9.
  196. function pushbutton9_Callback(hObject, eventdata, handles)
  197. % hObject    handle to pushbutton9 (see GCBO)
  198. % eventdata  reserved - to be defined in a future version of MATLAB
  199. % handles    structure with handles and user data (see GUIDATA)
  200. global L Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q QD QDD ICAN DH JACOB;
  201. %写入各个关节的速度
  202. i=get(handles.popupmenu1,'value');%选择输入第I个关节的速度
  203. Q6(i)=str2num(get(handles.edit1,'string'));
  204. set(handles.uitable1,'data',Q6);%将关节速度写入表格2
  205. % --- Executes on button press in pushbutton10.
  206. function pushbutton10_Callback(hObject, eventdata, handles)
  207. % hObject    handle to pushbutton10 (see GCBO)
  208. % eventdata  reserved - to be defined in a future version of MATLAB
  209. % handles    structure with handles and user data (see GUIDATA)
  210. global L Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q QD QDD ICAN DH JACOB;
  211. %写入末端操作器各个方向的速度和角速度
  212. i=get(handles.popupmenu2,'value');%选择输入第I个关节的速度
  213. Q7(i)=str2num(get(handles.edit2,'string'));
  214. set(handles.uitable2,'data',Q7);%将关节速度写入表格2
复制代码

所有资料51hei提供下载:
机器臂运动学、动力学轨迹规划界面.rar (58.23 KB, 下载次数: 80)


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:800785 发表于 2020-7-10 12:18 | 只看该作者
代码显示回调函数错误?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表