Log in

View Full Version : Colour Recognition


reidmc
30-04-2012, 12:37
Hi, This is my first post on this forum, so if there are any forum rules please just fill me in.

I am in a grade 11 robotics class and up until a short while ago I could follow everything and do all the assignments. Then my teacher gave me an assignment to make a program to make the robot follow a specific colour, I've done a program that allows you to drive the robot from a joystick and other basic beginning programs but I don't even know where to begin with this, most of my classmates are oblivious or dismissive ("oh yeah that's really hard but I'm busy playing video games in class")

I have never done anything related to robotics before (though I have done some computer programming) so please do not make too many assumptions as to what I know.

If you need to know anything about the bots I can find that out too.

Alan Anderson
30-04-2012, 13:25
What will you be using to detect the color you need to follow?

What programming language are you using?

What is the robot drivebase like? How many motors, what kind of wheels, what sort of steering, that kind of thing.

reidmc
03-05-2012, 13:28
A camera, Labview, tankdrive (I think thats what your talking about), 4 motors, 4 wheels.

I don't know how I would find out anything much more detailed.

PAR_WIG1350
05-05-2012, 19:41
well, just to point you in the right direction, if the camera picks up the color drive forwards, otherwise, turn.
I don't use LabView, and I'm not good a image processing, so I'll be of little help with that, but I'd be surprised if there wasn't some pre-written library with a function, or whatever LV calls it, that can tell you if a certain color appears in an image.

DonRotolo
05-05-2012, 20:04
Others will fill in the details, here's the "big picture" version:

To follow a line, you look down with 3 sensors (one left, one center, and one right). If the center sensor "sees" the line, you go forward. If the left sensor "sees" the line, you turn left (towards the line). Right sensor, same thing.

OK, now let's say you must follow the RED line and ignore all the others. You make your sensor able to tell the difference, and just do what I wrote above.

Now, instead of 3 sensors, you have a color camera.

The 'follow' part just analyzes the camera image, and if the 'line' is to the left, you turn left (towards the line) until it's centered...then go forward. If it's a RED line, then you just "look" at red.

The color part is actually pretty easy. A color camera gives you four 'channels' of information, red, green, blue and luminance (think 'brightness'). These can be separated and analyzed separately in software.

The 'follow' thing is a tiny bit harder, but basically you identify the "blob" representing the line, and do some math to find the center of the blob. The center will be either left, right or center.... get it?
(By the way, you only have to evaluate the 'blob' along a horizontal line, not the full height of the camera image - that makes it a lot easier, since it is in one dimension and not 2)

I hope this helps you understand the concepts behind what you are trying to do. Of course, you can get really crazy and follow the "thin" line, or the double yellow, or look ahead and anticipate the next turn, or... But let's get the basics down, then you can run wild with the cool-factor stuff.

Don

reidmc
07-05-2012, 13:31
Thanks for the response, I read a few other tutorials and I understand the concept now, I just need to know how to technically program it.

I can find examples of what I need but none of them have notes. could some one break down the major part of a colour reading program and tell me what each part does?

Alan Anderson
07-05-2012, 14:22
Do you have access to the 2012 LabVIEW software package for FRC teams? There's a vision assistant program included. It lets you plug together various functions for detecting and analyzing colors and objects.

What camera are you using? How are the four motors connected to the four wheels, and what sort of wheels are they?

reidmc
08-05-2012, 12:31
Yes I do have access to the 2012 frc package according to my teacher. Ill try to find it.

The cameras are Axis M1031-W with a ring of lights around the lens. On the bot Im working on there is one motor for each wheel (mechanome I belive was the phrase my teacher used) and the wheels are "omni-wheels" (I dont know if thats a technical term or a class nic name)

If thats a problem there is another robot I could use that has a pair of motors for a pair of wheels and has traditional wheels.

EDIT: Found the example, trying to make sense of it.

Alan Anderson
08-05-2012, 14:31
You're in luck. The WPI function libraries for FRC support the Axis camera communication protocol. You'll have to follow the documentation for setting everything up properly before it will work; look here (http://www.usfirst.org/sites/default/files/uploadedFiles/Robotics_Programs/FRC/Game_and_Season__Info/2012_Assets/Getting%20Started%20with%20the%202012%20FRC%20Cont rol%20System_2.pdf) and find the section dealing with the camera. You should be able to use the Vision Assistant to play with image processing and figure out a sequence of steps to find the color you want to follow.

The 2012 Vision Whitepaper posted on the firstforge site (http://firstforge.wpi.edu/sf/docman/do/listDocuments/projects.wpilib/docman.root) might be helpful.

Your drivebase sounds like a mecanum setup, with diagonal rollers on otherwise conventionally-mounted wheels. It's capable of moving in any direction at any time, either while facing in a constant direction or while turning. Again, you're in luck. The FRC libraries support mecanum drive directly. Just supply a number from -1 to 1 to control how quickly it moves forward or reverse, another number from -1 to 1 to control how quickly it moves left or right, and yet another number to control how quickly it spins counterclockwise or clockwise.

reidmc
09-05-2012, 13:52
Thanks for the help, I tnink I can manage from here but Ill post if I hit another roadblock.

DonRotolo
09-05-2012, 20:27
We'd all love to hear how you made out, once you're done.