Line Follower Basics Available?
-
- Posts: 32
- Joined: Sun Feb 07, 2016 6:10 am [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Line Follower Basics Available?
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.
-
- Posts: 180
- Joined: Tue Jul 28, 2015 12:56 am [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Line Follower Basics Available?
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. ![Smile :)](./images/smilies/icon_e_smile.gif)
![Smile :)](./images/smilies/icon_e_smile.gif)
- sil
- Posts: 40
- Joined: Thu Oct 01, 2015 1:04 am [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Line Follower Basics Available?
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!![Smile :)](./images/smilies/icon_e_smile.gif)
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!
![Smile :)](./images/smilies/icon_e_smile.gif)
- sil
- Posts: 40
- Joined: Thu Oct 01, 2015 1:04 am [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Line Follower Basics Available?
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.
-
- Posts: 3
- Joined: Wed May 02, 2018 3:43 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Line Follower Basics Available?
Thanks for the share. I am going to play with the code to see if I can get it running my little bot.
Who is online
Users browsing this forum: No registered users and 6 guests