[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 574: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 630: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 113: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 113: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
Plum Geek Forum • Line Follower Basics Available?
Page 1 of 1

Line Follower Basics Available?

Posted: Thu Feb 11, 2016 6:40 pm
by wclift
Does anyone have the basic information on Wink line following sensors? This information doesn't seem to be available in the standard tutorial packets yet.

Re: Line Follower Basics Available?

Posted: Thu Feb 11, 2016 6:57 pm
by Kevin
If anyone wants a line following example, contact me through the contact form at the PG website. I'll send you what we used for the KS videos. When I get to that part in the lessons, we'll be re-writing this code to make it more clean. What we have isn't super pretty but it works and you can tune it if you're interested. I didn't want to post it outright because I didn't want it to confuse and/or scare people. :)

Re: Line Follower Basics Available?

Posted: Fri Feb 12, 2016 1:55 am
by sil
Take a look in the Ringo code area where i posted my simple line following example. I haven't adapted it for Wink yet but it should be simple to follow if you want to try it yourself. The process I used is based on Ringo which only has two IR sensors underneath.

I started by writing code to read the two sensors and output to the serial port so I could look at the values via the arduino software, now they have the serial plotter this helps immensely. I would place ringo in random locations on my running surface to see the "background" values, and I made a "pad" of the line material to similarly obtain values for the line Ringo would see. This allowed me to be confident that Ringo could "see" the line differently to the background. From this process I had a threshold value where i was confident the running surface would never return a value lower than this threshold and any value below the threshold is either the line or off the edge of the desk.

So my approach in the code loop is to read the left sensor and right sensor in turn then compare them to the threshold value, if one sensor detects the drop (ie the line) then i speed up one motor to turn ringo back to the line again. Simple but its fast and works, and i'm confident about my posted code, its been reliable on different tracks I've made. Its probable not the most elegant code and no doubt the sensor check could be reduced to a function where you call the sensor rather than duplicate the code with different variable names, but thats a future project for me or anyone wanting to play with my code.

My poor Winks are being ignored, I play with my Ringo too much. But the code I posted should work if you change the read sensor numbers the the appropriate numbers for Wink, (I believe Wink has four in a row under the front so use the numbers for the leftmost and rightmost sensors only and ignore the middle two to start with, and i think Wink should line follow happily ( I can see myself trying it this weekend).

I do recommend you have a try, line following sounds like it need complicated decisions but its really simple, I started from nothing except the Ringo guide and avoided looking at plumgeek's code so it didnt influence me and found it a simple exercise and worthwhile doing. Forget the shape of the line, its width can matter though. A piece of black electricians tape on a table top is all you need to start with. I think Wink's IR sensors are much closer than Ringo's so I dont know what width of tape would best suit to start. That also might mean line following needs to be a reversed approach to what I took for Ringo: that is treat the line value as a background and look for a change in value the indicates Wink is seeing the table surface and turn her back to the line.

There's no right or wrong way to approach line following. If you find a method that has your bot following a line thats great. Then you end up wondering why it ran off the line or how to get it to run faster or take tighter turns , let your imagination run wild and try lots of things and enjoy it all the way! :)

Re: Line Follower Basics Available?

Posted: Fri Feb 12, 2016 7:34 am
by sil
Sorry, disregard the above. I've been trying to adapt my code but failing, i think i'm not reading the sensors correctly and it seems some command have a different case between ringo and wink, eg Motors() vs motors(). Back to the drawing board for me.

Re: Line Follower Basics Available?

Posted: Fri Feb 12, 2016 7:41 pm
by wclift

Re: Line Follower Basics Available?

Posted: Sat Feb 13, 2016 3:18 am
by sil

Re: Line Follower Basics Available?

Posted: Thu May 03, 2018 5:07 pm
by TKLG13
Thanks for the share. I am going to play with the code to see if I can get it running my little bot.