Line Follower that can learn

testerrrs

New Member
Hi all,

Thinking of trying this out as a project and wanted to run it past everyone here to see what people think and if anyone has any suggestions or ideas.

Basically I'm going for an LDR style black-line-on-white line follower. However I want it to learn the track the more times it goes round.

Im thinking use a 28X1 as it gives me the 4 PWMs, two of which can drive FETs for the motors, one for each back wheel. My idea at the moment is to have the LDR on the left control the left motor, and right LDR for the right motor. I will ADC the LDRs, and if one starts getting darker the PIC can drop the PWM on that side to slow the motor slightly to steer the buggy into the corner.

As for the memory, I'm thinking use the settimer as a background clock with a 20Hz 555 astable. On the first run, the system pauses every 50ms to check the sensors. Every time it needs to change direction itself it writes the "timestamp" (timer variable) to EEPROM as well as the corresponding speeds of each motor.

On the next run, it only pauses every 100ms, running its recorded program but still checking the sensors. On subsequent runs, it stops less and less frequently until it can do the track without using sensors.

Things I haven't quite worked out:
- How, when going along a straight line, do I stop it "snaking" back and forth across the line?
- How, from the points at which it changes direction, can I create a smooth turn?
- Are there any better ways of making it learn (ie. instead of learning each individual point)?

These are only initial thoughts! If anyone can think of an entirely better way of doing this I'd love to hear it.

Thanks very much,
*j
 

hippy

Technical Support
Staff member
An interesting project and like many other seemingly simple ideas could be incredibly hard to implement as there are a lot of things which need to come together for success.

To avoid snaking across the track you need to determine where the track is which will involve snaking around to start with, and more than you might do otherwise if you want to find a lot of edge points of the track rather than travel in long straight lines not knowing if you're in the middle of a track or a nanometre from its edge.

Once you know the edges of the track you can then determine a path which will take you along the centre of the track. When you have such a path you can then determine points on the line and the vector from each to get you to the next point.

All you then have to do is follow the vectors.

You can experiment and see some of the difficulties you are going to have to overcome by learning to walk with your eyes shut along a corridor then turning 90 degrees through an open doorway.

I'd also suggest turning to your favourite search engine to learn what others have done for these types of project.
 

testerrrs

New Member
That is very true. Maybe it's better to just "memorise" the straight bits and still rely on the sensors quite a lot in corners. In any case, I think trying to make the bot complete the track without using sensors is asking too much, and is far too likely to go wrong!

As for plotting the edges of the track and points, and then creating a line through the necessary points, how would I go about doing that? I mean, do you have any initial thoughts on how that could be done?

As for searching, I have had a quick look around but haven't found much. But then, I don't really know for what I should be searching.

Thanks for your reply though, very much appreciated :)

*j
 

hippy

Technical Support
Staff member
I don't have any experience of this and my 'how to' is pretty basic and theoretical; if you have a line between two edges of the track, providing it's known how long that line is ( far has been travelled ), where started from or where ended at, simple Pythagorian maths should work out where the mid point is on the line and that should notionally be in the centre of the track ( more so for shorter lines ). Of the length, staring point and ending point, only two need to be known to determine the other. With a list of mid points, joining them together should give the optimal course to take along the centre of the track, assuming the points are close enough.

I'm sure someone with more practical experience will be along later to give better ideas and links than I can.
 

BeanieBots

Moderator
Have a search for micro-mouse and/or maze solving. It is the same problem but detecting walls instead of lines.
IMHO a bit too much for PICAXE unless you also have the uFPU
http://www.micromegacorp.com/picaxe.html
to help out with the sums needed for vector navigation.
To avoid "snaking" you need to use analogue sensors which tell you how far off the line you are. By knowing the amount of error you can then use PID algorythms to effect a much smoother control and hence avoid overshooting past the line. A good tight well controlled line follower will be just as fast as a robot which knows where the line goes. The only advantage "knowing the maze" gives to a maze follower is that it avoids going the wrong way when there is a choice to be made.
 

testerrrs

New Member
Thanks for the input :)

I'm looking at using a stepper motor for each wheel as I can then record exactly how far the bot has moved.

I'd like an IC that I can PWMOUT to in the background that controls the steppers. Does such a thing exist? Or is there another way to control the stepper motors in the background using the 28X1?

Jon
 

bgrabowski

Senior Member
BeanieBots may not have heard about PicONE, which successfully solved a full-size maze at UK Micromouse 2007. It uses 2 Picaxes and will soon be available as a commercial product. It will no doubt be given another outing at the 2008 Micromouse competition at Birmingham TIC on 28th June.

It uses dc motors rather than steppers and has shaft encoders to keep track of distance travelled. Illustrations can be seen on www.PicONE.co.uk.
 
Top