Lab Report - Dynamical Systems
Lab Report - Dynamical Systems
cos ( A ) sin ( A )
0
sin ( A ) cos ( A )
1[ T ] =
0
0
0
0
0
0
1
0
0
0
l2
1
][
1 0 0 S A
0 1 0
0 0 1
0 0 0
S A ,max
2
0
0
1
cos ( A ) sin ( A )
0
sin ( A ) cos ( A )
2[ T ] =
0
0
0
0
][
0 0 cos ( B )
0 0
0
1 l 2 sin ( B )
0
0 1
Inverse kinematics:
cos ( A ) [ l 2 cos ( B ) + S A ]
0 {P }C = sin ( A ) [ l 2 cos ( B ) + S A ]
l 2 sin ( B ) +l 1
1
A =atan (
yc
)
xc
0 sin ( B ) S A
1
0
0
0 cos ( B ) 0
0
0
1
][ ]
1 0 0
0 1 0
0 0 1
0 0 0
l2
2
0
0
1
l 1z c
)
l2
x c l 2 cos ( B ) +cos ( A )
S A=
cos ( A )
B =asin (
Programming in MATLab
1)Plotting box
function box3d(Pts,colour)
%box3d plots a box using given points in xyz coordinate
%
This function uses the built-in matlab function fill3 to plot a box
% Pts - 3x8 matrix obtained by using parameters function
% colour - any value to select the number
tridmat = zeros(3,4,6);
tridmat(:,:,1) = [Pts(1:3,1),Pts(1:3,2),Pts(1:3,3),Pts(1:3,4)];
tridmat(:,:,2) = [Pts(1:3,5),Pts(1:3,6),Pts(1:3,7),Pts(1:3,8)];
tridmat(:,:,3) = [Pts(1:3,2),Pts(1:3,3),Pts(1:3,7),Pts(1:3,6)];
tridmat(:,:,4) = [Pts(1:3,3),Pts(1:3,4),Pts(1:3,8),Pts(1:3,7)];
tridmat(:,:,5) = [Pts(1:3,1),Pts(1:3,2),Pts(1:3,6),Pts(1:3,5)];
tridmat(:,:,6) = [Pts(1:3,1),Pts(1:3,4),Pts(1:3,8),Pts(1:3,5)];
%Plotting the box plane by plane in a single plot
fill3(tridmat(1,:,1),tridmat(2,:,1),
hold on
fill3(tridmat(1,:,2),tridmat(2,:,2),
fill3(tridmat(1,:,3),tridmat(2,:,3),
fill3(tridmat(1,:,4),tridmat(2,:,4),
fill3(tridmat(1,:,5),tridmat(2,:,5),
fill3(tridmat(1,:,6),tridmat(2,:,6),
hold off
end
tridmat(3,:,1), colour);
tridmat(3,:,2),
tridmat(3,:,3),
tridmat(3,:,4),
tridmat(3,:,5),
tridmat(3,:,6),
colour);
colour);
colour);
colour);
colour);
2)Setting parameters
function Threebyeight=parameters(thickness, width, height);
%this function takes in parameters such as height, width and thickness and
%generates a 3x8 matrix
%
%height in z axis
%width in y axis
%thickness in x axis
%l_origin is a 1x3 matrix representing coordinate of local origin
%
%the origin of the box is determined at the center of the base
%base is the x-y plane at z=0
p1 = [-thickness/2 ; -width/2; 0];
p2 = [thickness/2 ; -width/2; 0];
p3 = [thickness/2 ; width/2; 0];
p4 = [-thickness/2 ; width/2; 0];
p5 = [-thickness/2 ; -width/2; height];
p6 = [thickness/2 ; -width/2; height];
p7 = [thickness/2 ; width/2; height];
p8 = [-thickness/2 ; width/2; height];
3) Static Model
xlabel('x');
ylabel('y');
zlabel('z');
grid
hold on
box3d(final(:,:,2),1); %box 2
hold on
box3d(final(:,:,3),2); %box 3
end
%
%
*See GUI Options on GUIDE's Tools menu.
%
instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% --- Outputs from this function are returned to the command line.
function varargout = gui_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)
% eventdata
% handles
handles.Pf=[handles.thetaA2,handles.thetaB2,handles.Sa2];
animate_arm(handles.Ps, handles.Pf, 10, 1);
elseif get(handles.inverse,'Value')
handles.Pc1=[handles.x1,handles.y1,handles.z1];
handles.Pc2=[handles.x2,handles.y2,handles.z2];
handles.Pcf1=inverse_kinematics(handles.Pc1);
handles.Pcf2=inverse_kinematics(handles.Pc2);
animate_arm(handles.Pcf1,handles.Pcf2,10,1);
end
% --- Executes on button press in fwd.
function fwd_Callback(hObject, eventdata, handles)
% hObject
handle to fwd (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of fwd
end
Conclusion
The simulation helps in understanding the motion of RPR arm and the ranges of motion of
the end point, C. This program is really helpful in knowing whether the parameters set is
valid or not.
References
[1] "3D Polygon - draw a box with Matlab", Matrixlab-examples.com, 2016. [Online].
Available: http://www.matrixlab-examples.com/3d-polygon.html. [Accessed: 15- Sep- 2016].
[2] MatLab Documentation. http://www.mathworks.com/index.html?s_tid=gn_logo