I have two different students who are having similar issues with their robot running what it has been told, up to a certain point of their code. In both situations, the code is fairly lengthy and runs 75% of what they have, correctly. But the program will just stop and not continue the remaining portion of their program. At times, the program will run fine at times and at other times, it will stop and not run the entire program.
We have tried replacing batteries, deleting all programs from the brain of the robot and downloading the programs back to the brain, but I canât find any pattern as to why this is happening. Does anyone have any ideas of what to try?
Posting samples of the programs for troubleshooting by members of the community will help.
Most often, a program âappears to stop runningâ when there is a line of code that is unable to be completed. For example, a typical âmistakeâ might be a command to close a claw by moving a motor 60 degrees; however, when the claw picks up an object, the motor might not be able to close a full 60 degrees, so the program just stops to wait forever, because it canât continue until the command is complete. Telling the motor to close for .5 seconds, for example, would not cause a stop in the execution.
I have tried to post the âblocksâ code, am unable to do so. I have tried adding in a âwait timeâ right after the command that wonât run. Doesnât seem to help. Everything above this point in the code runs fine and runs each time.
I am going to try to add a screenshot.
The problem occurs with the last motion commands given at the bottom of the code, right about the âwait 15 secondsâ control.
At the very top of your code, add the set arm timeout to 1 second block, and also add a set claw timeout to 1 second.
Try that and then let us know what happens.
It fixed it because of what @kmmohn was saying above.
If you command a motor to do something (e.g. spin to 90 degrees) but it can never make it to 90, only 88, the blocks never completes, and the program never moves on.
In yout case, either the arm or claw, most likely the claw, can get to the position you are asking it to.
Without a timeout, it never gives up. With the timeout, if it gets jammed for 1 second, the code moves on anyway, even though the motor never reached itâs target.