Troubleshooting Step 3

As the programmer, I identified two problems for you to help me with:

Problem #1

When I get the program running I think that I should be able to press the round button to get the robot to stop moving and then beep but it’s not working.

Problem #2

I also tried pressing the triangle button twice and then the round button to see if that would work but my Edison just keep spinning.

Run the program in your Edison robot again. Follow the steps I described to see if you can replicate the problems the I’m experiencing. Do you have the same issues? Do you think the problems are human problems or robot problems?

Answers

Problem #1

This is a human problem. I made a logical error when thinking about how the program should make Edison behave. To understand my error, try running the program on your Edison again. This time, once the program is running, press the round button one time. Then press the triangle button two times. The robot will spin left, then spin right, then beep, and the program will end.

*Remember, the repeat until condition block is an indefinite loop that will loop until its condition is met. 

The loop tells Edison to do each item of code inside the loop in order, then come back to the top of the loop. If the loop condition has NOT been met, then the loop tells Edison to start the code inside the loop again. You can think about it as the loop asking Edison the question, “has the round button been pressed?” If the answer is “no” then the loop sends Edison back into the loop. If the answer is “yes”, then the loop sends Edison to the code that comes after the loop instead. 

A program will only check if the loop condition is met at the start of the loop, not while the code inside the loop is running. The robot needs to complete all of the code inside of the loop first, then it will go back to the top of the loop and check the condition. 

I pushed the round button but didn’t complete the conditions in the code blocks inside of the loop. That is what caused the error. 

Problem #2

The problem here is that, compared to a robot, humans are a bit slow! That’s because robots move through code really, really fast! 

*Remember, a program will only check if the loop condition is met at the start of the loop. In this program, as soon as the triangle button is pushed the second time, the spin right until the “triangle button pressed” block finishes, and the code moves to the top of the loop to check if the round button has been pressed. This happens very fast. It takes less than 10 milliseconds before the code checks for the round button press. That’s less than 1/100th of a second! Our programmer did push the round button, but by then, the code had already checked the loop condition and sent the robot back into the loop. The programmer was too late!

Problems adapted from [1 p. 131] Answers taken from [2 p. 98].