Onlyreon
Pybricks from patreon
Pybricks patreon

Line following with StarterBot - Boost Edition

🕑 Added 2024-07-16 07:59:42 +0000 UTC

Comments

Laurens Valk

That looks great! Thank you for sharing the end result. And good idea about timing the transitions to the same colors: Even if the segments look equally wide, the sensor may see one color "wider" than the other, due to the threshold between the colors. Waiting for the next transition to the same color solves that problem indeed.

Alexander Bell

I'm not sure if this is the best place, but wanted to give a little feedback. I always appreciate your prompt and helpful replies. A+ I ended up with something that actually uses the time between the two white segments rather than between the white and black segments. Could be because I did not define black but using it gave unpredictable results.  Once I converted to white, pause until black then look for white again - and the results were excellent as expected. I added an averaging section expecting the results to be more varying (esp because of the initial results) which is probably not necessary. I have a short video and a link to the code on a Rebrickable workbench post. Improvements always welcome, also feel free to use if it helps others. Thanks again. https://rebrickable.com/users/andybell/workbench/11882/

Laurens Valk

Here's one way to do it: - Make a counter variable, start at 0. - Wait until the sensor sees black. - Increment counter. - Wait until the sensor sees white. - Increment counter. - Your counter is a measure of position. - You could divide difference in position by the difference in time between two count values. Either the most recent one, or an older one you keep in a variable. This is a measure for speed.

Alexander Bell

I have been thinking about... finding the RPM with color/light sensor and the Technic, Disk 3 x 3 with 2 Black Opposing Sections Pattern. I certainly can Id the colors but unclear on how often they the sensor sends results and how to leverage that into time and rotation. Has this been done somewhere? (I know the "smart" motors have rotational control but thinking of using as a 'check' or with PF motors. Thanks for your help.


More Creators