Showing posts with label exercise 2. Show all posts
Showing posts with label exercise 2. Show all posts

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.

Tuesday, March 22, 2011

Exercise 2, Simulated laser scanner

After performing all the steps and testing the laserscanner we obtained the following result:

Exercise 2, Maze

The code below was implemented:

fwd 1.5
turn 65
fwd 1.5
turn 25
fwd 1.4
turn 45
fwd 0.15
turn 25
fwd 0.2
turn 20
fwd 1.4
turn 55
fwd 0.1
turn 10
fwd 0.15
turn 25
fwd 0.3
turn 30
fwd 0.7
turn -30
fwd 1
turn -65
fwd 0.45
turn -10
fwd 0.15
turn -15
fwd 0.5
stop

After the simulation, the robot was in the position seen below: