function varargout = PUMA560(varargin)
% PUMA560 MATLAB code for PUMA560.fig
% PUMA560, by itself, creates a new PUMA560 or raises the existing
% singleton*.
%
% H = PUMA560 returns the handle to a new PUMA560 or the handle to
% the existing singleton*.
%
% PUMA560('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in PUMA560.M with the given input arguments.
%
% PUMA560('Property','Value',...) creates a new PUMA560 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before PUMA560_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to PUMA560_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 PUMA560
% Last Modified by GUIDE v2.5 31-Dec-2020 10:03:03
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @PUMA560_OpeningFcn, ...
'gui_OutputFcn', @PUMA560_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 PUMA560 is made visible.
function PUMA560_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 PUMA560 (see VARARGIN)
% Choose default command line output for PUMA560
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes PUMA560 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
global pos_x
global pos_y
global pos_z
pos_x=0;
pos_y=0;
pos_z=0;
global px
global py
global pz
px=0;
py=0;
pz=0;
% --- Outputs from this function are returned to the command line.
function px_Callback(hObject, eventdata, handles)
% hObject handle to px (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 px as text
% str2double(get(hObject,'String')) returns contents of px as a double
% --- Executes during object creation, after setting all properties.
function px_CreateFcn(hObject, eventdata, handles)
% hObject handle to px (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 py_Callback(hObject, eventdata, handles)
% hObject handle to py (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 py as text
% str2double(get(hObject,'String')) returns contents of py as a double
% --- Executes during object creation, after setting all properties.
function py_CreateFcn(hObject, eventdata, handles)
% hObject handle to py (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 pz_Callback(hObject, eventdata, handles)
% hObject handle to pz (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 pz as text
% str2double(get(hObject,'String')) returns contents of pz as a double
% --- Executes during object creation, after setting all properties.
function pz_CreateFcn(hObject, eventdata, handles)
% hObject handle to pz (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 posx_CreateFcn(hObject, eventdata, handles)
% hObject handle to posx (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 posy_CreateFcn(hObject, eventdata, handles)
% hObject handle to posy (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 posz_CreateFcn(hObject, eventdata, handles)
% hObject handle to posz (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
function varargout = PUMA560_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 load_puma560.
function load_puma560_Callback(hObject, eventdata, handles)
% hObject handle to load_puma560 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global pos_x
global pos_y
global pos_z
mdl_puma560
if (str2double(handles.posx.String)==0)&&(str2double(handles.posy.String)==0)&&(str2double(handles.posz.String)==0)
pos_x=1;
pos_y=1;
pos_z=1;
p1 = [pos_x pos_y pos_z] ; %待抓取球体位置
elseif (str2double(handles.posx.String)~=0)||(str2double(handles.posy.String)~=0)||(str2double(handles.posz.String)~=0)
pos_x=str2double(handles.posx.String);
pos_y=str2double(handles.posy.String);
pos_z=str2double(handles.posz.String);
p1 = [pos_x pos_y pos_z] ; %待抓取球体位置
end
global px
global py
global pz
if (str2double(handles.px.String)==0)&&(str2double(handles.py.String)==0)&&(str2double(handles.pz.String)==0)
px=0.1272;
py=0.7858;
pz=0.03258;
p2=[px py pz];
elseif (str2double(handles.px.String)~=0)||(str2double(handles.py.String)~=0)||(str2double(handles.pz.String)~=0)
px=str2double(handles.px.String);
py=str2double(handles.py.String);
pz=str2double(handles.pz.String);
p2=[px py pz];
end
T = transl(p1) * troty(pi/2);%待抓取球体的位置和姿态
Tt= transl(p2) * troty(pi/2);%放置位置的位置和姿态
q1= p560.ikine6s(Tt, 'ru');%机械臂起始位置
qqr = p560.ikine6s(T, 'ru');