The Matlab programs
The Matlab programs are documented in the code,
so comments about all of them can be found using
the Matlab command HELP FUN .
The function paramlabel is not written by me,
but I couldn't find the authors name in the file,
thanks to him/her anyway.
A thing that should be noticed is that for some reason
my robot had a lot of difference in the power of the
two motors. That is why in each of the motor-controlling
Matlab-functions there's defined SPEED_NORMAL_A=50; and
SPEED_NORMAL_B=150; as these were nice values with which
the robot moved straight forward. These values will
probably not work with some other motors, you should
test to see what works with your robot.
These are the main programs you propably want to
try (more info available with Matlab's
help):
Program |
Comment |
robot_travel_v2 |
|
Picture of the line I used, notice the perpendicular
bit in the end (there's one in the other end as well) |
Follows the line in the floor using robot_find_line
and robot_move_to_end_v2, the version with a PD-regulator
If the script robot_init hasn't been ran,
this script initializes the robot by running it.
The line is detected by counting the horisontal gradient
of the image. The line is where the horisontal contrast is
biggest. The perpendicular ending is detected by counting
the maximum of vertical gradients of each vertical line.
If the meadian of these is big enough, the robot sees
the vertical line and is in the end. Any striped line
should work just fine.
For line following i used resolution 160x120 so that the analysis
can easily be done in realtime.
|
follow_trolley |
|
Picture of the "trolley" I used |
Tries to follow the trolley keeping it in the middle
of the image and 30 cm away from the robot.
The function detect_trolley is used for (surprisingly =] )
detecting where the trolley is in the picture. It is
detected based on it's colour, pink seemed a good idea
since I have no other pink items in my room.
Uses two PD-regulators, one for the speed of the robot
and one for the angle.
If the robot doesn't see the trolley it will turn left/right
until it is detected in the picture.
For trolley following i used resolution 160x120 so that the analysis
can easily be done in realtime.
|
analyze_object_types |
Grabs an image and analyzes the objects in it
Uses get_object_type to determine the type of each object,
otherwise does the same as analyze_objects.
The objects are distinguished by a double threshold;
really bright pixels and pixels a bit darker than the median
are considered as objects. This works fine for me, but depends
ofcourse totally on the color of the floor and lighting.
For object analysis i used resolution 352x280.
|
|
Example of a grabbed image and the objects detected |
Map of the objects |
|
r2 |
Uses robot_move_to_end_v2 to make the robot to move to the end of the
line and then plots the results |
robot_init |
This script initializes the robot-controller and some global variables
used to control the robot
The functions robot_travel, robot_travel_v2 and follow_trolley
run this script automatically if it hasn't already been ran. |
|