Page 1 of 2

Troubleshooting issues with NXT 2.0 Robot

Posted: 26 Oct 2011, 22:39
by paulharv66
Hi,
I just joined the forum - mainly on behalf of my son.

I'm starting off with a general question - if a robot/program does not behave as expected, or behaves inconsistently, what's the best approach to figuring out if it's a programming problem or a problem with the NXT itself?

I have tried to communicate with the Mindstorms support guys - even sending them a program that my son wrote and video of it misbehaving - but this has been a pretty luckless effort so far.

I feel like we need to sit down with an expert who can look at the bot, look at the program and tell us why it's behaving as it is!

Pretty much every bot my son has built has either not behaved as expected, or has sometimes behaved as expected and sometimes not. The bots and programs are simple (with simple color detection, path following etc) and when I look at them they make sense - the logic looks reasonable.

Any suggestions where to go from here?

Thanks so much
:roll:

Re: Troubleshooting issues with NXT 2.0 Robot

Posted: 27 Oct 2011, 00:06
by spillerrec
If a program is misbehaving it is usually because of either:
  • You think the program does something, but it is actually doing something (slightly) else.
  • You forgot to take something into account
I will try to write some examples tomorrow. While they sound like errors only "stupid" people would make, it happens all the time even for the best people out there.

So one approach to the first issue is to ask another person to look trough your program, but without telling too much about what it does. When he have grasped an understanding of the program, make him tell you how it works. Did his explanation match exactly what you thought it did? If not, how and where did it differ? It is often just small differences, but they can have big consequences.


With the other issue, you can approach it by trying to do the program manually. Go through the program step-by-step in different situations, without thinking, without assuming how anything works. What happens and how does the program handle it? Are some situations handled in a way that doesn't make sense in that specific situation?

The problem with this approach together with robotics is that sensors receive external input and it is difficult to predict this exactly.
Consider a line following robot which takes input from a light sensor. If the amount of light in the room increases a lot, the light sensors reading becomes higher and it might have difficulty to differentiate between black and white.
Another aspect of the issue is that the robot will not have the same start conditions. Slight changes in the start position and direction will make the program run completely different from before. (The goal in robotics is to make the result of the program as similar as possible no matter how the conditions were before, now and in the near future.)

So since it is difficult to run the program by yourself, you can instead try to get it explain to you what it is doing. You can do this with sound, make it Beep in certain ways depending on the situation, or you can do it using the in-built display.
When you then run the program, try to notice which situations often happens when the program misbehaves. Did it do something which it shouldn't have done here? Or did it think something happened (and reacted based on this) which actually did not happen?

Re: Troubleshooting issues with NXT 2.0 Robot

Posted: 27 Oct 2011, 09:10
by paulharv66
Thanks so much for you answer - really appreciate it.
So it's not unheard of to have even a simple robot and simple program misbehave...that's actually good to know!
Is this forum a good place to upload a program and have someone look at it?

My son's current bot/program basically grabs balls of different colors, and does one thing with blue balls, and something else for other colors. It sometimes does this correctly and sometimes not. (Initially he had it set to treat red balls in a special way and it would not, then he changed it to blue and it started working, but only sporadically. This makes me question if the unit is actually working properly.)

Other issues we've seen - he had a track following bot and it worked ok when going clockwise around the track. It followed the track and would speak the name of a color when it hit a colored square. When he had it go anti-clockwise it would go off into some different branch of logic when it detected a colored square, and get stuck in a loop.

Cheers,

Paul

Re: Troubleshooting issues with NXT 2.0 Robot

Posted: 27 Oct 2011, 12:17
by h-g-t
Best if you post your code here (or a link to it on another site if it will not post).

If it is written in NXT-G then use the 'pack and go' option to make sure everything is included.

Re: Troubleshooting issues with NXT 2.0 Robot

Posted: 02 Nov 2011, 14:11
by paulharv66
Tried posting the *.rbt file, but it doesn't upload. No error or anything - just nothing uploads.
Any suggestions where I might post it - I don't have a website or access to a publicly viewable one?
Anyone happy for me to email it to them?
Cheers

Re: Troubleshooting issues with NXT 2.0 Robot

Posted: 02 Nov 2011, 15:45
by mattallen37
zip it and upload the zipped file.

Re: Troubleshooting issues with NXT 2.0 Robot

Posted: 03 Nov 2011, 10:15
by paulharv66
Excellent - it uploaded - thanks.
RobotBall.zip
(644.56 KiB) Downloaded 679 times

Re: Troubleshooting issues with NXT 2.0 Robot

Posted: 03 Nov 2011, 13:15
by hassenplug
Your program seems pretty simple & straight-forward.

I suspect the problem is that the color sensor does not do a good job of identifying the color of the ball. The sensor has to be pretty close to an object to correctly identify the color, and the round balls make that a little harder.

One suggestion: Take out all the movement after it identifies the ball, and simple have it show (or say) the color of the ball. See how many times that comes out correct.

Next question, is the program executing as you would expect, assuming it didn't correctly identify a ball? (ex: it may continue moving, as if it didn't see the ball, or it may do the wrong sequence of moves. But when it executes a sequence of moves, is the sequence as you would expect, even if it's for the wrong color ball)

Steve

Re: Troubleshooting issues with NXT 2.0 Robot

Posted: 03 Nov 2011, 20:44
by paulharv66
Thanks.
We'll try out the troubleshooting steps.

Re: Troubleshooting issues with NXT 2.0 Robot

Posted: 05 Nov 2011, 14:31
by paulharv66
Attached is a modified program - dead simple.
The expected behavior is:

- Go forward until it detects a ball
- If color is blue says "Blue" then exits program and stops
- If color is red, green or yellow says "Malfunction" and continues going forward/looping

The behavior we're actually seeing is erratic:

- Detects blue and just stops (doesn't say "blue")
- Detects blue and says "blue" but continues going forward/looping
- Detects blue and says "malfunction"
- Detects red, green or yellow and says "malfunction" (correctly)

So the "blue" condition is inconsistent.

Other troubleshooting steps:
- We've tried it in a dark room.
- We've tried holding balls directly under the sensor
- Changing batteries

It seems there are three possibilities
- The program is not written correctly for the desired behavior
- The color-sensor is not working right
- The NXT block is not working right

Any input would be greatly appreciated!

Thanks