Sunday, May 16, 2010

Fire Fighting Robot- Part 6 Picoblocks

Now that we had our mechanism down, we were able to focus on the programming aspect of the final challenge. It took a lot of trial and error to figure out to make the MotorCar find the candle. Our candle-finding algorithm consisted of using shaft encoders to have the MotorCar travel a certain distance and having several checkpoints during its path to make sure that it is directed towards the candle.
We first had the car spin left to locate the candle. Once it did, we had the MotorCar stop and since it didn't always stop precisely in front of the candle, we had it nudge in order to find a more precise position. After the car was centered on the candle, we had the car travel halfway, using the shaft encoders. Once the car reached that halfway mark, we had it spin again to center itself on the candle. Then we had it move bit more forward, so that it was had 75% of the way. We had it check again its positioning and after that point we had it inch up to the candle and check its position regularly. This would ensure that the car would always travel towards the candle. Once the MotorCar was close, we had it travel until the sensors at reached a certain value. We didn't want to MotorCar to run over the candle and since the mechanism extends out, we had the MotorCar stop a safe distance away from it, this time by not using shaft encoders but sensor values.We did this by using "wait until" blocks. So for example in the second to last block, we had the car move forward and once the sensors read a certain value, it stopped. The rest of the program was similar to that procedure and uses a lot of "wait until" blocks. For example with the checkpoints, we had the car spin left until it read a certain value and then it stopped.
This technique required us to check what the sensors read at each of the checkpoints. The problem was that these values constantly changed as the candle decreased in size and if the sensors shifted on the MotorCar. Another problem was that the car did not always move to these exact checkpoints because sometimes the MotorCar did not travel perfectly straight. So in order to account for that, we made our sensor values a bit lower so that if the MotorCar was behind its checkpoint, it would still be able to see the candle. It was just a tedious process because the sensors a very sensitive and it is hard to get accuracy in the MotorCar's movements.
Below are screenshots of our LogoChop programs:


Above are the blocks that are responsible for the basic movements of the blocks, for example like moving forward, stopping, spinning left and right. We copied these blocks from our previous LogoChip challenges in this course.
Below you can see our program, the long list of blocks to the left. It consists of various of small procedures that consist of the MotorCar checking its positioning or moving forward. As you can see, it is a pretty long program that has many parts to it. The last block turns on the motor for the mechanism and tells the shaker to shake for 8 seconds.

When we tested our program, it worked fairly well but it required a lot of patience and double checking. It would have been better if we had made a program that relied less on the shaft encoders and that moved forward according to what the sensors read, instead of having it checking for its positioning every once in a while. What we could have done was to first have the car center on the candle and then to have it keep the candle within its range of sight by using the sensors. There many other ways to solve this challenge, but some are more accurate and easier than others. I'm afraid that we did not pick the easiest solution, but that is part of engineering and it takes a lot trials and errors to figure out the best way to achieve something. By the end of the week, Esther and I didn't really have enough time to re-create a program, but we decided to work with what we had and even though we had a some pretty successful test runs, our program was not consistent in its results.

No comments:

Post a Comment