lørdag den 29. september 2007

Modifications have begun!

We have now started rebuilding the car. Today the NXT unit was moved a bit backwards and now lies horizontal instead of the 45 degree angle it had before. The mount for the lightsensor has also been changed so that the lightsensor now points directly down at the surface and it is also alot closer to the surface then before. Work will continue at a later date.

torsdag den 27. september 2007

The war has begun

The goal with this weeks labsession is to get our Borg warrior through bootcamp, so that it will be ready for next weeks big race.
We will experiment with some prewritten color detection sensorprograms and try to get some insight into the simpler linefollower programs. We will then proceed to write a color detection program of our own, that is able to destinguish between black, white and green. We will then incorporate this into version 1 of our "race" program.

And the Borg said: "Let there be green"
..and he saw that it was good. Or at least better than monochrome vision.
Our initial experiments with the black and white sensor program was encouraging. The calibration feature is clever, since it allows the robot to function under various indirect lightsources without having to recode constant values. We did however stumble into a potential problem with the "ducktape" black color. It comes off as very light since it is very reflective of light. This means that the red light from the diode gets reflected instead of absorbed by the black color, hence making the values for white and black very close to each other. One thing that can be done about this is to turn the red light off, but this somewhat limits the functionality of the sensor in darker areas.
We will have to keep this in mind, and make a decision about what to do (or if it is even a crucial problem) once the race track is set up on friday.

After having played around with the black and white detector, we then wrote a ColorSensor program which could also see green, in addition to blackand white. It was basicly just a small addon to the excisting program, with an extra value.
To see if we are reading a green value, we compare the read value to the green light value (which we determine when we calibrate), but with a +- 1 margin to the value, to accomodate changing indirect light in some manner. We also make sure that we are not reporting a black or white value, if we are actually reading a green value.
This seems to work relatively well, as long as the shade of green is pretty constant, and the indirect light doesn't change too dramaticly.

Mr. Borg, take us to warp 3!
To be able to actually have a fast robot, we figured we would play around with some gearing. We dismantled the robot and rebuilt it with gears, levers and stabilitators. After all the work was done though, we did not see any performance inhancement. It seems that the motors simply does not have enough power to be able to handle any heavy gearing. Also the gears from the lego kit is not the best in terms of performance and stability. They are fine if you want to make something run slower (or more stable) at higher power, but it is harder to make it go faster.
We are still toying with a few ideas however, and the robot will probably end up tweaked out in some way eventually. We will definantly try out a few more ideas before giving up entirely in any ways.
Simultaniously we managed to create a simple linefollower program that uses the new color sensor. This means that we can now follow a line, untill we get to a green color, and the stop and output the travel time. This means that we at least have the minimum requirements up and ready for the competition, which is always a good thing.

Ready, set, think!
Untill next labsession, we will try to come up with intelligent ways to drive fast along a line. It will be easier to determine the best approaches, once we see the actual racetrack, but we are already playing around woth ideas about several lightsensors in action at once. By placing two lightsensors next to each other, eg. in front of each wheel, we would be able to make smoother turns, and hence keep up the speed longer.
One thing we have yet to decide on as well is in what manner to take sharp turns. But again, we will have to see the racetrack for final considerations.
Untill then, the work on the Borgs forward motion continues, but where it stands now, we fear that we have to do a total reconstruction, in order to apply proper gearing. Time will tell.

torsdag den 20. september 2007

Hear no evil

In todays lab session we will be giving our Borg robot ears in the form of the NXT microphone. The goal is to run a few experiments to determine the capabilities and the sensitivity of the newly attached unit.

Initial experiments:
The first thing we did after attaching the sound unit, was to download and run the SonicSensorTest java program. The idea here was to test how the microphone registers different pitches, loudness and how much proximity matters.
It was clear that a "sudden" noises like claps and stomps registered as quick peak values. The microphone has a fairly smooth "step" measurement, meaning that if you have a constant noise that increases in volume gradually, the microphone will detect that fairly accurately and increase the value read as well. However when the value gets to 93 and above the granularity fades and the value either stays at 93 or suddenly jumps higher.
Also the distance to the microphone will lower the value that is read, which is to be expected since even the mighty Borg have to obey the laws of nature. (At least sometime)

