Saturday, May 15, 2010

Firefighter: To the Flame

We started the programming without the putting-out mechanism because we couldn't get the servo motor to work properly.

Luckily, when we started, we knew where we wanted the sensors to be placed and had some idea of how we were going to get the car to determine where the candle is. We used three sensors, one right in the middle, and one on either side of the car.

When looking at the car from behind:
Sensor 1 = left sensor
Sensor 2 = middle sensor
Sensor 3 = right sensor

We started out by getting a sense of how the sensors would read at different positions and at different distances. Programs to read each of the sensor readings at different positions.
We tested from close up what each sensor read when the car was looking straight at the candle, when it was turned right and when it was turned left. We did the same for when the car was 10 feet away. As we had hoped for, when the car was looking straight at it, the middle sensor read the highest, when it was turned right, the left sensor read higher and when it was turned left, the right sensor read higher. This was the information we needed for the car to guide itself to the candle using feedback from the sensors.

These were the simple procedures that we used at the foundation of our program.

The first thing that we decided was that the program had to be split into different sections. The first was getting the car to face the candle initially before it started heading towards the candle. So we made it spin in one direction until the middle sensor hit a certain number and then keep adjusting itself until the middle sensor hit a higher, more precise number.

Find1
It ended up that we probably didn't need the second part of this adjustment because in practice, the car usually just stopped after the initial turning and then went on to the next part of the program.

The next section of the program was the actual driving to the candle part. We didn't really trust any of the bang bang or proportional controls for straightness. So we decided to use feedback, not from the shaft encoders, but from the sensors to guide the car. We implemented a program similar to the bang bang control we used earlier. If either of the side sensors reads larger than the other one, the car will bear in a certain direction. This happens until the middle sensor reads a certain number and, since we knew that thresholds from the sensors are not very reliable, the count is above a certain number.

Go
Once it got to the candle we also added in a safety-net find program that would reposition the car so that it is facing the candle just in case it was not facing the candle after driving there.

Find2

We also knew that we needed a put-out mechanism but we didn't have one at this point because we needed to ask Lyn how to get that to work.

So we put it all together and ended up with this (only we did not have the waits at this point, those were an iteration that we added on after we got the put out mechanism to work). We figured that that the car did not get to the candle every time depending on how much it swerved. We programed the car so that once the 'go' function was over, it would nudge and put out until the sensors sensed that the candle was out.


One thing is that the car drives very slowly but we don't quite know why it does this.

No comments:

Post a Comment