The script presented in the previous problem has been tested on the robot and the position and angle values recorded by the robot were stored in a file. We have implemented the following program in MATLAB:
[x,y,th] = textread('log.txt','%f %f %f');
hold on;
i=1;
while i <= length(x)
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
plot(x,y,'Color','red','LineWidth',3);
The program takes the values stored in the file and plots the trajectory (the red line) and the corresponding orientation of the robot at each point (the blue lines).
Sunday, February 20, 2011
Wednesday, February 16, 2011
Exercise 3, Problem 2. Constraints.
1) Rolling and sliding constraints for the left wheel (wheel 1):
2) Putting the equations into Maple (regarding α, β and l from Problem 1):
3) Querying the results / constraint matrices:
2) Putting the equations into Maple (regarding α, β and l from Problem 1):
3) Querying the results / constraint matrices:
Tuesday, February 15, 2011
Exercise 3, Problem 1.
Finding α, β and l (from length) for the three wheels.
Wheel 1, Left (back): [π/2 0 w/2]'
Wheel 2, Right (back): [-π/2 π w/2]'
Wheel 3, Middle (front): [0 β(t) L]'
Note: for the right wheel, β is π because, when α is applied, it runs backwards; thus it must be turned another 180 deg (π rad);
Wheel 1, Left (back): [π/2 0 w/2]'
Wheel 2, Right (back): [-π/2 π w/2]'
Wheel 3, Middle (front): [0 β(t) L]'
Note: for the right wheel, β is π because, when α is applied, it runs backwards; thus it must be turned another 180 deg (π rad);
Tricycle kinematics.
Figure 1 shows the wheel configuration of a tricycle with front wheel traction:
On this model, an introduction to kinematics is going to be applied through a series of steps.
These steps are the Problems in the next posts.
On this model, an introduction to kinematics is going to be applied through a series of steps.
These steps are the Problems in the next posts.
Exercise 5, Image analysis
The U and V values for the two balls are showed below.
Red: umin=114 umax=130 vmin=136 vmax=154
Blue: umin=130 umax=147 vmin=115 vmax=129
Red: umin=114 umax=130 vmin=136 vmax=154
Blue: umin=130 umax=147 vmin=115 vmax=129
Exercise 4, Problem 3
The implemented algorithm is the following:
log "$odox" "$odoy" "$odoth"
x=2
y=-0.5
a=atan2(y,x)
b=sqrt(x*x+y*y)
th=3.141
c=th-a
turn a "rad"
fwd b
turn c "rad"
stop
x=2
y=-0.5
a=atan2(y,x)
b=sqrt(x*x+y*y)
th=3.141
c=th-a
turn a "rad"
fwd b
turn c "rad"
stop
Exercise 5, Task 3. Balls
Exercise 5, Task 2. Theta
To continue with the camera calibration we need to find the angle theta on the robot's Y axis.
To achieve this we took a picture; then found the middle of the picture's corespondent point on the floor and measured the distance x from that specific point to the base of the camera, also on the floor.
Then the height to the camera from the floor, z, was measured. We have:
x = 1.297m
z = 0.415m
theta = arctan ( x / y ) = arctan ( 0.415 / 1.297 ) = 17,743 deg
theta = 0.309675 rad
To achieve this we took a picture; then found the middle of the picture's corespondent point on the floor and measured the distance x from that specific point to the base of the camera, also on the floor.
The center of the picture correspondence on the floor - the end of the ruler. |
x = 1.297m
z = 0.415m
theta = arctan ( x / y ) = arctan ( 0.415 / 1.297 ) = 17,743 deg
theta = 0.309675 rad
Exercise 5, Camera parameters
We started by calculating the focal length of the camera.
Formula used: f = xi * z / x where:
x - the width of an object
z - the distance from the object to the camera
xi - the width of the object in the picture taken
We have set the robot so it seen the center of an A4 peace of paper, at the distance of 1m.
The width of the paper, as seen in the picture was 201px:
So we know the objects physical width: x = 0.297m
We have measured the object's width in the picture: xi = 201px
Stated before: z = 1m
This yields to:
f = 201px * 1m / 0.297m
f = 677px (at the picture's resolution of 752x480)
Formula used: f = xi * z / x where:
x - the width of an object
z - the distance from the object to the camera
xi - the width of the object in the picture taken
We have set the robot so it seen the center of an A4 peace of paper, at the distance of 1m.
The width of the paper, as seen in the picture was 201px:
So we know the objects physical width: x = 0.297m
We have measured the object's width in the picture: xi = 201px
Stated before: z = 1m
This yields to:
f = 201px * 1m / 0.297m
f = 677px (at the picture's resolution of 752x480)
Friday, February 11, 2011
Exercise 4, Problem 2
The visualisation of the movements for the given cases is presented in the following figure:
The implementation was realised as in previous problems. The orientation of the robot at the starting position can not be seen in all the cases due to overlapping of the graphs.
The implementation was realised as in previous problems. The orientation of the robot at the starting position can not be seen in all the cases due to overlapping of the graphs.
Exercise 4, Problem 1
The following function moves the robot from the initial position (0, 0, 0) with the values given as an input:
pose = initpose;
x = relativePose(1);
y = relativePose(2);
th = relativePose(3);
a = atan2(y, x);
b = sqrt(x^2+y^2);
c = th-a;
array = turn(a,1);
for i=1:size(array)
a2=[array(i,1) array(i,1)+0.1*cos(array(i,3))];
b2=[array(i,2) array(i,2)+0.1*sin(array(i,3))]; line(a2,b2,'Color',ncolor);
end
array = forward(b,1);
plot(array(:,1),array(:,2),'Color',ncolor,'LineWidth',2);
array = turn(c,1);
for i=1:size(array)
a2=[array(i,1) array(i,1)+0.1*cos(array(i,3))];
b2=[array(i,2) array(i,2)+0.1*sin(array(i,3))];
line(a2,b2,'Color',ncolor);
end
end
The outputs a, b and c are the movements (rotation and translation) needed to be performed in order to reach the desired position.
function [a b c] = moveWith(relativePose)
global pose initpose ncolor;pose = initpose;
x = relativePose(1);
y = relativePose(2);
th = relativePose(3);
a = atan2(y, x);
b = sqrt(x^2+y^2);
c = th-a;
array = turn(a,1);
for i=1:size(array)
a2=[array(i,1) array(i,1)+0.1*cos(array(i,3))];
b2=[array(i,2) array(i,2)+0.1*sin(array(i,3))]; line(a2,b2,'Color',ncolor);
end
array = forward(b,1);
plot(array(:,1),array(:,2),'Color',ncolor,'LineWidth',2);
array = turn(c,1);
for i=1:size(array)
a2=[array(i,1) array(i,1)+0.1*cos(array(i,3))];
b2=[array(i,2) array(i,2)+0.1*sin(array(i,3))];
line(a2,b2,'Color',ncolor);
end
end
The outputs a, b and c are the movements (rotation and translation) needed to be performed in order to reach the desired position.
Tuesday, February 8, 2011
Exercise 1, Task 11
The following picture was taken with the camera mounted on the robot:
Exercise 1, Task 10
The following code was used:
fwd 0.3
followline "bl" :($irdistleft < 0.2)|($irdistright < 0.2)|($drivendist > 1)
switch($condition)
case 1
followline "bl" :($drivendist > 0.5)
case 2
followline "br" :($drivendist > 0.5)
case 3
turn 180
followline "br" :($drivendist > 1)
endswitch
stop
The robot follows a line until it sees an obstacle on the left or on the right side and then goes on the left side or the right side of the line. If it moves forward 1m and doesn't find any object it will turn 180 degrees and go back the same distance.
Exercise 1, Task 9
The robot will follow a line and stop if it encounters an object at a distance smaller than 0.3 m.
The program takes into consideration the values from all the front sensors.
The program takes into consideration the values from all the front sensors.
fwd 0.5@v0.3
followline "bm" :($irdistfrontleft < 0.3) | ($irdistfrontmiddle < 0.3) | ($irdistfrontright < 0.3)
stop
followline "bm" :($irdistfrontleft < 0.3) | ($irdistfrontmiddle < 0.3) | ($irdistfrontright < 0.3)
stop
Exercise 1, Task 8
The robot will follow a line on the floor and stop if it encounters another one crossing it.
fwd 0.3
followline "bl" :($crossingblackline)
eval $irdistfrontleft
eval $irdistfrontright
eval $irdistfrontmiddle
stop
followline "bl" :($crossingblackline)
eval $irdistfrontleft
eval $irdistfrontright
eval $irdistfrontmiddle
stop
Exercise 1, Task 7
The program is the same as the previous one, the only difference is that it follows the left branch of the fork.
fwd 0.3
followline "bl" :($drivendist > 3)
stop
followline "bl" :($drivendist > 3)
stop
Exercise 1, Task 6
This program makes the robot follow the right branch of a y-fork and stop after moving 3 meters.
fwd 0.3
followline "br" :($drivendist > 3)
stop
followline "br" :($drivendist > 3)
stop
Tuesday, February 1, 2011
Exercise 1, Task 5
First the line sensor should be calibrated:
Make a program which makes the SMR follow a black line for 1 meter; turn and get back.
Here is the end result:
smrdemo –c
Make a program which makes the SMR follow a black line for 1 meter; turn and get back.
fwd 0.3
followline "br" :($drivendist > 1.0)
turn 180
followline "br" :($drivendist > 1.0)
stop
followline "br" :($drivendist > 1.0)
turn 180
followline "br" :($drivendist > 1.0)
stop
Exercise 1, Task 3
In this exercise, the robot has to move in a rectangle with the side lengths 1m and 0.3m.
The program has the following commands:
drive @v 0.3 :($drivendist > 0.5)
The program has the following commands:
drive @v 0.3 :($drivendist > 0.5)
turnr 0.1 90 @v 0.3
drive @v 0.3 :($drivendist > 0.5)
turnr 0.1 90 @v 0.3
drive @v 0.3 :($drivendist > 0.5)
turnr 0.1 90 @v 0.3
drive @v 0.3 :($drivendist > 0.5)
turnr 0.1 90 @v 0.3
stop
drive @v 0.3 :($drivendist > 0.5)
turnr 0.1 90 @v 0.3
drive @v 0.3 :($drivendist > 0.5)
turnr 0.1 90 @v 0.3
drive @v 0.3 :($drivendist > 0.5)
turnr 0.1 90 @v 0.3
stop
The SMR will go straight, with the velocity 0.3. When the expression in the parenthesis is true, (the driven distance is greater than 0.5), the program will continue with the next line (the robot will not stop unless told so by the next command).
Exercise 1, Task 2
The following code is run:
fwd 1.5 @v0.3
turn 180
fwd 1.5 @v0.3
turn 180
stop
And here is the result:
fwd 1.5 @v0.3
turn 180
fwd 1.5 @v0.3
turn 180
stop
And here is the result:
Exercise 1, Task 4
"Make a program that makes the robot run 0.75m forward and the run in a square with round
corners. The side lengths should be 0.3m and the turning radius should be 0.3 m."
corners. The side lengths should be 0.3m and the turning radius should be 0.3 m."
The code for task 4 is:
drive @v 0.3 :($drivendist > 0.75)
drive @v 0.3 :($drivendist > 0.3)
turnr 0.3 90 @v 0.3
drive @v 0.3 :($drivendist > 0.3)
turnr 0.3 90 @v 0.3
drive @v 0.3 :($drivendist > 0.3)
turnr 0.3 90 @v 0.3
drive @v 0.3 :($drivendist > 0.3)
turnr 0.3 90 @v 0.3
stop
drive @v 0.3 :($drivendist > 0.3)
turnr 0.3 90 @v 0.3
drive @v 0.3 :($drivendist > 0.3)
turnr 0.3 90 @v 0.3
drive @v 0.3 :($drivendist > 0.3)
turnr 0.3 90 @v 0.3
drive @v 0.3 :($drivendist > 0.3)
turnr 0.3 90 @v 0.3
stop
And here is the movie of the robot:
Exercise 1, Task 1. Hello World!
A simple and easy task is to tell the robot to go forward, turn and get back.
The code is:
That means: go forward 1.5m at the velocity 0.3m/s, turn around 180 degrees and the same length back.
Here is the result in the simulator.
Notice that the simulator includes movement errors; i.e. the returning position is slightly offset.
The code is:
fwd 1.5 @v0.3
turn 180
fwd 1.5 @v0.3
That means: go forward 1.5m at the velocity 0.3m/s, turn around 180 degrees and the same length back.
Here is the result in the simulator.
Notice that the simulator includes movement errors; i.e. the returning position is slightly offset.
Presentations
Here it goes... this is what SMR is. We are team 7 and the robot has a Bender face on it made out of plastic.
Ergo: SMR12, Codename BENDER.
First thing's first: login to the SMR with the command:
ssh smrN
where N is the number of the used SMR
Ergo: SMR12, Codename BENDER.
First thing's first: login to the SMR with the command:
ssh smrN
where N is the number of the used SMR
Subscribe to:
Posts (Atom)