Wednesday, March 23, 2011

Exercise 2, MATLAB

The program used to plot the results is the following:
laser = load('laser_0.log');
odo = load('odoPose.log');
figure(1);
hold on;
i=1;
while i <= length(odo)
    x(i) = odo(i,2);
    y(i) = odo(i,3);
    th(i) = odo(i,4);
    a=[x(i) x(i)+0.5*cos(th(i))];
    b=[y(i) y(i)+0.5*sin(th(i))];
    line(a,b)
    i=i+1;
end   
xlabel('x [m]');
ylabel('y [m]');
plot(x,y,'Color','red','LineWidth',3);
figure(2);
nb = 700;
for i=1:laser(nb,5)
meas(i) = laser(nb,i+5);
ang (i) = deg2rad(laser(nb,4)+((i-1)*laser(nb,3)));
end
polar(ang,meas,'.');

The first plot represents the movement of the robot in carthesian coordinates.
 The robot was programmed to go through the door and then move along the wall. But it was very confused as to which wall should he follow, thus resulting the figure above. After several attempts, a position in which the door can be seen was found. It is shown in the figure below.

No comments:

Post a Comment