Steering a car with sounds
Next we installed the SoundCtrCar program and played around with it. The way this program works is by having 4 different movement modes that it alternates between: Forward, left, right and stopped. It switches between these states every time it hears a sound louder than the value "90". It doesn't matter what sort of sound it is or how long it persists.
After playing around with it a bit, we changed it so that we could abort the program using the escape button, even if we were in one of the movement modes. This was a rather minor change and was quickly done. However it is important to remember that one should be able to stop the car in whichever state it might be so that you don't have to pull the battery in case that you want an unexpected stop.

Applaud the Borg
Lastly we made a program with two movement modes: Forward and stopped. The way it changes between these states is again controlled by the sound that comes through the microphone. However now it will only respond to claps. Being able to distinguish claps from ordinary chatter and background noise, or even extended loud sounds is fairly "simple" since Sivan Toledo has already done all the research. This way we did an algorithm that did exactly as the exercise suggested and it works really well.
The fact to be noted here is of course that the robot never distinguishes between actual "claps" and other sounds. It only reads values from the microphone and then determines if the pattern of the input matches a typical clap-pattern. This way it would probably be possible to make the robot aware of even more specific sounds, if one had the proper sound patterns for these.
This method is not flawless of course, and a stomp in the ground will this way also be registered as a clap. A human would of course be able to distinguish the two based on the pitch of the sound and other things, but the Borg knows not these things.
Just as the Borg does not distinguish between humans and other lifeforms: All must be conquered. But all in due time...

torsdag den 13. september 2007

The Borg is watching you

The goal for the lesson 2 exercises is to experiment with the ultrasonic i2c sensor. In this session we will play around with an obstacle avoider program to get the feel of the sensor; and also create a wallfollower which includes upgrading our Borg warrior with new modifications.
As always the ultimate goal is conquering the world. Resistance is futile!


Experimenting with the ultrasonic sensor
After blessing the Borg with the sensation of vision we started experimenting with the sensor.
The first thing we could conclude was that the distance of the robots vision was quite limited, and that the granularity of measurements was quite crude. Especially with distances less than 10 and greater than 180'ish. Furthermore the angle at which the sensor was turned was crucial. If looking at a wall in an angle greater than 30'ish degrees it would tend to not see the wall at all or introduce alot of "jitter" in the measurements.
We also noted that the polling interval was somewhat limited, meaning that rapid movements will most likely go undetected.

Notes on the Avoider program
After initial experiments with the Borgs vision we wanted to take it to the next level. We uploaded the avoider program and ran a few tests with it. It is obviously quite a rough movement mode for our Borg, but we noted a few interesting things.
First off the robot would just run straight and then stop when within a set distance of an obstacle. But since this is the way it was designed it was quite expected. A notable thing it did however was driving slower as it got closer to an obstacle coming to a slow gentle stop. Almost like a Borg Cube stopping at a red light. This ensured that we would always stop at the desired distance.
If we however tried to tweak the robot to stop faster or have no "gentle stop" at all, it was possible for it to miss the stopping point and stop closer to the wall than desired.
All in all this form of simple feedback control is good for initial testing, but of course this will not do if we ever hope to conquer the world.

Look, a wall!
Next we examined the wallfollower program from Philippe Hurbain. We noted that it maintained quite a few variables and was rather "advanced.

