CS 1020 - Homework 6 - Color sensing

Due: Monday, 1/21

For the next 5 days you will work on two assignments in a new group. The goal is to build a Lego sorter that can sort Lego pieces by color and perhaps also by shape.

Undo...

First (still with your old group), disassemble your 8-ball robot and clean up your Lego kit. Then, move to your new group and get to know your new group members with whom you will face the next set of challenges!

Sensing Color

The object of this assignment (due Monday) is to experiment with ways of sensing color. As you might know, humans sense color via three types of cones in the retina that are sensitive to red, green, and blue light. Similarly, cameras usually contain a Bayer filter - an array of RGB color filters. Another way of sensing the color of an object is to illuminate it with different colored light, and measure how much light is reflected.

How can you sense colors with our Lego sensors? That's for you to figure out. Collect Lego blocks with different colors and experiment what kind of readings you get with both the brightness and the IR sensors. When experimenting make sure you setup a controlled environment both with respect to the location of sensors and the pieces you're examining. When working with the brightness sensors you should make sure you have a consistent illumination.

To help with the illumination (and possibly provide you with additional information) we have available some LEDs that can be plugged into the motor ports and are bi-color (red and green) - use 'thisway' and 'thatway' to get the two different colors. Experiment with these LEDs and see what impact they have on the sensor readings. Again, make sure you setup a nice controlled environement. We do also have some other LEDs that you can experiment if you have other ideas. Come talk to us...

Using 2 or 3 different sensors, how many colors can you reliably distinguish? Write a program that continuously outputs the color of the object. (Be sure that the object whose colors you are sensing are always in the same position, etc.)

"Conveying" color

Once you have the color sensing working, build a little conveyor belt (or other transport mechanism) that moves the pieces past your sensors. Try to detect the piece and sense its color at the same time. The homework for Monday is to build a color counter, i.e. keep track of how many pieces of each color have passed by. Display the current totals on the screen, e.g.:
red:3 yellow:1
blue:5 total:9
In addition, play a different note depending on the color. The program should stop when 10 pieces have been counted. There are a few ways to make this happen, but one is to use concurrency to create a process that does most of the work and increments a counter each time it sees a piece. Then, use a waituntil to check the value of that counter in your main procedure. When it gets to 10, you can call stoprules to kill the process and finish your main procedure.

Your program should be able to distinguish at least 3 different colors.

Note: You that besides the above-mentioned use to get it to count 10 properly, you should probably not use any of the concurrency commands for this assignment. They are likely not necessary here since no two things happen in parallel.

When you're done

Print out your code (names and group number in a comment!) and hand it in Monday at the beginning of class. We will also go around to see your counter in action during Monday's lab.