Date: 08-03-12
Duration: 3 hours
Group members attending: Tore & Troels
Goal
The goal of todays exercises was to control a car with sound and light.
Plan
1. Build a robot.
2. Write and test a program, that has the bot drive faster, when the sound is louder (exitatory)
3. Make the bot go faste, the more silent is. (inhibitory)
4. Mount two light sensors and use them to steer the bot away from or towards the light source.
Execution
1. We found this (*1) nxt 5 minute bot, which was rather fast to build. We modified it a bit, so it had a turnable third wheel. The bot now looks like this:
2. We wrote a simple program, that takes a sound input and transforms it to a power output to the motors. The program can be seen here (*2). We had some touble with the car dragging to the left, even though the to motors was set to the same amount of power. We changed the motors, and got it to drive straight. Apparently one of the motors is more powerful than the other two.
When we clap the bot speeds up for a second or two and then slows down again. When we play a song, the volume of the sound is constant and the bot maintains speed.
The mapping was done like this:
public int normalizeSound() {
int input = soundSensor.readValue();int output = 55 + (input * 45) / 100;
return output;
}
3. We just changed a few signs to accomplish this.
public int normalizeSound() {
int input = soundSensor.readValue();int output = 100 - (input * 45) / 100;
return output;
}
Since the initial value for the motor is close to 100 it becomes quite unmanageable, since it will drive fast all the time if there is no steady sound source nearby. As a result of the way we mapped it we needed a lot of noise to slow it down to a manageable level.
4. We mounted the two light sensor as seen in the picture below:
There is about a 45 degree angle between the sensors, this will make them read more different values and the direction of the bot should be easier to control. We changed this later however, so the sensors both pointed forward.
Our two light sensors did not seem to measure the same values. Where the two values should be the same, we had a motor power difference of about 10. Testing the light sensors by themselves, we found out the normalized value read from the two sensors had a difference of about 30-40, which had a rather noticeable impact on the motor powers.
We basically just took the formulas from (*3), and the program can be seen here (*2). This program has the bot turn away from the light.
Show below are the differences between the two bots in (*3).
Bot2a: When we shine light on the left sensor, the right motor would slow down and vice versa.
Bot2b: This bots turns toward the light.
Bot2a
public int normalize(int input) {
int MIN_VALUE = 400;
int MAX_VALUE = 800;
int output = ((input - MIN_VALUE) * 100) / (MAX_VALUE - MIN_VALUE);
return output;
}
Bot2b
public int normalize(int input) {
int MIN_VALUE = 400;
int MAX_VALUE = 800;
int output = ((input - MAX_VALUE) * 100) / (MIN_VALUE - MAX_VALUE);
return output;
}
Status
We got through todays exercises and got the different vehicles to work, although we had some trouble with the motors not being equally strong, and the light sensors measuring different values, so the turns was a bit uneven. But the vehicles worked well enough despite these flaws.
We accidentally skipped a part with the one sound sensor controller. We could have had the car drive forward in some volume interval and backwards in another. Then the car might drive forward towards the sound until it became too loud, and then backwards instead. This would have the car oscillate at some distance.
We did not do the vehicle 3, but a quick thought about it is to have two sound and two light sensors. To make the bot drive towards the light we use the 2b bot, and then have claps decrease the power, so the bot turns away from the sound. Then the power to the motors would be the sum of the power from the light and the power from the sound. Or maybe have the sound add “negative power”.
references
(*1) http://www.nxtprograms.com/five_minute_bot/index.html
(*2) http://troelskristiantore.blogspot.com/2012/03/legolab-6-code.html
(*3) Notes on construction of Braitenberg's Vehicles, Chapter 1-5 of Braitenbergs book
No comments:
Post a Comment