<< return to Pixycam.com

Lane Following

Good morning! (At least where I am currently)

So I have been reading through the forums and previous versions of the CMUCams but maybe I am not sure where to start with the Pixy for lane following.

One of my professors asked that I do a lane following robot for our final project which is due in 2 weeks (I promise I haven’t procrastinated, I received the task description last week and the Pixy on Friday) and suggested I look into the Pixy which looks really good and promising so I picked one up. But it doesn’t look like there are many examples on how to use the camera and do even simple line following like there are for previous versions.

Has anyone tackled line or lane following with the Pixy and may have some suggestions on where to start? From the examples I understand how to obtain the pixels but how do I specify which signature/color I am looking for and how do I restrict the window I am processing so the robot sees only a few inches to maybe a foot in front of it to assist it with navigating the curves?

I am assuming, please please correct me if this is the wrong way to think about it, that from getting the centroid of the detected right lane line and the centroid of the left lane line I can then calculate whether I am roughly equal distance and then just turn my wheels as needed to move myself back to the middle of the lane. Even if this assumption is correct, I still don’t understand how to specify the green I am looking for, look for 2 lines, and restrict the viewing window.

I am using an Arduino Mega and have played a bit with PixyMon (I like the purple triceratops icon, makes for a fun explanation when people ask what it is).

I would greatly appreciate any hints, tips, tricks, examples, links, anything you can give me to help me get on the right track to complete this project.

Thank you!

Kelly

Hi Kelly,

Have you had a chance to look through the “wiki”:http://cmucam.org/projects/cmucam5/wiki? There are quite a few pages describing how to use Pixy and how to interface it with other microcontrollers, like Arduino.

To get started teaching Pixy the color of your lanes, look “here”:http://cmucam.org/projects/cmucam5/wiki/Teach_Pixy_an_object. Once you’ve taught Pixy an object (such as your green lanes), it will send block data to you over the chosen communication method (SPI, I2C, UART, etc). This block data contains the location and size of detected objects, which in your case would be the lanes. You could then use this data to determine where the lanes are and if you should turn or not.

Is this what you were looking for? Please let me know if you have any more questions.

Scott

Thank you for the response.

I did go through the wiki first and have already hooked the Pixy up to my Arduino and taught it that signature 1 is the green of my lanes.

What i was trying to ask and failing was this: If I want to look for a single signature, and don’t care about any other object, do I still have to call pixy.blocks[i].signature for every block I am looking at and determine whether it belongs to signature 1? Also, knowing I can call pixy.blocks[i].x and pixy.blocks[i].y, I want to limit the x and y range I look at so I only see blocks from a small range within the frame, but do I need to look at every block.x and block.y and determine if they fall within the range before I use the data or can I specify the frame size I want in another way so I do not have to go through all of that processing?

Thanks,

Kelly

Hi Kelly,

In the current form of the Arduino library, you will have to check both the signature and the location of the x/y coordinates. Currently there are no filtering options in the library. This should only take a few if-statements to do what you want.

Please let me know if you have any other questions.

Scott