We then continued to build a rotating station where we could mount the eyes to. This gave us better opportunities to play with different angles when looking at the wall. We will make sure to grab a picture of this new contraption in the near future.
We then proceeded to make a simple 3 state wallfollower program ourselves, partly inspired by the Philippe Hurbain algorithm and we managed to actually follow a wall consistently.
Things to note however, was that the angle in which the eyes were looking mattered hugely. If looking to straight at the wall it would just continue to turn right and drive around in a circle, since the distance it perceived did not change notably when turning. If the tower was turned in an angle at the previously examined 30 degrees however, it would loose sight of the wall or the granularity of the readings would vary too much.
We also experimented with the turning speed and noted a few things.
First off if it is "either one or the other" wheel turning, the turns would be too great and it could not follow the wall. If however we made "gentle" turns it would sway slightly along the wall in various distances, but still follow the direction without loosing sight of the wall or bumping in to it.

This comes at a cost though, since it means that it can not eg. detect a corner and turn sharply around it. The wall will have to be relatively straight for the Borg to follow it.
If we had had the time we would have introduced several "distance conditions" as in Hurbain's program, so that we could get the best of both worlds in a controlled way. It would be interesting to make it so that it could navigate a maze or find its way around a crowded room. This would require some pretty severe upgrades to the program, but who knows - the Borg might yet evolve into an even greater force.

Follow the Borg next week, where it will yet again unleash it's mighty powers in attempt to take over the world. . .

torsdag den 6. september 2007

Resistance is futile (Lesson 1)


The main goal for todays excersice is to get our lego robot (aka "The Borg") assembled and test that it is working according to specification. Furthermore we will make sure that we can compile, upload and run programs from the workstation. There are also a couple of small experiments which we will carry out with the LineFollower program.

The assembly of the robot was carried out swiftly, as most of it had already been done before this session. We did however experience some problems with installing the drivers and software needed on the workstation, and with uploading programs to our robot.

The problem turned out to be the fact that the drivers where installed in "Program Files" folder, which has a space in it. We reinstalled the drivers to a different location and got the first "Tune" program up and running. Whether it was a software bug or a human error that caused the robot to freeze up afterwards is unknown, but the problem was resolved by removing the battery and reinserting it.

After having "The Borg" come alive we then uploaded the LineFollower program and ran initial tests. It all ran as expected, and the robot was able to follow a (broad) black line by swaying left and right.
We noticed that the ligthsensor was not sensitive enough to read any notable light difference between black and white if the drawn line was thin. This is something to keep in mind when setting up courses for the robot in the future.


After the inital success we continued on to experiment with the robots "sense of color".
It turns out that the light sensor is able to destinguish between different colors, but it is a very minute destinction between most of them. What this means is that it would probably be hard to have the robot destinguish between different colors other than "light" and "dark" ones. Perhaps something inbetween could be possible as well, but the results would be dependent on the light coming from the environment and could vary alot.
The color table we were able to draw up looks as follows:
Color Light
Orange 59%
White 58%
Yellow 57%
Red 56%
Purple 43%
Black 37%
The experiments where carried out in the same spot by sliding different color papers under the lightsensor attatched to the robot. We tried to keep the incoming light the same on all tries to have a stable environment.

The next experient we carried out was to display the free memory on the heap while trying to see the difference between prining out a stored string variable and printing out a new string every time.
It turns out that printing out a string stored in a variable that is not canged saves alot of memory. The memory consumption while printing out the string literal "left" would increase gradually. This is because the program had to create a new string object every time and thus using the same amount of memory each time through the loop. If we instead printed the left variable out as is default for the program, the memory consumption would remain the same (and less) than for the other solution.
This is also something to keep in mind if memory consumption becomes an issue in the future.

Lastly we did an experiment where we altered the sample rate of the lightsensor.
It was obvious that if we had a very fast sample rate the robot was more responsive and would not sway very far from the line it was following.
If however the sample was increased to 1000ms it was possible for the robot to completely miss the black line of tape, by driving over it before the sample was taken.
Again it is a tradeoff between processing time vs precision and we suspect that it is something we will have to experiment quite a bit with for future projects.

This sums up the first day in the life of a Borg. Tune in next week for more life experiences

Project group:
Elvar Olafsson 20030582
Ebbe Flarup 20030592
Henrik Andersen 20030577

Bidragydere