📄 simuladorcs.m
字号:
errordlg('耼gulo Invalido:Digite um valor entre -90?e 90?','Erro','on')
set(handles.edittetap,'String',' '); %limpar a caixa
end
% --- Executes during object creation, after setting all properties.
function edittetap_CreateFcn(hObject, eventdata, handles)
% hObject handle to edittetap (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 editVx_Callback(hObject, eventdata, handles)
% hObject handle to editVx (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 editVx as text
% str2double(get(hObject,'String')) returns contents of editVx as a double
% --- Executes during object creation, after setting all properties.
function editVx_CreateFcn(hObject, eventdata, handles)
% hObject handle to editVx (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 editVy_Callback(hObject, eventdata, handles)
% hObject handle to editVy (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 editVy as text
% str2double(get(hObject,'String')) returns contents of editVy as a double
% --- Executes during object creation, after setting all properties.
function editVy_CreateFcn(hObject, eventdata, handles)
% hObject handle to editVy (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 editVz_Callback(hObject, eventdata, handles)
% hObject handle to editVz (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 editVz as text
% str2double(get(hObject,'String')) returns contents of editVz as a double
% --- Executes during object creation, after setting all properties.
function editVz_CreateFcn(hObject, eventdata, handles)
% hObject handle to editVz (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 pbjacobiano.
function pbjacobiano_Callback(hObject, eventdata, handles)
% hObject handle to pbjacobiano (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = hObject;
global teta1 d2 d3 teta4 teta5 teta6 Vx Vy Vz
%%%%%%%%%Guardar valores da posi玢o do rob?
teta1deg=str2num(get(handles.textteta1,'String'));
d2=str2num(get(handles.textd2,'String'));
d3=str2num(get(handles.textd3,'String'));
teta4deg=str2num(get(handles.textteta4,'String'));
teta5deg=str2num(get(handles.textteta5,'String'));
teta6deg=str2num(get(handles.textteta6,'String'));
Vx=str2num(get(handles.editVx,'String'));
Vy=str2num(get(handles.editVy,'String'));
Vz=str2num(get(handles.editVz,'String'));
teta1=(teta1deg*pi)/180;
teta4=(teta4deg*pi)/180;
teta5=(teta5deg*pi)/180;
teta6=(teta6deg*pi)/180;
Jacobiano(hObject, eventdata,handles);
%Jacobiano(hObject, eventdata,handles); %Matlab 7.3
%SimuladorCs('Desenha_robo',hObject, eventdata,handles); %Matlab 7.1
% --- Executes on selection change in listboxPos.
function listboxPos_Callback(hObject, eventdata, handles)
% hObject handle to listboxPos (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 listboxPos contents as cell array
% contents{get(hObject,'Value')} returns selected item from listboxPos
% --- Executes during object creation, after setting all properties.
function listboxPos_CreateFcn(hObject, eventdata, handles)
% hObject handle to listboxPos (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 button press in pbGuarda.
function pbGuarda_Callback(hObject, eventdata, handles)
% hObject handle to pbGuarda (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global tabela_pos;
str_Px=get(handles.textpx,'String');
str_Py=get(handles.textpy,'String');
str_Pz=get(handles.textpz,'String');
str_listbox=get(handles.listboxPos,'String');
if(strcmp(str_listbox,' ')~=0)
[c,l]=size(str_listbox);
str_listbox{c}=['PX:',str_Px,';','PY:',str_Py,';','PZ:',str_Pz,';'];
set(handles.listboxPos,'String',str_listbox);
set(handles.listboxPos,'Value',c);
tabela_pos(c,1)=str2num(get(handles.textpx,'String'));
tabela_pos(c,2)=str2num(get(handles.textpy,'String'));
tabela_pos(c,3)=str2num(get(handles.textpz,'String'));
else
[c,l]=size(str_listbox);
str_listbox{c+1}=['PX:',str_Px,';','PY:',str_Py,';','PZ:',str_Pz,';'];
set(handles.listboxPos,'String',str_listbox);
set(handles.listboxPos,'Value',c+1);
%%Guardar valores numa tabela
tabela_pos(c+1,1)=str2num(get(handles.textpx,'String'));
tabela_pos(c+1,2)=str2num(get(handles.textpy,'String'));
tabela_pos(c+1,3)=str2num(get(handles.textpz,'String'));
end
% s{list_i,1}=strcat('PX:',str_Px,';','PY:',str_Py,';','PZ:',str_Pz,';');
% set(handles.listboxPos,'String',s);
%
% list_i=list_i+1;
%[' datestr(now,13) '] retorna data e hora
% --- Executes on button press in pbDEL.
function pbDEL_Callback(hObject, eventdata, handles)
% hObject handle to pbDEL (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
xx{1}=[' '];
%set(handles.listboxPos,'String',str_listbox);
set(handles.listboxPos,'String',xx);
set(handles.listboxPos,'Value',1);
clear global tabela_pos
% --- Executes on button press in pbtrajectoria.
function pbtrajectoria_Callback(hObject, eventdata, handles)
% hObject handle to pbtrajectoria (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = hObject;
global tabela_pos teta1 d2 d3 d4 l1
%%%%%%Velocidades
Vx=str2num(get(handles.editVx,'String'));
Vy=str2num(get(handles.editVy,'String'));
Vz=str2num(get(handles.editVz,'String'));
Vmodulo=sqrt((Vx^2)+(Vy^2)+(Vz^2));
str_listbox=get(handles.listboxPos,'String');
[c,l]=size(str_listbox);
% Pxantes=str2num(get(handles.textpx,'String'));
% Pyantes=str2num(get(handles.textpy,'String'));
% Pzantes=str2num(get(handles.textpz,'String'));
i=1;
while(i<=c)
Px=tabela_pos(i,1);
Py=tabela_pos(i,2);
Pz=tabela_pos(i,3);
teta1=atan2(Py,Px)+atan2(sqrt(Px^2+Py^2-l1^2),l1);
d2=Pz;
d3=sin(teta1)*Px-cos(teta1)*Py-d4;
pause(0.5);
Desenha_robo(hObject, eventdata,handles); %Matlab 7.3
%SimuladorCs('Desenha_robo',hObject, eventdata,handles); %Matlab 7.1
% if(i>1)
% Pxantes=tabela_pos(i-1,1);
% Pyantes=tabela_pos(i-1,2);
% Pzantes=tabela_pos(i-1,3);
% end
% d=sqrt((Px-Pxantes)^2+(Py-Pyantes)^2+(Pz-Pzantes)^2);
% tempoPercurso=d/Vmodulo;
% tempoIntermedio=tempoPercurso/20;
%
% k=1;%20 itera珲es
% while(k<=20)
% Pxpos=Pxantes+((Px-Pxantes)/20);
% Pypos=Pyantes+((Py-Pyantes)/20);
% Pzpos=Pzantes+((Pz-Pzantes)/20);
% teta1=atan2(Pypos,Pxpos)+atan2(sqrt(Pxpos^2+Pypos^2-l1^2),l1);
% d2=Pzpos;
% d3=sin(teta1)*Pxpos-cos(teta1)*Pypos-d4;
% pause(0.05);
% SimuladorCs('Desenha_robo',hObject, eventdata,handles);
% k=k+1;
% end
i=i+1;
end
% --- Executes on button press in NomeSumulador.
function NomeSumulador_Callback(hObject, eventdata, handles)
% hObject handle to NomeSumulador (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function detectar_Mov_Callback(hObject, eventdata, handles)
% hObject handle to detectar_Mov (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
WebCam;
% --------------------------------------------------------------------
function Manual_Callback(hObject, eventdata, handles)
% hObject handle to Manual (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open Manual_Cs_Simulator.pdf;
% --- Executes on button press in GuardaDados.
function GuardaDados_Callback(hObject, eventdata, handles)
% hObject handle to GuardaDados (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
GuardarDados;
% --- Executes on button press in LerDados.
function LerDados_Callback(hObject, eventdata, handles)
% hObject handle to LerDados (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = hObject;
xx{1}=[' '];
%set(handles.listboxPos,'String',str_listbox);
set(handles.listboxPos,'String',xx);
set(handles.listboxPos,'Value',1);
clear global tabela_pos
global tabela_pos;
global hObjectx evendatax handlesx
hObjectx=hObject;
handlesx=handles;
%SimuladorCs('LerDados',hObject,eventdata,handles);
LerDados;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -