Week 8 – Oliver

This week we were asked to write some pseudocode and then a program to find the can in our line-following mission that we are going to do in the Robocup Junior next year. Here is my pseudocode:

Pseudocode:
1. When the robot reaches the green area, stop moving.
2. Turn on axis anticlockwise until an object is detected within a range of 30cm. (can)
3. If the can is not detected move forward 2 wheel rotations and go back to 2.
4. When can is detected move forward while the can is being detected.
5. If the can is not detected stop and go back to 2.

At first, I thought it would be not too hard. The pseudocode seemed simple enough, although there was a few “return to” parts that are hard to execute in Mindstorms. My original code could detect the can by spinning around anticlockwise until it found the can but would not move forward until the can was moved out of the way. The reason it did this was that I had mixed up the larger than and less than symbols in a loop.

I then realised that when the robot moved forward and crashed into the can, the ultrasonic sensor banged into the can. This must have messed up the sound waves, because the robot started turning again. Because the sensor couldn’t detect the can if it was straight up against it, I decided to make a bar to keep the can away from the sensor so it could still be detected. I had finished making it but unfortunately we ran out of time so I couldn’t attach it onto the robot.

My finished code is below:

And now for (drum roll please…) The Word of the Day: Batrachomyomachy – A pointless argument.