基于MATLAB的機械臂運動學動力學及軌跡規劃GUI界面
0.png (50.43 KB, 下載次數: 49)
下載附件
2018-4-25 19:02 上傳
單片機源程序如下:
- function varargout = jacobface(varargin)
- % JACOBFACE MATLAB code for jacobface.fig
- % JACOBFACE, by itself, creates a new JACOBFACE or raises the existing
- % singleton*.
- %
- % H = JACOBFACE returns the handle to a new JACOBFACE or the handle to
- % the existing singleton*.
- %
- % JACOBFACE('CALLBACK',hObject,eventData,handles,...) calls the local
- % function named CALLBACK in JACOBFACE.M with the given input arguments.
- %
- % JACOBFACE('Property','Value',...) creates a new JACOBFACE or raises the
- % existing singleton*. Starting from the left, property value pairs are
- % applied to the GUI before jacobface_OpeningFcn gets called. An
- % unrecognized property name or invalid value makes property application
- % stop. All inputs are passed to jacobface_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 jacobface
- % Last Modified by GUIDE v2.5 16-Nov-2011 20:35:50
- % Begin initialization code - DO NOT EDIT
- gui_Singleton = 1;
- gui_State = struct('gui_Name', mfilename, ...
- 'gui_Singleton', gui_Singleton, ...
- 'gui_OpeningFcn', @jacobface_OpeningFcn, ...
- 'gui_OutputFcn', @jacobface_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 jacobface is made visible.
- function jacobface_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 jacobface (see VARARGIN)
- % Choose default command line output for jacobface
- handles.output = hObject;
- % Update handles structure
- guidata(hObject, handles);
- % UIWAIT makes jacobface wait for user response (see UIRESUME)
- % uiwait(handles.figure1);
- % --- Outputs from this function are returned to the command line.
- function varargout = jacobface_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 selection change in popupmenu1.
- function popupmenu1_Callback(hObject, eventdata, handles)
- % hObject handle to popupmenu1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
- % contents{get(hObject,'Value')} returns selected item from popupmenu1
- % --- Executes during object creation, after setting all properties.
- function popupmenu1_CreateFcn(hObject, eventdata, handles)
- % hObject handle to popupmenu1 (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 edit1_Callback(hObject, eventdata, handles)
- % hObject handle to edit1 (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 edit1 as text
- % str2double(get(hObject,'String')) returns contents of edit1 as a double
- % --- Executes during object creation, after setting all properties.
- function edit1_CreateFcn(hObject, eventdata, handles)
- % hObject handle to edit1 (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 pushbutton1.
- function pushbutton1_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- %從外部文件導入關節速度數據
- global Q6;
- Q6=csvread('關節速度.txt');
- set(handles.uitable1,'data',Q6);
- % --- Executes on button press in pushbutton2.
- function pushbutton2_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton2 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- %將關節速度數據導入外部文件進行保存
- global Q6;
- csvwrite('關節速度.txt',get(handles.uitable1,'data'));
- % --- Executes on selection change in popupmenu2.
- function popupmenu2_Callback(hObject, eventdata, handles)
- % hObject handle to popupmenu2 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
- % contents{get(hObject,'Value')} returns selected item from popupmenu2
- % --- Executes during object creation, after setting all properties.
- function popupmenu2_CreateFcn(hObject, eventdata, handles)
- % hObject handle to popupmenu2 (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 edit2_Callback(hObject, eventdata, handles)
- % hObject handle to edit2 (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 edit2 as text
- % str2double(get(hObject,'String')) returns contents of edit2 as a double
- % --- Executes during object creation, after setting all properties.
- function edit2_CreateFcn(hObject, eventdata, handles)
- % hObject handle to edit2 (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 pushbutton3.
- function pushbutton3_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton3 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- %將末端操作器速度數據導入外部文件進行保存
- global Q7;
- Q7=csvread('末端速度.txt');
- set(handles.uitable2,'data',Q7);
- % --- Executes on button press in pushbutton4.
- function pushbutton4_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton4 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- %將末端操作器速度數據導入外部文件進行保存
- global Q7;
- csvwrite('末端速度.txt',get(handles.uitable2,'data'));
- % --- Executes on button press in pushbutton5.
- function pushbutton5_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton5 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- %正向雅克比:由關節速度推算末端操作器的速度
- global L Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q QD QDD ICAN DH JACOB;
- Q7=Q6*JACOB';
- set(handles.uitable2,'data',Q7);%將關節速度寫入表格2
- % --- Executes on button press in pushbutton6.
- function pushbutton6_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton6 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global L Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q QD QDD ICAN DH JACOB;
- Q6=Q7/JACOB';
- set(handles.uitable1,'data',Q6);%將關節速度寫入表格2
- % --- Executes on button press in pushbutton7.
- function pushbutton7_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton7 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- %該界面消失返回主界面
- set(jacobface,'visible','off');
- % --- Executes on button press in pushbutton8.
- function pushbutton8_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton8 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- %計算雅克比矩陣
- global L Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q QD QDD ICAN DH JACOB;
- JACOB=jacob0(ICAN,Q);
- set(handles.uitable3,'data',JACOB);%將雅克比矩陣寫入表格一
- % --- Executes on button press in pushbutton9.
- function pushbutton9_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton9 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global L Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q QD QDD ICAN DH JACOB;
- %寫入各個關節的速度
- i=get(handles.popupmenu1,'value');%選擇輸入第I個關節的速度
- Q6(i)=str2num(get(handles.edit1,'string'));
- set(handles.uitable1,'data',Q6);%將關節速度寫入表格2
- % --- Executes on button press in pushbutton10.
- function pushbutton10_Callback(hObject, eventdata, handles)
- % hObject handle to pushbutton10 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global L Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q QD QDD ICAN DH JACOB;
- %寫入末端操作器各個方向的速度和角速度
- i=get(handles.popupmenu2,'value');%選擇輸入第I個關節的速度
- Q7(i)=str2num(get(handles.edit2,'string'));
- set(handles.uitable2,'data',Q7);%將關節速度寫入表格2
復制代碼
所有資料51hei提供下載:
機器臂運動學、動力學軌跡規劃界面.rar
(58.23 KB, 下載次數: 80)
2018-4-25 15:33 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|