6-DoF Robot Elbow - A Tutorial in MATLAB and Simulink
1.Draw links ( using SolidWorks software)
2.Link assembly(using SolidWorks software)
3.Forward + Inverse Kinematics
Select the base coordinate system and attach the coordinate systems to the links.
Make a table of kinematic parameters(DENAVIT HARTENBERG)
Based on kinematic parameters determine the matrices
4.Install MATLAB
5.Attach the coordinate system to the link(using SolidWorks software)
6.Export SIMCAPE MULTIBODY
7.Create interface control
Select the base coordinate system and attach the coordinate systems to the links.
The forward kinematics problem is Calculating the matrix T6
KINEMATIC PARAMETER (DENAVIT HARTENBERG)
Θi :Angle of rotation about the Z axis
α : Angle of rotation of the Z axis around the X axis (positive counterclockwise)
ai : Distance between axes Z
di: Distance between axes Z
GENERAL MATRIX
An=Rot(z,θ)Trans(0,0,d)Trans(a,0,0)Rot(x,α)
cosθ -sinθcosα sinθsinα a cosθ
sinθ cosθcosα -cosθsinα a sinθ
An = 0 sinα cosα d
0 0 0 1
Using MatLab to calculate the Matrix T6
A1= [cosd(t1) 0 sind(t1) 0;sind(t1) 0 -cosd(t1) 0;0 1 0 0;0 0 0 1];
A2= [cosd(t2) -sind(t2) 0 cosd(t2)*a2 ;sind(t2) cosd(t2) 0 sind(t2)*a2; 0 0 1 0;0 0 0 1];
A3= [cosd(t3) -sind(t3) 0 cosd(t3)*a3;sind(t3) cosd(t3) 0 sind(t3)*a3 ;0 1 0 0;0 0 0 1];
A4= [cosd(t4) 0 -sind(t4) cosd(t4)*a4;sind(t4) 0 cosd(t4) sind(t4)*a4;0 -1 0 0;0 0 0 1];
A5= [cosd(t5) 0 sind(t5) 0;sind(t5) 0 -cosd(t5) 0;0 1 0 0;0 0 0 1];
A6= [cosd(t6) -sind(t6) 0 0;sind(t6) cosd(t6) 0 0;0 0 1 0;0 0 0 1];
Inverse Kinematics: The inverse kinematics problem is to calculate the rotations around the joint axis
θ1 = θ1 + 1800
θ2 = arctg2((C3a3 + a2)p’y - S3a3p’x , (C3a3 + a2)p’x + S3a3p’y )
θ3 = arctg2(S3 , C3)
θ4 = θ234 - θ3 - θ2
θ5 = arctg2(C234(C1ax + S1ay) + S234az , S1ax - C1ay)
θ6 = arctg2(S6 , C6)
create interface control
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
ModelName = 'robotElbow';
global var;
t1=get(handles.slider1,'value'); %set value from slider
set(handles.edit1,'string',num2str(t1));%display value Edit
t2=get(handles.slider2,'value');
set(handles.edit2,'string',num2str(t2));
t3=get(handles.slider3,'value');
set(handles.edit3,'string',num2str(t3));
t4=get(handles.slider4,'value');
set(handles.edit4,'string',num2str(t4));
t5=get(handles.slider5,'value');
set(handles.edit5,'string',num2str(t5));
t6=get(handles.slider6,'value');
set(handles.edit6,'string',num2str(t6));
set_param([ModelName '/Gain1'],'Gain',num2str(t1)) %TRUYEN CAC THONG SO CUA CAC THANH SLIDER TRONG GUI VAO KHOI SLIDER GAIN
set_param([ModelName '/Gain2'],'Gain',num2str(t2))
set_param([ModelName '/Gain3'],'Gain',num2str(t3))
set_param([ModelName '/Gain4'],'Gain',num2str(t4))
set_param([ModelName '/Gain5'],'Gain',num2str(t5))
set_param([ModelName '/Gain6'],'Gain',num2str(t6))
A1= [cosd(t1) 0 sind(t1) 0;sind(t1) 0 -cosd(t1) 0;0 1 0 0;0 0 0 1];
A2= [cosd(t2) -sind(t2) 0 cosd(t2)*530 ;sind(t2) cosd(t2) 0 sind(t2)*530; 0 0 1 0;0 0 0 1];
A3= [cosd(t3) -sind(t3) 0 cosd(t3)*430;sind(t3) cosd(t3) 0 sind(t3)*430 ;0 1 0 0;0 0 0 1];
A4= [cosd(t4) 0 -sind(t4) cosd(t4)*330;sind(t4) 0 cosd(t4) sind(t4)*330;0 -1 0 0;0 0 0 1];
A5= [cosd(t5) 0 sind(t5) 0;sind(t5) 0 -cosd(t5) 0;0 1 0 0;0 0 0 1];
A6= [cosd(t6) -sind(t6) 0 0;sind(t6) cosd(t6) 0 0;0 0 1 0;0 0 0 1];
T=A1*A2*A3*A4*A5*A6;
Px=T(1,4);
Py=T(2,4);
Pz=T(3,4);
set(handles.edit7,'string',num2str(Px));
set(handles.edit8,'string',num2str(Py));
set(handles.edit9,'string',num2str(Pz));
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ModelName = 'robotElbow';
% Opens the Simulink model
open_system(ModelName);
set_param(ModelName,'BlockReduction','off');
set_param(ModelName,'StopTime','inf');
set_param(ModelName,'simulationMode','normal');
set_param(ModelName,'StartFcn','1');
set_param(ModelName, 'SimulationCommand', 'start');
https://drive.google.com/file/d/1dVklz2KRPCROHQDW1ldOMMjqTo65IyVM/view?usp=sharing
https://www.youtube.com/watch?v=Jhte3nATu8k
Powered by Froala Editor
;