📄 aliwork.m
字号:
case 1 %2 links free
axes(handles.axes1);
cla
set(handles.pushbutton8, 'Visible', 'on');
set(handles.pushbutton9, 'Visible', 'on');
set(handles.pushbutton10, 'Visible', 'off');
set(handles.pushbutton11, 'Visible', 'off');
set(handles.pushbutton3, 'Visible', 'off');
set(handles.pushbutton1, 'Visible', 'off');
set(handles.pushbutton4, 'Visible', 'off');
set(handles.pushbutton5, 'Visible', 'off');
set(handles.phi, 'Visible', 'off');
set(handles.obx, 'Visible', 'off');
set(handles.oby, 'Visible', 'off');
set(handles.text3, 'Visible', 'off');
set(handles.text6, 'Visible', 'off');
set(handles.text7, 'Visible', 'off');
set(handles.uipanel3, 'Visible', 'off');
case 2 % 2links with obstacle
axes(handles.axes1);
cla
set(handles.pushbutton10, 'Visible', 'on');
set(handles.pushbutton11, 'Visible', 'on');
set(handles.pushbutton8, 'Visible', 'off');
set(handles.pushbutton9, 'Visible', 'off');
set(handles.pushbutton3, 'Visible', 'off');
set(handles.pushbutton1, 'Visible', 'off');
set(handles.pushbutton4, 'Visible', 'off');
set(handles.pushbutton5, 'Visible', 'off');
set(handles.phi, 'Visible', 'off');
set(handles.obx, 'Visible', 'on');
set(handles.oby, 'Visible', 'on');
set(handles.text3, 'Visible', 'off');
set(handles.text6, 'Visible', 'on');
set(handles.text7, 'Visible', 'on');
set(handles.uipanel3, 'Visible', 'on');
case 3 %3links free obstacles
axes(handles.axes1);
cla
set(handles.pushbutton3, 'Visible', 'off');
set(handles.pushbutton1, 'Visible', 'off');
set(handles.pushbutton4, 'Visible', 'on');
set(handles.pushbutton5, 'Visible', 'on');
set(handles.pushbutton8, 'Visible', 'off');
set(handles.pushbutton9, 'Visible', 'off');
set(handles.pushbutton10, 'Visible', 'off');
set(handles.pushbutton11, 'Visible', 'off');
set(handles.phi, 'Visible', 'on');
set(handles.obx, 'Visible', 'off');
set(handles.oby, 'Visible', 'off');
set(handles.text3, 'Visible', 'on');
set(handles.text6, 'Visible', 'off');
set(handles.text7, 'Visible', 'off');
set(handles.uipanel3, 'Visible', 'off');
case 4 %3links with obstacle
axes(handles.axes1);
cla
set(handles.pushbutton3, 'Visible', 'on');
set(handles.pushbutton1, 'Visible', 'on');
set(handles.pushbutton4, 'Visible', 'off');
set(handles.pushbutton5, 'Visible', 'off');
set(handles.pushbutton8, 'Visible', 'off');
set(handles.pushbutton9, 'Visible', 'off');
set(handles.pushbutton10, 'Visible', 'off');
set(handles.pushbutton11, 'Visible', 'off');
set(handles.phi, 'Visible', 'on');
set(handles.obx, 'Visible', 'on');
set(handles.oby, 'Visible', 'on');
set(handles.text3, 'Visible', 'on');
set(handles.text6, 'Visible', 'on');
set(handles.text7, 'Visible', 'on');
set(handles.uipanel3, 'Visible', 'on');
end
% --- 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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
set(hObject, 'String', {'2links free','2links with obstacle','3links free','3links with obstacles'})
% --- 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)
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
%preview plot _________ 3links free
axes(handles.axes1);
cla;
axis([-2.7 2.7 -2.7 2.7])
x1=handles.metricdata.x1;
y1=handles.metricdata.y1;
phi=handles.metricdata.phi;
x2=handles.metricdata.x2;
y2=handles.metricdata.y2;
[k,a]=invkini(x1,y1,phi);
if k > 1
warndlg('non valid initial conditions..... change the initial conditions','!! eror !!')
clear
return
end
if sqrt(x2^2+y2^2) > 2.5
warndlg('non valid final conditions..... change the final conditions','!! error !!')
clear
return
end
a=a';
[xt,yt]=angls2links(a);
hold on
plot(xt,yt)
plot(x2,y2,'r+')
shx=0;shy=0;
rx=2.5;ry=2.5;
l=linspace(0,2*pi);
xv=rx*cos(l)'+shx;yv=ry*sin(l)'+shy;
ox2=[xv;xv(1)];oy2=[yv;yv(1)];
plot(ox2,oy2,'m:')
axis([-2.7 2.7 -2.7 2.7])
% --- 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)
axes(handles.axes1);
grid
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% previw plot _________ 2links free
axes(handles.axes1);
cla;
axis([-2.7 2.7 -2.7 2.7])
x1=handles.metricdata.x1;
y1=handles.metricdata.y1;
x2=handles.metricdata.x2;
y2=handles.metricdata.y2;
if sqrt(x1^2+y1^2) > 2
warndlg('non valid initial conditions..... change the initial conditions','!! error !!')
clear
return
end
if sqrt(x2^2+y2^2) > 2
warndlg('non valid final conditions..... change the final conditions','!! error !!')
clear
return
end
a1=invkin(x1,y1);
a2=invkin(x2,y2);
[xt1,yt1]=angls2links2(a1');
[xt2,yt2]=angls2links2(a2');
plot(xt1,yt1,xt2,yt2),hold on
shx=0;shy=0;
rx=2;ry=2;
l=linspace(0,2*pi);
xv=rx*cos(l)'+shx;yv=ry*sin(l)'+shy;
ox2=[xv;xv(1)];oy2=[yv;yv(1)];
plot(ox2,oy2,'m:')
axis([-2.7 2.7 -2.7 2.7])
% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% previw plot _________ 2links obstacle
axes(handles.axes1);
cla;
axis([-2.7 2.7 -2.7 2.7])
x1=handles.metricdata.x1;
y1=handles.metricdata.y1;
x2=handles.metricdata.x2;
y2=handles.metricdata.y2;
if sqrt(x1^2+y1^2) > 2
warndlg('non valid initial conditions..... change the initial conditions','!! error !!')
clear
return
end
if sqrt(x2^2+y2^2) > 2
warndlg('non valid final conditions..... change the final conditions','!! error !!')
clear
return
end
obx=eval(handles.metricdata.obx);
oby=eval(handles.metricdata.oby);
if length(obx)~=1|length(oby)~=1
warndlg('invalid obstacle input data','!! error !!')
clear
return
end
if sqrt(obx^2+oby^2) > 2.5
warndlg('The obstacle is out of rigion','!! error !!')
clear
return
end
a1=invkin(x1,y1);
a2=invkin(x2,y2);
[xt1,yt1]=angls2links2(a1');
[xt2,yt2]=angls2links2(a2');
shx=obx;shy=oby;
rx=.35;ry=0.35;
l=linspace(0,2*pi,20);
xv=rx*cos(l)'+shx;yv=ry*sin(l)'+shy;
ox2=[xv;xv(1)];oy2=[yv;yv(1)];
c1=ox2+i*oy2;
plot(c1,'r')
hold on
plot(xt1,yt1,xt2,yt2)
shx=0;shy=0;
rx=2;ry=2;
l=linspace(0,2*pi);
xv=rx*cos(l)'+shx;yv=ry*sin(l)'+shy;
ox2=[xv;xv(1)];oy2=[yv;yv(1)];
plot(ox2,oy2,'m:')
axis([-2.7 2.7 -2.7 2.7])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -