SIMULATION OF WIPER MECHANISM OF A BUS USING MATLAB
Aim:
To simulate the wiper mechanism of a bus using MATLAB and make an animation of the plot.
Theory:
- 2R Robotic Arm:
A 2R Robotic Arm refers to a robotic arm with two Degrees of Freedom(DOF).This robotic arm can move only in two dimensions.Such robotic arms can be used in cars as wipers of the windshield,in industries as an aid to pick and place objects.As the movement of this arm is restricted to just two Degrees of Freedom(DOF),the usage is also limited.
Description of Program:
A program is written to simulate the Wiper mechanism of a bus.
1) The lengths of the arms are determined.
2) The angles made by the arms are also determined,where the first arm angles are fixed the second arm angles are varied using the "linspace" command.
3) The first co-ordinate is fixed to (15,20) and (25,20).
4)A "for" loop is added to execute the variations in the angle made by the second arms.
5)A graph is made using the "plot" command where all the co-ordinates are plotted and a pause of 0.1 seconds is given to the plots for a smoother simulation.
6)A counter is setup to count the number of frames and an array of frames is made which get converted into a movie using the "movie" command.
7)The file is then saved in .avi format which gives the movie.
Program:
%Wipers mechanism:
clear all
close all
clc
%Length of arms
l1 = 5;
l2 = 10;
%Angle made by arms
t1 = 200;
t2 = linspace(230,310,20);
t3 = 200;
t4 = linspace(230,310,20);
ct = 1;
for i = 1:length(t2)
T1 = t1;
T2 = t2(i);
x1 = 25;
y1 = 20;
x2 = 15;
y2 = 20;
x12 = x1 + l1*cosd(T1);
y12 = y1 + l1*sind(T1);
x13 = x12 + l2*cosd(T2);
y13 = y12 + l2*sind(T2);
x22 = x2 + l1*cosd(T1);
y22 = y2 + l1*sind(T1);
x23 = x22 + l2*cosd(T2);
y23 = y22 + l2*sind(T2);
plot([x2 x22],[y2 y22],[x22 x23],[y22 y23],[x1 x12],[y1 y12],[x12 x13],[y12 y13] )
axis([0 30 0 30])
pause(0.1)
M(ct) = getframe(gcf);
ct = i;
end
ct2 = 0;
ctm2 = length(t2);
for j = 1:length(t2)
T1 = t1;
T2 = t2(end - ct2);
x1 = 25;
y1 = 20;
x2 = 15;
y2 = 20;
x12 = x1 + l1*cosd(T1);
y12 = y1 + l1*sind(T1);
x13 = x12 + l2*cosd(T2);
y13 = y12 + l2*sind(T2);
x22 = x2 + l1*cosd(T1);
y22 = y2 + l1*sind(T1);
x23 = x22 + l2*cosd(T2);
y23 = y22 + l2*sind(T2);
plot([x2 x22],[y2 y22],[x22 x23],[y22 y23],[x1 x12],[y1 y12],[x12 x13],[y12 y13])
axis([0 30 0 30])
pause(0.1)
M(ctm2) = getframe(gcf);
ctm2 = ctm2+1;
ct2 = ct2+1;
end
movie(M)
videofile = VideoWriter('wipermech.avi','uncompressed AVI')
open(videofile)
writeVideo(videofile,M)
close(videofile)
Output:
Link to the video:
Results and Conclusion:
Therefore a simulation of the wiper mechanism of a bus was created and the animation of the plot was obtained.