I am planning on using the line tracking kit on my competition robot for this year. I do not have the luxury of having the official comp. tiles to practice on but i do have some dark blue ones that i plan to practice on.
My question to everybody is what value do you usually use to determine if you are on a white line or on the gray tiles for competition use? I know that white returns 0 and black returns 255 but i know having a bit of a buffer is good. I was thinking about saying anything < 30 is the white line and anything > 30 is a field tile.
What have some of you guys used in the past to determine if the bot is on a line or on the tiles? I know Mr. Tyler had quite a few bots with line tracking last year and quite a few others did as well.
254 used Easy C which gave the line sensor values between 0 and 1000 (with 0 being the lightest) (Edit: should be 1023). For tracking the line, we set under 100 to be on the line. Line sensor readings off of the line tended to be around 700. Line sensor readings on the line tended to be around 35. Keep in mind that readings can change a lot depending on the amount (and type) of light in the room and the condition of the field.
Looking at page two of this it looks like the sensor returns 0-255 how did you get it to do 0-1000? Thanks i can still use you answer as far as percentages go ya know?
Indeed this is quite confuzzling. Either way if i do have to use values 0-255 i can percentify (totally a word ;)) your values and use them. so i would use so the “translated” values would be something like anything < 25 is the line and anything > 25 is the tiles. The line should return about 6 and the tiles should return about 150. this is pretty close to what i had guessed originally!
For our bot, we found that the white lines are usually between 90 and 60 and off of the tape on the mat, the value is around 700. We set the threshold to 200 for finding the line and it turned out that the lighting was too dim on our competition field and it missed the line and ran into the wall for the full 20 seconds. I’d recommend taking your dark value e.g. 700 and subtracting 250 or so since while most fields aren’t going to be much brighter than the room you work in, they do stand a good chance of being dimmer.
The value could also change drastically depending on how high off the ground you have the line tracker. I would get new values for your line tracking program each time you go to a new tournament so you don’t run into unexpected problems.
It should be pretty easy to make the target values a variable or constant so that when you get somewhere you can tweak them a little to match your play field.
Perhaps instead of getting an exactly matching practice field you could just get one tile (or smaller) that you can use to calibrate your sensor. Then you’ll have a good range for a “real” field and since you make it easy to change in your program, you can flip back and forth.
Heck, you could even use some jumpers to program in 2 or 3 pre-set settings to use, assuming you have that many digital ports open (and want to deal with a bunch of jumpers). 3 ports would give you what… 6 different combinations if you were ambitious or just 3 if you wanted it to be easy to understand? What a headache to track
I personally have found the the line followers are alot more reliable if you can seal them from external light sources as much as possible. For example on my competition bot, i’ve wrapped as much of the area surrounding the sensors in the high grip mat. It seems to be working pretty well so far…
The easiest way to do this is to use a potentiometer to set the threshold value; then you can tweak it without having to use a lot of I/O ports and remember jumper combinations.
As an aid to setting it, you could use an LED in one I/O port. Write some code that averages the left and right sensor values, then lights the LED if this average value is within about ±10 of the potentiometer value. To calibrate for a given surface & lighting conditions, do the following:
[LIST=1]
*]Place the robot on the playing surface such that the left sensor is right over a stripe, and the right sensor is not over a stripe.
*]Turn the potentiometer till the LED lights. The potentiometer is now set to an approximate midpoint between stripe and non-stripe readings for this particular playing surface and lighting conditions.
[/LIST]
I like it guys perhaps what i can do is make the threshold value a variable and call it something like “Threshold” (Genius) and then make a part of the code where i set “Threshold” so i only have to mess with it once if i need to tweak it during comp. It sounds like 700ish is a common number for the tiles and the white line can drastically change depending on light. I assume that the lights will be at least normal if not bright at QCC so maybe to be save i could set the threshold a bit higher say 300 which is still probobly fine in most “standard” competition light situations.
Quazar that sounds like a great idea as well however i have already given myself too many complicated start up things for the bot. I have 4 bumper switches to toggle between match type (Robot skills, programming skills and standard) as well as to toggle between two auto modes and the side that i place the robot on. Although it is possible the best solution for the problem it think i will just stick to changing one variable in the code. Who knows if i have some time left before the comp i may try this out. Some questions that i have for you. Am i allowed to use the LED for comp. because technically speaking it is serving a purpose that does help the robot in a weird kind of way? second is when i turn the potentiometer until it is close to the average would you lock it down somehow or remove the shaft? my concern is that if the shaft were to spin a little bit or something it could mess up the values and if i remove the shaft the pot may vibrate and spin. perhaps i could just get the value right at the beginning of the code and not worry about it after that but that still leave the issue of having to recalibrate every match.
Thanks for your help guys.
~DK
EDIT: I answered one of my questions. i could use the vex LEDs to ensure i would not get into any trouble with the LED not being a decoration or i could just take it out for the matches.
You don’t have to make it a startup-only thing. The calibration process itself would only be done when you tweak the potentiometer. But as for code, you can run the average/compare/LED thing every time you read the line trackers. It is harmless and should be quick enough to not effect performance perceptibly.
It isn’t much of a departure in your code. Anywhere you would use the threshold constant, you just read the analog port instead.
Self-answered below…
That is a valid concern, but I think the pots have enough friction to hold a setting even if the robot experiences high vibrations or fairly high G forces. I think it could hold a setting through any impact that didn’t seriously damage the robot (in which case you have bigger problems than the line tracker threshold).
I would not leave a shaft in the potentiometer during competition - I would make an adjuster key that is a lock collar on a short shaft. Use it during calibration and carefully remove if once you are done.
That is exactly what I did with a (non competition) line tracker and it held a value over several months, even when engaged in some fairly rough driving.
What you should do is recover a value from a sensor at the beginning of the program so the robot uses that as the base. then uses a percentage of the base to percieve if the values recorded are the ones from a line. =)
For EX: when the robot starts up it picks up the value of the matt, lets say the popular 700, just have anything thats 200 below that be recognized as the line
Wow that’s not wicked simple and wicked smart now is it;) I just had one of those “why didn’t i think of that” moments. This sounds like a pretty good. the only issue here that i see is that if by some weird happening the line trackers picked up some low ball value for some reason i would have no human interaction with the “threshold” value that i would have if i tested the field value once in the beginning of the event. however your way seems WAY more convenient. Thanks
You could have the line trackers constantly updating the threshold value. You can also program a button on the remote to reset the values to some known safe value.
The constant updating is a good point but getting a little bit complicated because the original idea was to immediately get the gray value and subtract 200 or so. if you constantly update you have to average the values of a line and the tiles without having a threshold yet to know when you are on which. it is just a bit complicated. Although the idea of getting the value of the gray tile right away may hit a fluke once in a thousand i am pretty happy with those odds just pointing out a possible issue.
as far as the fail safe on the controller… doesn’t that kinda ruin the idea of autonomous? hahaha