First of all, I have no idea whether I'm just too stupid to come to a conclusion regarding the problem, or it is just not possible to solve it without adding additional sensors/hardware...
Either way, time doesn't run slower and the deadline comes closer far too fast and I really hope that you are able to help me.
The task:
A Robot controlled by a single NXT-Brick has to follow a black line on white ground. Occasionally there are 3 white stripes on the black line indicating a platform next to the road. The roboter then has to leave the course, push a small ball off the platform, return to the line and continue it's journey.
To build the robot we are allowed to use 1 NXT-Brick, 3 motors, 2 light sensors, 2 touch sensors and all kinds of non-electrical LEGO-Bricks. The code has to be written in NXC.
As for now my group and I were able to code the program which lets the robot follow the black line.
But regarding the code for the stripes we are becoming frustrated more and more...
This is a video of an earlier stage of the robot:
You can see the stripes and the platform around 0:15 mins
The problem we see is, that there is absolutely no way to distinguish the stripes from the white ground.
I know that you all are much much more familiar with Mindstorms, NXT and NXC and I really hope there is someone able to help.
Hoping for fast answers,
gravy
P.s. I hope I added all the information needed. If something important misses please tell me.
Re: NXC: Need help to complete project
Posted: 25 Jan 2012, 13:51
by tabbycatrobots
Maybe you can use some ideas from my project "Kemmel - Combining Line Following and Formula 1", described
in this forum, Mindstorms Projects. Your robot has 2 sub-tasks 1. follow the black line, and 2. watch for
a marker of some sort (in this case, some black / white stripes), and the robot has 2 light sensors. Structure
your software the same way. Are you familiar with multi-tasking (multi-threaded) programs? This is a
simple way to solve this problem. Use one task, in the program, to monitor one light sensor and thus to monitor
the left (or right) side of the black line. Use a second task in your program to monitor the 2nd light sensor
and count black white changes. The first task that is monitoring the line edge also controls the motors, i.e.
steering. When the 2nd task counts 3 black white changes, it writes a global variable that the 1st task is
checking periodically. (Through trial and error, you will have to determine the checking period.) When the
1st task reads a pre-determined value in this variable, it stops following the line, and does the ball pushing.
So, I suggest thinking about the software part as a multi-threaded program. Hope this helps. suggestions -
mount the light sensors such that when one is over the left side of the black line, the 2nd light sensor is over
the middle of the black line. Improve your line following code so the robot tracks the left side of the line better.
Re: NXC: Need help to complete project
Posted: 25 Jan 2012, 15:17
by tabbycatrobots
In my "Kemmel" topic posts, see my last post for the R03 code zip file. And another suggestion,
in the thread that watches for stripes, have some code such that after it sees 6 - 10 cm of
black, it starts back at 0, counting the stripes. This should help handle the case of the robot wobbling
as it line follows, such that the 2nd sensor is not over the center of the black line, and the 2nd
sensor sees white background and starts counting stripes.
Re: NXC: Need help to complete project
Posted: 31 Jan 2012, 04:03
by mcsummation
The motor/wheels in the back seem to make it harder to turn sharply when the track changes quickly. Why not use a "free castering wheel" back there? Something like this http://www.nxtprograms.com/NXT2/castor_bot/index.html.
Re: NXC: Need help to complete project
Posted: 31 Jan 2012, 10:08
by pepijndevos
It seems you are currently putting the light sensors outside of the track. While you could follow the line with one sensor using PID, another option is to put both sensor *within* the line. This way, you can distinguish driving off the line from the stripes, because normally, only one sensor will see white, whereas with the stripes, both will be white.
So in theory you don't even need to count them, just as soon as you get 2 white readings, do the pushing, if you get 1 white reading, turn.
Re: NXC: Need help to complete project
Posted: 15 Feb 2012, 20:24
by gravy1992
tabbycatrobots wrote:In my "Kemmel" topic posts, see my last post for the R03 code zip file
First of all I really have to thank you all, especially you tabbycatrobots.
Mostly because of your code we drastically changed our point of view about NXC-programming. Thank you very very much for supplying us with such a great example
The reason why I did not check this thread very frequently after reading the first answers is, because we finally got the good ideas to complete the code and therefore had been quite busy.
It might not be the perfect solution (in fact we just use the very basic methods and commands), but it is working perfectly.
What we did was basically adding quite a lot of "timers" checking for white stripes or plain white space, indicating a loss of the track.
The result:
Im sure that there are still lots of possibilities to enhance the code, but I am quite confident that everything will work out fine when we have to present our precious little robot
So once again: Thank you all and keep on with what you do. Lots of the projects I've seen here are not only fantastic creations, but true art!
Re: NXC: Need help to complete project
Posted: 19 Feb 2012, 12:57
by tabbycatrobots
I'm glad my ideas could help. I'm interested in the case in the video, where there is a very sharp corner
and if your robot doesn't turn enough on the first try, it travels in reverse for a short distance, then
tries to travel around the corner a second time, and always seems to be successful on the second try. If
you don't mind, would you upload your programs that shows this - maybe in a zip file. I'm thinking this
technique might help when my racing robots miss their pit entrance.
Thanks.
Howard