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.
These were the simple procedures that we used at the foundation of our program.
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 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
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.
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.
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.
No comments:
Post a Comment