⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cinematicadirecta2.m

📁 Simulador de orientacion posicion de un brazo robotico de cuatro grados de libertad, en GUI de matla
💻 M
📖 第 1 页 / 共 3 页
字号:


function Q3edit_Callback(hObject, eventdata, handles)

le=str2double(get(hObject,'String'));
if le>68
    errordlg('Valor incorrecto o fuera del rango en Q3 "Debe ser un valor entre -68 y 68"','ALERTA');
    set(handles.Q3,'Value',68);
    set(handles.Q3edit,'string',68);
end
if le<-68
    errordlg('Valor incorrecto o fuera del rango en Q3 "Debe ser un valor entre -68 y 68"','ALERTA');
    set(handles.Q3,'Value',-68);
    set(handles.Q3edit,'string',-68);
end

if le<=68 & le>=-68
    set(handles.Q3,'Value',str2double(get(hObject,'String')));
end

q1=str2double(get(handles.Q1edit,'string'));
q2=str2double(get(handles.Q2edit,'string'));
q3=str2double(get(handles.Q3edit,'string'));
q4=str2double(get(handles.Q4edit,'string'));

L1 = 1596;
L2 = 390;
L3 = 1220;
L4 = 1555;
L5 = 172;
dh = [pi/2,  L1,  L2, -pi/2, 0;
     -pi/2,   0,  L3,     0, 0;
      pi/2,   0,  L4,  pi/2, 0;
         0, -L5,   0,     0, 0];
         
q=[q1,q2,q3,q4]*pi/180;
A = directa(dh,q);

set(handles.nx,'String',(round((A(1,1))*100))/100);
set(handles.ny,'String',(round((A(2,1))*100))/100);
set(handles.nz,'String',(round((A(3,1))*100))/100);

set(handles.sx,'String',(round((A(1,2))*100))/100);
set(handles.sy,'String',(round((A(2,2))*100))/100);
set(handles.sz,'String',(round((A(3,2))*100))/100);

set(handles.ax,'String',(round((A(1,3))*100))/100);
set(handles.ay,'String',(round((A(2,3))*100))/100);
set(handles.az,'String',(round((A(3,3))*100))/100);

set(handles.Px,'String',(round((A(1,4))*100))/100);
set(handles.Py,'String',(round((A(2,4))*100))/100);
set(handles.Pz,'String',(round((A(3,4))*100))/100);

% --- Executes during object creation, after setting all properties.
function Q3edit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Q3edit (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 Q2edit_Callback(hObject, eventdata, handles)

le=str2double(get(hObject,'String'));
if le>72
    errordlg('Valor incorrecto o fuera del rango en Q2 "Debe ser un valor entre -72 y 72"','ALERTA');
    set(handles.Q2,'Value',72);
    set(handles.Q2edit,'string',72);
end
if le<-72
    errordlg('Valor incorrecto o fuera del rango en Q2 "Debe ser un valor entre -72 y 72"','ALERTA');
    set(handles.Q2,'Value',-72);
    set(handles.Q2edit,'string',-72);
end
if le<=72 & le>=-72
    set(handles.Q2,'Value',str2double(get(hObject,'String')));
end

q1=str2double(get(handles.Q1edit,'string'));
q2=str2double(get(handles.Q2edit,'string'));
q3=str2double(get(handles.Q3edit,'string'));
q4=str2double(get(handles.Q4edit,'string'));

L1 = 1596;
L2 = 390;
L3 = 1220;
L4 = 1555;
L5 = 172;
dh = [pi/2,  L1,  L2, -pi/2, 0;
     -pi/2,   0,  L3,     0, 0;
      pi/2,   0,  L4,  pi/2, 0;
         0, -L5,   0,     0, 0];
         
q=[q1,q2,q3,q4]*pi/180;
A = directa(dh,q);

set(handles.nx,'String',(round((A(1,1))*100))/100);
set(handles.ny,'String',(round((A(2,1))*100))/100);
set(handles.nz,'String',(round((A(3,1))*100))/100);

set(handles.sx,'String',(round((A(1,2))*100))/100);
set(handles.sy,'String',(round((A(2,2))*100))/100);
set(handles.sz,'String',(round((A(3,2))*100))/100);

set(handles.ax,'String',(round((A(1,3))*100))/100);
set(handles.ay,'String',(round((A(2,3))*100))/100);
set(handles.az,'String',(round((A(3,3))*100))/100);

set(handles.Px,'String',(round((A(1,4))*100))/100);
set(handles.Py,'String',(round((A(2,4))*100))/100);
set(handles.Pz,'String',(round((A(3,4))*100))/100);

% --- Executes during object creation, after setting all properties.
function Q2edit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Q2edit (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 Q1edit_Callback(hObject, eventdata, handles)

le=str2double(get(hObject,'String'));
if le>180
    errordlg('Valor incorrecto o fuera del rango en Q1 "Debe ser un valor entre -180 y 180"','ALERTA');
    set(handles.Q1,'Value',180);
    set(handles.Q1edit,'string',180);
end
if le<-180
    errordlg('Valor incorrecto o fuera del rango en Q1 "Debe ser un valor entre -180 y 180"','ALERTA');
    set(handles.Q1,'Value',-180);
    set(handles.Q1edit,'string',-180);
end
if le<=180 & le>=-180
    set(handles.Q1,'Value',str2double(get(hObject,'String')));
end

q1=str2double(get(handles.Q1edit,'string'));
q2=str2double(get(handles.Q2edit,'string'));
q3=str2double(get(handles.Q3edit,'string'));
q4=str2double(get(handles.Q4edit,'string'));

L1 = 1596;
L2 = 390;
L3 = 1220;
L4 = 1555;
L5 = 172;
dh = [pi/2,  L1,  L2, -pi/2, 0;
     -pi/2,   0,  L3,     0, 0;
      pi/2,   0,  L4,  pi/2, 0;
         0, -L5,   0,     0, 0];
         
q=[q1,q2,q3,q4]*pi/180;
A = directa(dh,q);

set(handles.nx,'String',(round((A(1,1))*100))/100);
set(handles.ny,'String',(round((A(2,1))*100))/100);
set(handles.nz,'String',(round((A(3,1))*100))/100);

set(handles.sx,'String',(round((A(1,2))*100))/100);
set(handles.sy,'String',(round((A(2,2))*100))/100);
set(handles.sz,'String',(round((A(3,2))*100))/100);

set(handles.ax,'String',(round((A(1,3))*100))/100);
set(handles.ay,'String',(round((A(2,3))*100))/100);
set(handles.az,'String',(round((A(3,3))*100))/100);

set(handles.Px,'String',(round((A(1,4))*100))/100);
set(handles.Py,'String',(round((A(2,4))*100))/100);
set(handles.Pz,'String',(round((A(3,4))*100))/100);

% --- Executes during object creation, after setting all properties.
function Q1edit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Q1edit (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 slider movement.
function Q1_Callback(hObject, eventdata, handles)

handles.Q1=get(hObject,'Value');                            %captura el valor del slider Q1 
set(handles.Q1edit,'String',(round(handles.Q1*100))/100);    %colocar el valor del slider en el edit le hace un redondeo

q1=str2double(get(handles.Q1edit,'string'));
q2=str2double(get(handles.Q2edit,'string'));
q3=str2double(get(handles.Q3edit,'string'));
q4=str2double(get(handles.Q4edit,'string'));

L1 = 1596;
L2 = 390;
L3 = 1220;
L4 = 1555;
L5 = 172;
dh = [pi/2,  L1,  L2, -pi/2, 0;
     -pi/2,   0,  L3,     0, 0;
      pi/2,   0,  L4,  pi/2, 0;
         0, -L5,   0,     0, 0];
         
q=[q1,q2,q3,q4]*pi/180;
A = directa(dh,q);

set(handles.nx,'String',(round((A(1,1))*100))/100);
set(handles.ny,'String',(round((A(2,1))*100))/100);
set(handles.nz,'String',(round((A(3,1))*100))/100);

set(handles.sx,'String',(round((A(1,2))*100))/100);
set(handles.sy,'String',(round((A(2,2))*100))/100);
set(handles.sz,'String',(round((A(3,2))*100))/100);

set(handles.ax,'String',(round((A(1,3))*100))/100);
set(handles.ay,'String',(round((A(2,3))*100))/100);
set(handles.az,'String',(round((A(3,3))*100))/100);

set(handles.Px,'String',(round((A(1,4))*100))/100);
set(handles.Py,'String',(round((A(2,4))*100))/100);
set(handles.Pz,'String',(round((A(3,4))*100))/100);

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

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function Q2_Callback(hObject, eventdata, handles)

handles.Q2=get(hObject,'Value');                            %captura el valor del slider Q1 
set(handles.Q2edit,'String',(round(handles.Q2*100))/100);    %colocar el valor del slider en el edit le hace un redondeo

q1=str2double(get(handles.Q1edit,'string'));
q2=str2double(get(handles.Q2edit,'string'));
q3=str2double(get(handles.Q3edit,'string'));
q4=str2double(get(handles.Q4edit,'string'));

L1 = 1596;
L2 = 390;
L3 = 1220;
L4 = 1555;
L5 = 172;
dh = [pi/2,  L1,  L2, -pi/2, 0;
     -pi/2,   0,  L3,     0, 0;
      pi/2,   0,  L4,  pi/2, 0;
         0, -L5,   0,     0, 0];
         
q=[q1,q2,q3,q4]*pi/180;
A = directa(dh,q);

set(handles.nx,'String',(round((A(1,1))*100))/100);
set(handles.ny,'String',(round((A(2,1))*100))/100);
set(handles.nz,'String',(round((A(3,1))*100))/100);

set(handles.sx,'String',(round((A(1,2))*100))/100);
set(handles.sy,'String',(round((A(2,2))*100))/100);
set(handles.sz,'String',(round((A(3,2))*100))/100);

set(handles.ax,'String',(round((A(1,3))*100))/100);
set(handles.ay,'String',(round((A(2,3))*100))/100);
set(handles.az,'String',(round((A(3,3))*100))/100);

set(handles.Px,'String',(round((A(1,4))*100))/100);
set(handles.Py,'String',(round((A(2,4))*100))/100);
set(handles.Pz,'String',(round((A(3,4))*100))/100);

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

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -