function varargout = speedplan_draw(varargin)
% SPEEDPLAN_DRAW MATLAB code for speedplan_draw.fig
% SPEEDPLAN_DRAW, by itself, creates a new SPEEDPLAN_DRAW or raises the existing
% singleton*.
%
% H = SPEEDPLAN_DRAW returns the handle to a new SPEEDPLAN_DRAW or the handle to
% the existing singleton*.
%
% SPEEDPLAN_DRAW('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SPEEDPLAN_DRAW.M with the given input arguments.
%
% SPEEDPLAN_DRAW('Property','Value',...) creates a new SPEEDPLAN_DRAW or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before speedplan_draw_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to speedplan_draw_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 speedplan_draw
% Last Modified by GUIDE v2.5 11-Jan-2014 23:18:40
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @speedplan_draw_OpeningFcn, ...
'gui_OutputFcn', @speedplan_draw_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 speedplan_draw is made visible.
function speedplan_draw_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 speedplan_draw (see VARARGIN)
% Choose default command line output for speedplan_draw
handles.output = hObject;
%**********************添加背景***********%%%%%%%%%%%%%%
ha=axes('units','normalized','position',[0 0 1 1]);%找的不懂
uistack(ha,'down')%根据背景图片的关系设置down/top/boutton
II=imread('HITsz.jpg');
image(II)
colormap gray %不太懂
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes speedplan_draw wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = speedplan_draw_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;
function edit_Vmax_Callback(hObject, eventdata, handles)
% hObject handle to edit_Vmax (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 edit_Vmax as text
% str2double(get(hObject,'String')) returns contents of edit_Vmax as a double
% --- Executes during object creation, after setting all properties.
function edit_Vmax_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_Vmax (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 edit_Amax_Callback(hObject, eventdata, handles)
% hObject handle to edit_Amax (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 edit_Amax as text
% str2double(get(hObject,'String')) returns contents of edit_Amax as a double
% --- Executes during object creation, after setting all properties.
function edit_Amax_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_Amax (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 edit_Jmax_Callback(hObject, eventdata, handles)
% hObject handle to edit_Jmax (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 edit_Jmax as text
% str2double(get(hObject,'String')) returns contents of edit_Jmax as a double
% --- Executes during object creation, after setting all properties.
function edit_Jmax_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_Jmax (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 edit_Kmax_Callback(hObject, eventdata, handles)
% hObject handle to edit_Kmax (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 edit_Kmax as text
% str2double(get(hObject,'String')) returns contents of edit_Kmax as a double
% --- Executes during object creation, after setting all properties.
function edit_Kmax_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_Kmax (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 edit_T_Callback(hObject, eventdata, handles)
% hObject handle to edit_T (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 edit_T as text
% str2double(get(hObject,'String')) returns contents of edit_T as a double
% --- Executes during object creation, after setting all properties.
function edit_T_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_T (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 button_aJerkT.
function button_aJerkT_Callback(hObject, eventdata, handles)
% hObject handle to button_aJerkT (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%组合字符串求****加加速度为T型求他的值
% %%***************求得t2值,即速度从0到Jmax所需时间***********%
flg_ok=getappdata(handles.ok,'flg_ok');
flg_VT=getappdata(handles.button_VT,'flg_VT');
flg_AT=getappdata(handles.button_AT,'flg_AT');
if (1==flg_ok)
s=getappdata(handles.ok,'s');%所走的路程
s_angle=getappdata(handles.ok,'s_angle');
Vmax=getappdata(handles.ok,'Vmax');
Amax=getappdata(handles.ok,'Amax');
m_t=getappdata(handles.ok,'m_t');
Jmax=getappdata(handles.ok,'Jmax');
Kmax=getappdata(handles.ok,'Kmax');
% Js_t=Jerk_t(); %获取各区间的加加速度曲线方程
% ti=time();
% Vs_t=V_t();
% As=A_t();
% t1=Jmax/Kmax;
% t2=Amax/Jmax; %面积相等
% t3=t2+t1;
% Vs_t(3);
% v_3=double(subs(Vs_t(3),{'t','t1','t2','Kmax'},{t3,t1,t2,Kmax}))%匀加速前的速度
% t4=(Vmax-2*v_3)/Amax+t3;
% t5=t4+t1;t6=t4+t2;t7=t6+t1;
% Ds_t=D_t();
% Ds_t(7);
% D_t7=double(subs(Ds_t(7),{'t','t1','t2','Kmax','t4'},{t7,t1,t2,Kmax,t4}))
% t8=(s-2*D_t7)/Vmax+t7; %匀速行驶,的时间结束点,
% t9=t8+t1;t10=t8+t2;t11=t10+t1,t12=t8+t4,t13=t12+t1;t14=t12+t2;t15=t14+t1;
% t_out=0:m_t:t15
% %setappdata(handles.ok,'z1',z1); %%例子设置全局变量
% setappdata(handles.button_aJerkT,'t1',t1);
% setappdata(handles.button_aJerkT,'t2',t2);
% setappdata(handles.button_aJerkT,'t4',t4);
% setappdata(handles.button_aJerkT,'t8',t8);
t1=Jmax/Kmax;
t2=Amax/Jmax; %??I??
t3=t1+t2;
t4=Vmax/Amax; %A??±???
%A??????
%t4=(s-2*distance3)/Vmax+t3; %???????????±??
t5=t4+t1;
t6=t4+t2;
t7=t6+t1;
t8=s/Vmax;
t9=t8+t1;
t10=t8+t2;
t11=t8+t3;
t12=t8+t4;
t13=t12+t1;
t14=t12+t2;
t15=t12+t3;
%*************??????????**************%
A1=Kmax*t1^2/2;
V1=Kmax*t1^3/3;
L1=Kmax*t1^4/24;
A2=A1+Jmax*(t2-t1);
V2=V1+A1*(t2-t1)+Jmax*(t2-t1)^2/2;
L2=L1+V1*(t2-t1)+A1*(t2-t1)^2/2+Jmax*(t2-t1)^3/6;
A3=A2+Jmax*(t3-t2)-Kmax*(t3-t2)^2/2;
V3=V2+A2*(t3-t2)+Jmax*(t3-t2)^2/2-Kmax*(t3-t2)^3/6;
L3=L2+V2*(t3-t2)+A2*(t3-t2)^2/2+Jmax*(t3-t2)^3/6-Kmax*(t3-t2)^4/24;
A4=Amax;
V4=V3+Amax*(t4-t3);
L4=L3+V3*(t4-t3)+Amax*(t4-t3)^2/2;
A5=A4-Kmax*(t5-t4)^2/2;
V5=V4+A4*(t5-t4)-Kmax*(t5-t4)^3/6;
L5=L4+V4*(t5-t4)+A4*(t5-t4)^2/2-Kmax*(t5-t4)^4/24;
A6=A5-Jmax*(t6-t5);
V6=V5+A5*(t6-t5)-Jmax*(t6-t5)^2/2;
L6=L5+V5*(t6-t5)+A5*(t6-t5)^2/2-Jmax*(t6-t5)^3/6;
A7=A6-Jmax*(t7-t6)+Kmax*(t7-t6)^2/2;
V7=V6+A6*(t7-t6)-Jmax*(t7-t6)^2/2+Kmax*(t7-t6)^3/6;
L7=L6+V6*(t7-t6)+A6*(t7-t6)^2/2-Jmax*(t7-t6)^3/6+Kmax*(t7-t6)^4/24;
A8=0;
V8=Vmax;
L8=L7+Vmax*(t8-t7);
A9=A8-Kmax*(t9-t8)^2/2;
V9=V8+A8*(t9-t8)-Kmax*(t9-t8)^3/6;
L9=L8+V8*(t9-t8)+A8*(t9-t8)^2/2-Kmax*(t9-t8)^4/24;
A10=A9-Jmax*(t10-t9);
V10=V9+A9*(t10-t9)-Jmax*(t10-t9)^2/2;
L10=L9+V9*(t10-t9)+A9*(t10-t9)^2/2-Jmax*(t10-t9)^3/6;
A11=A10-Jmax*(t11-t10)+Kmax*(t11-t10)^2/2;
V11=V10+A10*(t11-t10)-Jmax*(t11-t10)^2/2+Kmax*(t11-t10)^3/6;
L11=L10+V10*(t11-t10)-Jmax*(t11-t10)^3/6+Kmax*(t11-t10)^4/24;
A12=-Amax;
V12=V11-Amax*(t12-t11);
L12=L11+V11*(t12-t11)-Amax*(t12-t11)^2/2;
A13=A12+Kmax*(t13-t12)^2/2;
V13=V12+A12*(t13-t12)+Kmax*(t13-t12)^3/6;
L13=L12+V12*(t13-t12)+A12*(t13-t12)^2/2+Kmax*(t13-t12)^4/24;
A14=A13+Jmax*(t14-t13);
V14=V13+A13*(t14-t13)+Jmax*(t14-t13)^2/2;
L14=L13+V13*(t14-t13)+A13*(t14-t13)^2/2+Jmax*(t14-t13)^3/6;
A15=A14+Jmax*(t15-t14)-Kmax*(t15-t14)^2/2;
V15=V14+A14*(t15-t14)+Jmax*(t15-t14)^2/2-Kmax*(t15-t14)^3/6
L15=L14+V14*(t15-t14)+A14*(t15-t14)^2/2+Jmax*(t15-t14)^2/6-Kmax*(t15-t14)^4/24;
% distance2=distance1+v1*(t2-t1)+Amax*(t2-t1)^2/2;
% v3=v2+Amax*(t3-t2)-Jmax*(t3-t2)^2/2;
% distance3=distance2+v2*(t3-t2)+Amax*(t3-t2)^2/2-Jmax*(t3-t2)^3/6;
% v4=Vmax;
% distance4=distance3+Vmax*(t4-t3);
% v5=Vmax-Jmax*(t5-t4)*(t5-t4)/2;
% distance5=distance4+Vmax*(t5-t4)-Jmax*(t5-t4)^3/6;
% v6=v5-Amax*(t6-t5); %%%%%%%??????±????ì??????
% distance6=distance5+v5*(t6-t5)-Amax*(t6-t5)^2/2;
% v7=v6-Amax*(t7-t6)+Jmax*(t7-t6)^2/2;
% distance7=distance6+v6*(t7-t6)-Amax*(t7-t6)^2/2+Jmax*(t7-t6)^3/6;
%********************?¨????????????????????????????????*************%
i=1
for t=0:m_t:t15;
if t<=t1
Kj_out(i)=Kmax;
Jj_out(i)=Kmax*t;%??????
Aj_out(i)=1/2*Kmax*t^2;
Vj_out(i)=1/6*Kmax*t^3;
Lj_out(i)=1/24*Kmax*t^4;
elseif t<=t2
Kj_out(i)=0;
Jj_out(i)=Jmax;%??????
Aj_out(i)=A1+Jmax*(t-t1);
Vj_out(i)=V1+A1*(t-t1)+Jmax*(t-t1)^2/2;
Lj_out(i)=L1+V1*(t-t1)+A1*(t-t1)^2/2+Jmax*(t-t1)^3/6;
elseif t<t3
Kj_out(i)=-Kmax;
Jj_out(i)=Jmax-Kmax*(t-t2);%??????
Aj_out(i)=A2+Jmax*(t-t2)-Kmax*(t-t2)^2/2;
Vj_out(i)=V2+A2*(t-t2)+Jmax*(t-t2)^2/2-Kmax*(t-t2)^3/6;
Lj_out(i)=L2+V2*(t-t2)+A2*(t-t2)^2/2+Jmax*(t-t2)^3/6-Kmax*(t-t2)^4/24;
elseif t<=t4
Kj_out(i)=0;
Jj_out(i)=0;%??????
Aj_out(i)=Amax;
Vj_out(i)=V3+Amax*(t-t3);
Lj_out(i)=L3+V3*(t-t3)+Amax*(t-t3)^2/2;
elseif t<=t5
Kj_out(i)=-Kmax;
Jj_out(i)=-Kmax*(t-t4);%??????
Aj_out(i)=A4-Kmax*(t-t4)^2/2;
Vj_out(i)=V4+A4*(t-t4)-Kmax*(t-t4)^3/6;
Lj_out(i)=L4+V4*(t-t4)+A4*(t-t4)^2/2-Kmax*(t-t4)^4/24;
elseif t<=t6
Kj_out(i)=0;
Jj_out(i)=-Jmax;%??????
Aj_out(i)=A5-Jmax*(t-t5);
Vj_out(i)=V5+A5*(t-t5)-Jmax*(t-t5)^2/2;
Lj_out(i)=L5+V5*(t-t5)+A5*(t-t5)^2/2-Jmax*(t-t5)^3/6;
elseif t<=t7
Kj_out(i)=Kmax;
Jj_out(i)=-Jmax+Kmax*(t-t6);%??????
Aj_out(i)=A6-Jmax*(t-t6)+Kmax*(t-t6)^2/2;
Vj_out(i)=V6+A6*(t-t6)-Jmax*(t-t6)^2/2+Kmax*(t-t6)^3/6;
Lj_out(i)=L6+V6*(t-t6)+A6*(t-t6)^2/2-Jmax*(t-t6)^3/6+Kmax*(t-t6)^4/24;
elseif t<=t8
Kj_out(i)=0
Jj_out(i)=0;%??????
Aj_out(i)=0;
Vj_out(i)=Vmax;
Lj_out(i)=L7+Vmax*(t-t7);
elseif t<=t9
Kj_out(i)=-Kmax;
Jj_out(i)=-Kmax*(t-t8);%??????
Aj_out(i)=A8-Kmax*(t-t8)^2/2;
Vj_out(i)=V8+A8*(t-t8)-Kmax*(t-t8)^3/6;
Lj_out(i)=L8+V8*(t-t8)+A8*(t-t8)^2/2-Kmax*(t-t8)^4/24;
elseif t<=t10
Kj_out(i)=0;
Jj_out(i)=-Jmax;%??????
Aj_out(i)=A9-Jmax*(t-t9);
Vj_out(i)=V9+A9*(t-t9)-Jmax*(t-t9)^2/2;
Lj_out(i)=L9+V9*(t-t9)+A9*(t-t9)^2/2-Jmax*(t-t9)^3/6;
elseif t<=t11
Kj_out(i)=Kmax;
Jj_out(i)=-Jmax+Kmax*(t-t10);%??????
Aj_out(i)=A10-Jmax*(t-t10)+Kmax*(t-t10)^2/2;
Vj_out(i)=V10+A10*(t-t10)-Jmax*(t-t10)^2/2+Kmax*(t-t10)^3/6;
Lj_out(i)=L10+V10*(t-t10)-Jmax*(t-t10)^3/6+Kmax*(t-t10)^4/24;
elseif t<=t12
Kj_out(i)=0;
Jj_out(i)=0;%??????
Aj_out(i)=-Amax;
Vj_out(i)=V11-Amax*(t-t11);
Lj_out(i)=L11+V11*(t-t11)-Amax*(t-t11)^2/2;
elseif t<=t13
Kj_out(i)=Kmax;
Jj_out(i)=Kmax*(t-t12);%??????
Aj_out(i)=A12+Kmax*(t-t12)^2/2;
Vj_out(i)=V12+A12*(t-t12)+Kmax*(t-t12)^3/6;
Lj_out(i)=L12+V12*(t-t12)+A12*(t-t12)^2/2+Kmax*(t-t12)^4/24;
elseif t<=t14
Kj_out(i)=0;
Jj_out(i)=Jmax;%??????
Aj_out(i)=A13+Jmax*(t-t13);
Vj_out(i)=V13+A13*(t-t13)+Jmax*(t-t13)^2/2;
Lj_out(i)=L13+V13*(t-t13)+A13*(t-t13)^2/2+Jmax*(t-t13)^3/6;
else
Kj_out(i)=-Kmax;
Jj_out(i)=Jmax-Kmax*(t-t14);%??????
Aj_out(i)=A14+Jmax*(t-t14)-Kmax*(t-t14)^2/2;
Vj_out(i)=V14+A14*(t-t14)+Jmax*(t-t14)^2/2-Kmax*(t-t14)^3/6
Lj_out(i)=L14+V14*(t-t14)+A14*(t-t14)^2/2+Jmax*(t-t14)^2/6-Kmax*(t-t14)^4/24;
end
i=i+1;
end
% setappdata(handles.button_aJerkT,'t_out',t_out);//用符号型做的
tj_out=0:m_t:t15
plot3(handles.plot_xyz,Lj_out.*s_angle(1),Lj_out.*s_angle(2),Lj_out.*s_angle(3),'*')
setappdata(handles.button_aJerkT,'tj_out',tj_out);
setappdata(handles.button_aJerkT,'Lj_out',Lj_out);
setappdata(handles.button_aJerkT,'Aj_out',Aj_out);
setappdata(handles.button_aJerkT,'Vj_out',Vj_out);
setappdata(handles.button_aJerkT,'Jj_out',Jj_out);
%*********************判断按钮加速度为T型触发没************%
flg_aJerkT=1;
setappdata(handles.button_aJerkT,'flg_aJerkT',flg_aJerkT);
else
warndlg('请按确定键');
end
% J_out=Jend_draw(t1,t2,t4,t8,Kmax,m_t); %%加加速度的速度图像
% A_out=Aend_draw(t1,t2,t4,t8,Kmax,m_t);
% V_out=Vend_draw(t1,t2,t4,t8,Kmax,m_t);
% %m_out=[t_out;V_out] %%输出时间和速度仿真,
% d_out=Dend_draw(t1,t2,t4,t8,Kmax,m_t);
% md_out=[t_out;d_out] %%输出时间和位移进行仿真
%plot3(handles.plot_xyz,d_out.*s_angle(1),d_out.*s_angle(2),d_out.*s_angle(3),'*')
% --- Executes on button press in button_VT.
function button_VT_Callback(hObject, eventdata, handles)
% hObject handle to button_VT (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%**************速度为T型,并且正确出图************************************%
flg_ok=getappdata(handles.ok,'flg_ok');
flg_VT=getappdata(handles.button_VT,'flg_VT');
flg_AT=getappdata(handles.button_AT,'flg_AT');
flg_aJerkT=getappdata(handles.button_aJerkT,'flg_aJerkT');
if (flg_ok==1)
s=getappdata(handles.ok,'s');%所走的路程
Vmax=getappdata(handles.ok,'Vmax');
Amax=getappdata(handles.ok,'Amax');
m_t=getappdata(handles.ok,'m_t');
s_angle=getappdata(handles.ok,'s_angle');
Jmax=getappdata(handles.ok,'Jmax');
Kmax=getappdata(handles.ok,'Kmax');
if(Jmax~=0)||(Kmax~=0)||(m_t<=0)
warndlg('不符合参数要求');
% close(figure1); %%a没搞懂***********%%%%%%
else
t1=Vmax/Amax;t2=s/Vmax;t3=t1+t2;
i=1;%************* 插补赋值*******************%
for t=0:m_t:t3
if t<=t1
L(i)=Amax*t*t/2;
V(i)=Amax*t;
A(i)=Amax;
elseif t<=t2
L(i)=Vmax*t1/2+Vmax*(t-t1);
V(i)=Vmax;
A(i)=0;
else
L(i)=s-(t3-t)^2*Amax/2;
V(i)=Amax*(t3-t);
A(i)=-Amax;
end
i=i+1;
end
tv_out=0:m_t:t3;
%plot(handles.plot_distance,t,L)%绘制路程图像
setappdata(handles.button_VT,'tv_out',tv_out);
setappdata(handles.button_VT,'L',L);
setappdata(handles.button_VT,'A',A);
setappdata(handles.button_VT,'V',V);
flg_VT=1;
setappdata(handles.button_VT,'flg_VT',flg_VT);
plot3(handles.plot_xyz,L.*s_angle(1),L.*s_angle(2),L.*s_angle(3),'*')
end
else
warndlg('请按确定键');
end
% for i=0:4
% view(-37.4,30+i*30);
% pause(2);
% end
% --- Executes on button press in button_AT.
function button_AT_Callback(hObject, eventdata, handles)
% hObject handle to button_AT (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
flg_ok=getappdata(handles.ok,'flg_ok');
if (flg_ok==1)
s=getappdata(handles.ok,'s');%所走的路程
Vmax=getappdata(handles.ok,'Vmax');
Amax=getappdata(handles.ok,'Amax');
m_t=getappdata(handles.ok,'m_t');
s_angle=getappdata(handles.ok,'s_angle');
Jmax=getappdata(handles.ok,'Jmax');
Kmax=getappdata(handles.ok,'Kmax');
if(Jmax<=0)||(Kmax<=0)||(m_t<=0)||(Vmax<=0)
warndlg('不符合参数要求');
else
t1=Amax/Jmax; %第I段
t2=Vmax/Amax; %A不变段
t3=t1+t2;%A下降段
t4=s/Vmax;%对称的面积关系
%t4=(s-2*distance3)/Vmax+t3; %匀速运动的时间
t5=t4+t1;
t6=t4+t2;
t7=t6+t1;
%*************重新算位移**************%
v1=Jmax*(t1)^2/2;
distance1=(Jmax*t1*t1*t1)/6;
v2=v1+Amax*(t2-t1);%用数学方法求解出来。
distance2=distance1+v1*(t2-t1)+Amax*(t2-t1)^2/2;
v3=v2+Amax*(t3-t2)-Jmax*(t3-t2)^2/2;
distance3=distance2+v2*(t3-t2)+Amax*(t3-t2)^2/2-Jmax*(t3-t2)^3/6;
v4=Vmax;
distance4=distance3+Vmax*(t4-t3);
v5=Vmax-Jmax*(t5-t4)*(t5-t4)/2;
distance5=distance4+Vmax*(t5-t4)-Jmax*(t5-t4)^3/6;
v6=v5-Amax*(t6-t5); %%%%%%%写的方便观察特点。
distance6=distance5+v5*(t6-t5)-Amax*(t6-t5)^2/2;
v7=v6-Amax*(t7-t6)+Jmax*(t7-t6)^2/2;
distance7=distance6+v6*(t7-t6)-Amax*(t7-t6)^2/2+Jmax*(t7-t6)^3/6;
i=1
%********************通过符号型计算而来的公式,进行赋值*************%
% for t=0:m_t:t7;
% if t<=t1
% Ja_out(i)=Jmax;%第一段
% Aa_out(i)=Jmax*t;
% Va_out(i)=1/2*Jmax*t*t;
% La_out(i)=(Jmax*t*t*t)/6;
% elseif t<=t2
% Ja_out(i)=0;
% Aa_out(i)=Amax;
% Va_out(i)=Amax*t-1/2*Amax*t1;%1/2*Amax*t1+Amax*(t-t1)
% La_out(i)=distance1+(Amax*t*(t - t1))/2;
% elseif t<=t3
% Ja_out(i)=-Jmax;
% Aa_out(i)=Jmax*(t3-t);
% Va_out(i)=Vmax-1/2*Jmax*(t3-t)*(t3-t);
% La_out(i)=distance2-((t - t2)*(Amax*t^2 + Amax*t*t2 - 3*Amax*t*t3 + Amax*t2^2 - 3*Amax*t2*t3 + 3*Amax*t3^2 - 6*Vmax))/6;
% elseif t<=t4
% Ja_out(i)=0;
% Aa_out(i)=0;
% Va_out(i)=Vmax;
% La_out(i)=distance3+Vmax*(t - t3);
% elseif t<=t5
% Ja_out(i)=-Jmax;
% Aa_out(i)=-Jmax*(t-t4);
% Va_out(i)=Vmax-Jmax*(t-t4)*(t-t4)/2;
% La_out(i)=distance4+((t - t4)*(- Jmax*t^2 + 2*Jmax*t*t4 - Jmax*t4^2 + 6*Vmax))/6;
% elseif t<=t6
% Ja_out(i)=0;
% Aa_out(i)=-Amax;
% Va_out(i)=1/2*Amax*t1+Amax*(t6-t);
% La_out(i)=distance5-(Amax*(t - t5)*(t - t1 + t5 - 2*t6))/2
% else %if t<=t7
% Ja_out(i)=Jmax;
% Aa_out(i)=-Jmax*(t7-t);
% Va_out(i)=(t7-t)*(t7-t)/2*Jmax;
% La_out(i)=distance6+(Jmax*(t - t6)*(t^2 + t*t6 - 3*t*t7 + t6^2 - 3*t6*t7 + 3*t7^2))/3;
% 符号型为什么会存在误差。
for t=0:m_t:t7;
if t<=t1
Ja_out(i)=Jmax;%
Aa_out(i)=Jmax*t;
Va_out(i)=Jmax*t*t/2;
La_out(i)=(Jmax*t*t*t)/6;
elseif t<=t2
Ja_out(i)=0;
Aa_out(i)=Amax;
Va_out(i)=v1+Amax*(t-t1);%Amax*t-1/2*Amax*t1,??????????
La_out(i)=distance1+v1*(t-t1)+Amax*(t-t1)^2/2;
elseif t<=t3
Ja_out(i)=-Jmax;
Aa_out(i)=Amax-Jmax*(t-t2);
Va_out(i)=v2+Amax*(t-t2)-Jmax*(t-t2)^2/2;
La_out(i)=distance2+v2*(t-t2)+Amax*(t-t2)^2/2-Jmax*(t-t2)^3/6;
elseif t<=t4
Ja_out(i)=0;
Aa_out(i)=0;
Va_out(i)=Vmax;
La_out(i)=distance3+Vmax*(t-t3);
elseif t<=t5
Ja_out(i)=-Jmax;
Aa_out(i)=-Jmax*(t-t4);
Va_out(i)=Vmax-Jmax*(t-t4)*(t-t4)/2;
La_out(i)=distance4+Vmax*(t-t4)-Jmax*(t-t4)^3/6;
elseif t<=t6
Ja_out(i)=0;
Aa_out(i)=-Amax;
Va_out(i)=v5-Amax*(t-t5);
La_out(i)=distance5+v5*(t-t5)-Amax*(t-t5)^2/2;
else %if t<=t7
Ja_out(i)=Jmax;
Aa_out(i)=-Amax+Jmax*(t-t6);
Va_out(i)=v6-Amax*(t-t6)+Jmax*(t-t6)^2/2;
La_out(i)=distance6+v6*(t-t6)-Amax*(t-t6)^2/2+Jmax*(t-t6)^3/6;
end
i=i+1;
end
ta_out=0:m_t:t7;
%*************************画出位置图形*********************************
plot3(handles.plot_xyz,La_out.*s_angle(1),La_out.*s_angle(2),La_out.*s_angle(3),'*')
setappdata(handles.button_AT,'ta_out',ta_out);
setappdata(handles.button_AT,'La_out',La_out);
setappdata(handles.button_AT,'Aa_out',Aa_out);
setappdata(handles.button_AT,'Va_out',Va_out);
setappdata(handles.button_AT,'Ja_out',Ja_out);
flg_AT=1
setappdata(handles.button_AT,'flg_AT',flg_AT);
end
else
warndlg('请按确定键');
end
function edit_x0_Callback(hObject, eventdata, handles)
% hObject handle to edit_x0 (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 edit_x0 as text
% str2double(get(hObject,'String')) returns contents of edit_x0 as a double
% --- Executes during object creation, after setting all properties.
function edit_x0_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_x0 (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 edit_y0_Callback(hObject, eventdata, handles)
% hObject handle to edit_y0 (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 edit_y0 as text
% str2double(get(hObject,'String')) returns contents of edit_y0 as a double
% --- Executes during object creation, after setting all properties.
function edit_y0_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_y0 (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 edit_z0_Callback(hObject, eventdata, handles)
% hObject handle to edit_z0 (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 edit_z0 as text
% str2double(get(hObject,'String')) returns contents of edit_z0 as a double
% --- Executes during object creation, after setting all properties.
function edit_z0_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_z0 (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 edit_x1_Callback(hObject, eventdata, handles)
% hObject handle to edit_x1 (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 edit_x1 as text
% str2double(get(hObject,'String')) returns contents of edit_x1 as a double
% --- Executes during object creation, after setting all properties.
function edit_x1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_x1 (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 edit_y1_Callback(hObject, eventdata, handles)
% hObject handle to edit_y1 (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 edit_y1 as text
% str2double(get(hObject,'String')) returns contents of edit_y1 as a double
% --- Executes during object creation, after setting all properties.
function edit_y1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_y1 (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 edit_z1_Callback(hObject, eventdata, handles)
% hObject handle to edit_z1 (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 edit_z1 as text
% str2double(get(hObject,'String')) returns contents of edit_z1 as a double
% --- Executes during object creation, after setting all properties.
function edit_z1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_z1 (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 ok.
function ok_Callback(hObject, eventdata, handles)
% hObject handle to ok (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clc
x0=get(handles.edit_x0,'string');x0=str2double(x0); %接收数据相当于接收全局变量
setappdata(handles.ok,'x0',x0);
y0=get(handles.edit_y0,'string');y0=str2double(y0);
setappdata(handles.ok,'y0',y0);
z0=get(handles.edit_z0,'string');z0=str2double(z0);
setappdata(handles.ok,'z0',z0);
x1=get(handles.edit_x1,'string');x1=str2double(x1);
setappdata(handles.ok,'x1',x1);
y1=get(handles.edit_y1,'string');y1=str2double(y1);
setappdata(handles.ok,'y1',y1);
z1=get(handles.edit_z1,'string');z1=str2double(z1);
setappdata(handles.ok,'z1',z1);
Vmax=get(handles.edit_Vmax,'string');Vmax=str2double(Vmax);
setappdata(handles.ok,'Vmax',Vmax);
Amax=get(handles.edit_Amax,'string');Amax=str2double(Amax);
setappdata(handles.ok,'Amax',Amax);
Jmax=get(handles.edit_Jmax,'string');Jmax=str2double(Jmax);
setappdata(handles.ok,'Jmax',Jmax);
Kmax=get(handles.edit_Kmax,'string');Kmax=str2double(Kmax);
setappdata(handles.ok,'Kmax',Kmax);
m_t=get(handles.edit_T,'string');m_t=str2double(m_t);
setappdata(handles.ok,'m_t',m_t); %%句柄是什么形式的。
if (Vmax<0)||(Amax<0)||(Jmax<0)||(Kmax<0)||(m_t<0)
warndlg('不符合参数要求,存在小于零的');
close %%a没搞懂***********%%%%%%
end
%求两点之间的距离
s=sqrt((x1-x0)^2+(y1-y0)^2+(z1-z0)^2);
distance_0=[x0 y0 z0];distance_1=[x1 y1 z1];%起点和终点
s_fx=distance_1-distance_0; % 运动的直线方向
s_angle=s_fx/s; %单位向量
setappdata(handles.ok,'s',s); %传递距离参数
setappdata(handles.ok,'s_angle',s_angle);%单位向量
s=num2str(s,'%.5f');
set(handles.sta_distance,'string',s);
%***************************判断ok,键点击下去没*********************%
flg_ok=1
setappdata(handles.ok,'flg_ok',flg_ok);
flg_VT=0;
setappdata(handles.button_VT,'flg_VT',flg_VT);
flg_AT=0;
setappdata(handles.button_AT,'flg_AT',flg_AT);
flg_aJerkT=0;
setappdata(handles.button_aJerkT,'flg_aJerkT',flg_aJerkT);
% --- Executes on button press in but_disfig.
function but_disfig_Callback(hObject, eventdata, handles)
flg_VT=getappdata(handles.button_VT,'flg_VT');
flg_AT=getappdata(handles.button_AT,'flg_AT');
flg_aJerkT=getappdata(handles.button_aJerkT,'flg_aJerkT');
if flg_VT==1 %************满足条件VT***********
tv_out=getappdata(handles.button_VT,'tv_out');
L=getappdata(handles.button_VT,'L');
figure(4)
plot(tv_out,L,'LineWidth',2)
grid on;
hold on;
legend('速度T型,路程曲线');
%*************************加速度为T型*****************
elseif flg_AT==1
ta_out=getappdata(handles.button_AT,'ta_out');
La_out=getappdata(handles.button_AT,'La_out');
figure(4)
plot(ta_out,La_out,'LineWidth',2)
grid on;
hold on;
legend('加速度T型,路程曲线');
elseif flg_aJerkT==1
%******************加加速度为T型*********************%
% t1=getappdata(handles.button_aJerkT,'t1');
% t2=getappdata(handles.button_aJerkT,'t2');
% t4=getappdata(handles.button_aJerkT,'t4');
% t8=getappdata(handles.button_aJerkT,'t8');
% t_out=getappdata(handles.button_aJerkT,'t_out');
% s=getappdata(handles.ok,'s');%所走的路程
% s_angle=getappdata(handles.ok,'s_angle');
% Kmax=getappdata(handles.ok,'Kmax');
% m_t=getappdata(handles.ok,'m_t')
% %J_out=Jend_draw(t1,t2,t4,t8,Kmax,m_t); %%加加速度的速度图像
% % A_out=Aend_draw(t1,t2,t4,t8,Kmax,m_t); %%绘制加速度图像,顺便保存图像
% % V_out=Vend_draw(t1,t2,t4,t8,Kmax);
% % m_out=[t_out;V_out] %%输出时间和速度仿真,
% d_out=Dend_draw(t1,t2,t4,t8,Kmax,m_t);
% md_out=[t_out;d_out] %%输出时间和位移进行仿真
% setappdata(handles.but_disfig,'d_out',d_out);
% plot3(handles.plot_xyz,d_out.*s_angle(1),d_out.*s_angle(2),d_out.*s_angle(3),'*');
% setappdata(handles.button_aJerkT,' flg_aJerkT', flg_aJerkT);
tj_out=getappdata(handles.button_aJerkT,'tj_out');
Lj_out=getappdata(handles.button_aJerkT,'Lj_out');
figure(4)
plot(tj_out,Lj_out,'LineWidth',2)
grid on;
hold on;
legend('加速度T型,路程曲线');
else
warndlg('请选择速度规划模式!')
end
% --- Executes on button press in but_vfig.
function but_vfig_Callback(hObject, eventdata, handles)
flg_ok=getappdata(handles.ok,'flg_ok');
flg_VT=getappdata(handles.button_VT,'flg_VT');
flg_AT=getappdata(handles.button_AT,'flg_AT')
flg_aJerkT=getappdata(handles.button_aJerkT,'flg_aJerkT');
if flg_VT==1 %************满足条件VT***********
tv_out=getappdata(handles.button_VT,'tv_out');
V=getappdata(handles.button_VT,'V');
figure(3)
plot(tv_out,V,'LineWidth',2)
grid on;
hold on;
legend('速度T型,速度曲线');
% flg_VT=0;
% setappdata(handles.button_VT,'flg_VT',flg_VT);
%*************************加速度为T型*****************
elseif flg_AT==1
ta_out=getappdata(handles.button_AT,'ta_out');
Va_out=getappdata(handles.button_AT,'Va_out');
figure(3)
plot(ta_out,Va_out,'LineWidth',2)
grid on;
hold on;
legend('加速度T型,速度曲线');
% flg_AT=0;
% setappdata(handles.button_AT,'flg_AT',flg_AT);
elseif flg_aJerkT==1
%******************加加速度为T型*********************%
% t1=getappdata(handles.button_aJerkT,'t1');
% t2=getappdata(handles.button_aJerkT,'t2');
% t4=getappdata(handles.button_aJerkT,'t4');
% t8=getappdata(handles.button_aJerkT,'t8');
% t_out=getappdata(handles.button_aJerkT,'t_out');
% Kmax=getappdata(handles.ok,'Kmax');
% m_t=getappdata(handles.ok,'m_t')
% V_out=Vend_draw(t1,t2,t4,t8,Kmax,m_t);
% m_out=[t_out;V_out] %%输出时间和速度仿真,
% setappdata(handles.but_vfig,'V_out',V_out);
% flg_aJerkT=0;
% setappdata(handles.button_aJerkT,'flg_aJerkT',flg_aJerkT);
tj_out=getappdata(handles.button_aJerkT,'tj_out');
Vj_out=getappdata(handles.button_aJerkT,'Vj_out');
figure(3)
plot(tj_out,Vj_out,'LineWidth',2)
grid on;
hold on;
legend('加速度T型,速度曲线');
else
warndlg('请选择速度规划模式!')
end
% --- Executes on button press in but_afig.
function but_afig_Callback(hObject, eventdata, handles)
% hObject handle to but_afig (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
flg_VT=getappdata(handles.button_VT,'flg_VT');
flg_AT=getappdata(handles.button_AT,'flg_AT');
flg_aJerkT=getappdata(handles.button_aJerkT,'flg_aJerkT');
%**********速度为T型,画出加速度图形*********************%
if flg_VT==1
tv_out=getappdata(handles.button_VT,'tv_out');
A=getappdata(handles.button_VT,'A');
figure(2)
plot(tv_out,A,'LineWidth',2)
grid on;
hold on;
legend('加速度曲线');
% flg_VT=0;
% setappdata(handles.button_VT,'flg_VT',flg_VT);
%*******************加速度为T型******************
elseif flg_AT==1
ta_out=getappdata(handles.button_AT,'ta_out');
Aa_out=getappdata(handles.button_AT,'Aa_out');
figure(2)
plot(ta_out,Aa_out,'LineWidth',2)
grid on;
hold on;
legend('加速度T型,加速度曲线');
%*************加加速度为T型************************%
elseif flg_aJerkT==1
% % % t1=getappdata(handles.button_aJerkT,'t1');
% % % t2=getappdata(handles.button_aJerkT,'t2');
% % % t4=getappdata(handles.button_aJerkT,'t4');
% % % t8=getappdata(handles.button_aJerkT,'t8');
% % % Kmax=getappdata(handles.ok,'Kmax');
% % m_t=getappdata(handles.ok,'m_t')
% % A_out=Aend_draw(t1,t2,t4,t8,Kmax,m_t);%%绘制加速度图像,顺便保存图像
% setappdata(handles.but_afig,'A_out',A_out);
tj_out=getappdata(handles.button_aJerkT,'tj_out');
Aj_out=getappdata(handles.button_aJerkT,'Aj_out');
figure(2)
plot(tj_out,Aj_out,'LineWidth',2)
grid on;
hold on;
legend('加加速度T型,加速度曲线');
else
warndlg('请选择速度规划模式!')
end
% plot3(handles.plot_xyz,L.*s_angle(1),L.*s_angle(2),L.*s_angle(3),'*')
% V_out=Vend_draw(t1,t2,t4,t8,Kmax);
% m_out=[t_out;V_out] %%输出时间和速度仿真,
% d_out=Dend_draw(t1,t2,t4,t8,Kmax);
% md_out=[t_out;d_out] %%输出时间和位移进行仿真
% --- Executes on button press in but_jerkfig.
function but_jerkfig_Callback(hObject, eventdata, handles)
% hObject handle to but_jerkfig (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%获取时间变量,获取加速度图形
flg_ok=getappdata(handles.ok,'flg_ok');
flg_VT=getappdata(handles.button_VT,'flg_VT');
flg_AT=getappdata(handles.button_AT,'flg_AT');
flg_aJerkT=getappdata(handles.button_aJerkT,'flg_aJerkT');
if flg_VT==1 %************满足条件VT***********
warndlg('速度T型,加加速度是脉冲函数,图形省略!')
elseif flg_AT==1
ta_out=getappdata(handles.button_AT,'ta_out');
Ja_out=getappdata(handles.button_AT,'Ja_out');
figure(1)
plot(ta_out,Ja_out,'LineWidth',2)
grid on;
hold on;
legend('加速度T型,加加速度曲线');
elseif flg_aJerkT==1 %%绘制加加速度的图像
%****************第一次做,用原函数发********
% t1=getappdata(handles.button_aJerkT,'t1');
% t2=getappdata(handles.button_aJerkT,'t2');
% t4=getappdata(handles.button_aJerkT,'t4');
% t8=getappdata(handles.button_aJerkT,'t8');
% Kmax=getappdata(handles.ok,'Kmax');
% m_t=getappdata(handles.ok,'m_t')
% J_out=Jend_draw(t1,t2,t4,t8,Kmax,m_t); %%加加速度的速度图像
% setappdata(handles.but_jerkfig,'J_out',J_out);%%输出加速度数据便于保存
tj_out=getappdata(handles.button_aJerkT,'tj_out');
Jj_out=getappdata(handles.button_aJerkT,'Jj_out');
figure(1)
plot(tj_out,Jj_out,'LineWidth',2)
grid on;
hold on;
legend('加加速度T型,加加速度曲线');
else
warndlg('请选择速度规划模式!')
end
%A_out=Aend_draw(t1,t2,t4,t8,Kmax,m_t);
% --- Executes on button press in but_clear.
function but_clear_Callback(hObject, eventdata, handles)
% hObject handle to but_clear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
try
delete(allchild(handles.plot_xyz))
end
flg_VT=getappdata(handles.button_VT,'flg_VT');
flg_AT=getappdata(handles.button_AT,'flg_AT');
flg_aJerkT=getappdata(handles.button_aJerkT,'flg_aJerkT');
close(figure(1));
close(figure(2));
close(figure(3));
close(figure(4));
flg_VT=0;
setappdata(handles.button_VT,'flg_VT',flg_VT);
flg_AT=0;
setappdata(handles.button_AT,'flg_AT',flg_AT);
flg_aJerkT=0;
setappdata(handles.button_aJerkT,'flg_aJerkT',flg_aJerkT);
s=0
s=num2str(s,'%.5f');
set(handles.sta_distance,'string',s);
flg_VT=0;
setappdata(handles.button_VT,'flg_VT',flg_VT);
flg_AT=0;
setappdata(handles.button_AT,'flg_AT',flg_AT);
flg_aJerkT=0;
setappdata(handles.button_aJerkT,'flg_aJerkT',flg_aJerkT);
%****************关闭图形******************************%
% --- Executes on button press in but_savce.
% function but_savce_Callback(hObject, eventdata, handles)
% % hObject handle to but_savce (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 but_save.
function but_save_Callback(hObject, eventdata, handles)
% hObject handle to but_save (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%获取时间变量
% setappdata(handles.button_VT,'tv_out',tv_out);
% setappdata(handles.button_VT,'L',L);
% setappdata(handles.button_VT,'A',A);
% setappdata(handles.button_VT,'V',V);
% flg_VT=1;
% setappdata(handles.button_VT,'flg_VT',flg_VT)
flg_aJerkT=getappdata(handles.button_aJerkT,'flg_aJerkT');
s_angle=getappdata(handles.ok,'s_angle');
flg_VT=getappdata(handles.button_VT,'flg_VT');
flg_AT=getappdata(handles.button_AT,'flg_AT');
%***********************存储加加速度T型数据数据文件%**********************
if flg_aJerkT==1
%*******创建存储文件**********
mkdir 加加速度T型插补点数据数据文件
cd 加加速度T型插补点数据数据文件
t_out=getappdata(handles.button_aJerkT,'tj_out');
d_out=getappdata(handles.button_aJerkT,'Lj_out');
A_out=getappdata(handles.button_aJerkT,'Aj_out');
V_out=getappdata(handles.button_aJerkT,'Vj_out');
J_out=getappdata(handles.button_aJerkT,'Jj_out');
% J_out=getappdata(handles.but_jerkfig,'J_out');
% t_out=getappdata(handles.button_aJerkT,'t_out');
% A_out=getappdata(handles.but_afig,'A_out');
% V_out=getappdata(handles.but_vfig,'V_out');
% d_out=getappdata(handles.but_disfig,'d_out');
J_endout=[t_out',J_out'];
fid1=fopen('插补点合加加速度与时间.txt','wt')
[m,n]=size(J_endout);
title=' time jerk'
fprintf(fid1,'%s\n',title);
for i=1:m
for j=1:n
if j==n
fprintf(fid1,' %12.6g\n',J_endout(i,j));
else
fprintf(fid1,' %12.6g',J_endout(i,j));
end
end
end
fclose(fid1);
%********************************存储加速度文件**************************%
A_endout=[t_out',A_out'];
fid2=fopen('插补点合加速度与时间.txt','wt')
[m,n]=size(A_endout);
title='time Accleration'
fprintf(fid2,' %s\n',title);
for i=1:m
for j=1:n
if j==n
fprintf(fid1,' %12.6g\n',A_endout(i,j));
else
fprintf(fid1,' %12.6g',A_endout(i,j));
end
end
end
fclose(fid2);
%********************************存储速度文件******************************%
V_endout=[t_out',A_out'];
fid3=fopen('插补点速度.txt','wt')
[m,n]=size(V_endout);
title=' time velocity'
fprintf(fid3,' %s\n',title);
for i=1:m
for j=1:n
if j==n
fprintf(fid1,' %12.6g\n',V_endout(i,j));
else
fprintf(fid1,' %12.6g',V_endout(i,j));
end
end
end
fclose(fid3);
%********************************插补点数据度******************************%
d_x=d_out.*s_angle(1);d_y=d_out.*s_angle(2);d_z=d_out.*s_angle(3);
D_endoutxyz=[t_out',d_x',d_y',d_z'];
fid4=fopen('插补点x,y,z.txt','wt')
[m,n]=size(D_endoutxyz);
title='插补点数据 t x y z'
fprintf(fid4,' %s\n',title);
for i=1:m
for j=1:n
if j==n
fprintf(fid1,' %12.6g\n',D_endoutxyz(i,j));
else
fprintf(fid1,' %12.6g',D_endoutxyz(i,j));
end
end
end
fclose(fid4);
%*************************存储合位移文件************************%
JT_distance=[t_out',d_out'];
fid5=fopen('插补点合位移.txt','wt')
[m,n]=size(JT_distance);
title=' time distance'
fprintf(fid5,' %s\n',title);
for i=1:m
for j=1:n
if j==n
fprintf(fid1,' %12.6g\n',JT_distance(i,j));
else
fprintf(fid1,' %12.6g',JT_distance(i,j));
end
end
end
fclose(fid5);
end
%%%%**********************速度为T型的数据**************************%%
if flg_VT==1
tv_out=getappdata(handles.button_VT,'tv_out');
L=getappdata(handles.button_VT,'L');
A=getappdata(handles.button_VT,'A');
V=getappdata(handles.button_VT,'V');
%*****创建存储文件**********
mkdir 速度T型插补点数据数据文件
cd 速度T型插补点数据数据文件
%********************************存储加速度文件**************************%
VT_a=[tv_out',A'];
fid1=fopen('速度T型_加速度插补点数据.txt','wt')
[m,n]=size(VT_a);
title='time Accleration'
fprintf(fid1,'%s\n',title);
for i=1:m
for j=1:n
if j==n
fprintf(fid1,' %12.6g\n',VT_a(i,j));
else
fprintf(fid1,' %12.6g',VT_a(i,j));
end
end
end
fclose(fid1);
%********************************存储速度文件******************************%
VT_v=[tv_out',V'];
fid2=fopen('速度T型_合速度插补点数据.txt','wt')
[m,n]=size(VT_v);
title=' time velocity'
fprintf(fid2,' %s\n',title);
for i=1:m
for j=1:n
if j==n
fprintf(fid1,' %12.6g\n',VT_v(i,j));
else
fprintf(fid1,' %12.6g',VT_v(i,j));
end
end
end
fclose(fid2);
%********************************插补点数据度******************************%
L_x=L.*s_angle(1);L_y=L.*s_angle(2);L_z=L.*s_angle(3);
VT_xyz=[tv_out',L_x',L_y',L_z'];
fid3=fopen('速度T型_插补点数据x,y,z的值.txt','wt')
[m,n]=size(VT_xyz);
title='插补点数据 t x y z'
fprintf(fid3,'%s\n',title);
for i=1:m
for j=1:n
if j==n
fprintf(fid1,' %12.6g\n',VT_xyz(i,j));
else
fprintf(fid1,' %12.6g',VT_xyz(i,j));
end
end
end
fclose(fid3);
%********************************存储速度文件******************************%
VT_distance=[tv_out',V'];
fid4=fopen('速度为T型_合位移数据.txt','wt')
[m,n]=size(VT_distance);
title='time distance'
fprintf(fid4,'%s\n',title);
for i=1:m
for j=1:n
if j==n
fprintf(fid1,' %12.6g\n',VT_distance(i,j));
else
fprintf(fid1,' %12.6g',VT_distance(i,j));
end
end
end
fclose(fid4);
end
%***************************加速度为T型的**********************************
if flg_AT==1
%*****创建存储文件**********
ta_out=getappdata(handles.button_AT,'ta_out');
La_out=getappdata(handles.button_AT,'La_out');
Aa_out=getappdata(handles.button_AT,'Aa_out');
Va_out=getappdata(handles.button_AT,'Va_out');
Ja_out=getappdata(handles.button_AT,'Ja_out');
mkdir 加速度为T型_数据
cd 加速度为T型_数据
%******************************存储加加速度数据文件%**********************
AT_J=[ta_out',Ja_out'];
fid1=fopen('加速度为T型_合加加速度数据.txt','wt')
[m,n]=size(AT_J);
title=' time jerk'
fprintf(fid1,'%s\n',title);
for i=1:m
for j=1:n
if j==n
fprintf(fid1,' %12.6g\n',AT_J(i,j));
else
fprintf(fid1,' %12.6g',AT_J(i,j));
end
end
end
fclose(fid1);
%********************************存储加速度文件**************************%
AT_A=[ta_out',Aa_out'];
fid2=fopen('加速度为T型_合加速度数据.txt','wt')
[m,n]=size(AT_A);
title='time Accleration'
fprintf(fid2,'%s\n',title);
for i=1:m
for j=1:n
if j==n
fprintf(fid1,' %12.6g\n',AT_A(i,j));
else
fprintf(fid1,' %12.6g',AT_A(i,j));
end
end
end
fclose(fid2);
%********************************存储速度文件******************************%
AT_V=[ta_out',Aa_out'];
fid3=fopen(' 加速度为T型_速度数据.txt','wt')
[m,n]=size(AT_V);
title=' time velocity'
fprintf(fid3,' %s\n',title);
for i=1:m
for j=1:n
if j==n
fprintf(fid1,' %12.6g\n',AT_V(i,j));
else
fprintf(fid1,' %12.6g',AT_V(i,j));
end
end
end
fclose(fid3);
%********************************插补点数据度******************************%
La_x=La_out.*s_angle(1);La_y=La_out.*s_angle(2);La_z=La_out.*s_angle(3);
AT_xyz=[ta_out', La_x', La_y', La_z'];
fid4=fopen('加速度为T型_插补点数据.txt','wt')
[m,n]=size(AT_xyz);
title='插补点数据 t x y z'
fprintf(fid4,'%s\n',title);
for i=1:m
for j=1:n
if j==n
fprintf(fid1,' %12.6g\n',AT_xyz(i,j));
else
fprintf(fid1,' %12.6g',AT_xyz(i,j));
end
end
end
fclose(fid4);
%*************************存储合位移文件************************%
AT_distance=[ta_out',La_out'];
fid5=fopen('加速度为T型_合位移插补点数据.txt','wt')
[m,n]=size(AT_distance);
title=' time distance'
fprintf(fid5,'%s\n',title);
for i=1:m
for j=1:n
if j==n
fprintf(fid1,' %12.6g\n',AT_distance(i,j));
else
fprintf(fid1,' %12.6g',AT_distance(i,j));
end
end
end
fclose(fid5);
end