Source Code:
Visual Basic source code (ZIP
format)
(Added March 27, 2001)NOTE:
This source code is incomplete, unoptimized, and uh... not cleaned up. (I'm
an idea guy, not a programmer.)
Also, I don't think the source code will compile without
an e-mail client I licensed, and some other programs I incorporated. See the list
below.
Important Files:
SPEECH
SDK 4.0
Price: FREE
This is a BIG download, but Microsoft's speech SDK is fantastic. It not only
gives you state-of-the-art text to speech controls, you also get voice recognition
controls and more. Plus, you can't beat that price!
VISUAL
BASIC 5.0 (Control Creation Edition)
Price: FREE
Cybert's source code is written using this free version of Visual Basic.
Microsoft released this program so users could create Controls. Therefore, you can
NOT create stand alone .EXE files, and lots of advanced features are missing. But
again, for the price you can't beat it.
CsMail (Internet Mail Client Control Library)
Price: $20.00 (for single user license)
This nifty little program allows me to poll my e-mail server to see if new messages
have arrived. Using the sample source code I was able to get something basic working
in no time. There are probably more robust packages available, but this one was so
simple and quick I never bothered to look for anything else.
NetStepper (Internet Data
Collection Agent)
Price: $49.95 for basic version
This program allows me to write simple "scripts" that poll specific
websites and strip out just the text and data I want. It then saves this information
into text files so Cybert can read it out loud. I can, for example, pull the top 3
headlines off of a Yahoo news page, or grab the price data for my favorite stocks, or even
download a "joke of the day".
Navigation Code:
Nav.zip (My path planning source)
NOTE: This code is completely unoptimized and
essentially untweaked.
I wrote my own navigation code for Cybert that allows him to smoothly move
around the house without bumping into mapped objects. I created the map by pasting a
snapshot of my Map-n-Zap map into my Visual Basic form (Cye robots use a program called
"Map-n=Zap" for mapping and navigation). Then I "painted" over
the top of it with IMPASSABLE cells, BEST PATH cells, and NEXT BEST PATH (MARGINAL)
cells. These correspond to the three colors that can be painted on the map.
RUNNING THE SAMPLE PROGRAM:
Extract the enclosed files to a directory, then you can play with my sample program
by running Nav.exe.
PAINTING THE MAP:
You can "paint" on the map (or even create your own map) by clicking the
appropriate function key, or by clicking on one of the colored bars in the top right
corner. This should be fairly obvious when you look at the map.
IMPORTANT NOTE: If you make changes on the map you MUST use the
file menu to SAVE the map before you click on the "Choose
Start/Goal" button. If you don't save, all your changes will be lost.
PLANNING A PATH:
To plan a path, click on the "Choose Start/Goal" button at the bottom of
the window. Then click on an empty white cell for the starting point, and another
empty cell for the goal.
ABOUT THE MARGINAL CELLS:
When I make a map I start by drawing in all the walls and fixed objects in black
(UNPASSABLE). Then I surround these areas with grey cells (MARGINAL) to keep the
robot in the center of the map, and away from all the walls and objects. These are cells
the robot can move through, but the cost is higher so it tries not to. On
my actual map, the only white areas are in the middle of hallways and rooms. I have a more
recent version of the program that uses an extra gray to indicate even less desirable
areas.
OPTIMIZATIONS:
It runs fast enough on my computer that I'm not going to worry about optimizing it;
but I could make it a LOT faster (I presume) by not searching through the entire
cell array every time I update the path. (Currently, I go through the entire array
when I add "2"'s next to all the "1"s, etc.) It should be possible to
store the locations of all the "1"s (as they are added) and then ONLY go to
those cells to update the adjacent cells.
I'm pretty happy with how well it works. It even simplifies obstacle avoidance.
When Cybert senses an obstacle, I just "scan" in front of the robot and mark
anything in the path as UNPASSABLE. Then I tell Cybert to calculate a new path, and he
automatically goes around what's in front of him!
HOW IT WORKS (WRITE YOUR OWN):
If you want to write your own path planning algorithm, here's an overview of how
Cybert's code works: (there are better algorithms out there, but this one is really
simple to implement)
1. Start with a grid and fill every cell with a value of 500. (These are
UNMAPPED cells.)
2. Mark clear areas with 0 (BEST PATH) and mark IMPASSABLE objects (walls,
chairs, etc.) by putting the value "10" in the appropriate cells on your map.
3. Surround IMPASSABLE cells with MARGINAL cells. (These have a
value of 2, but this can be changed.) This keeps the robot away from the walls.
When you are ready to calculate a path:
4. Choose an x,y location for your GOAL, and put a "1" in all
cells that are adjacent to it. Like this:
5. Now search through the map for all the "1"s and put
a "2" in the adjacent cells:
| |
|
2 |
|
|
| |
2 |
1 |
2 |
|
| 2 |
1 |
G |
1 |
2 |
| |
2 |
1 |
2 |
|
| |
|
2 |
|
|
6. Next, put a 3 beside all the 2's. Keep going until you
find the robot's starting x,y location.
NOTE: If a cell is marked as IMPASSABLE do NOT put a number in that cell.
Once you find the robot, plotting the course is easy:
7. Look at the numbers in the 8 cells surrounding the robot's starting cell.
Pick the smallest number and have the robot move to that cell. Repeat this
process until the robot reaches the GOAL.
THE ROBOT CAN CREATE ITS OWN MAP:
If you want the robot to CREATE a map (rather than using a pre-made one) you simply
use a range finding sensor to "scan" in front of the robot. Blocked cells
can be filled in by updating the map with a "10" (IMPASSABLE) in the
corresponding cell.
You must re-calculate the path every time you find an obstacle. |