View unanswered posts | View active topics It is currently Thu Jul 31, 2014 2:13 pm






Reply to topic  [ 8 posts ] 
Light Sensor dector, + line following. 
Author Message
Rookie

Joined: Mon Apr 02, 2012 12:18 pm
Posts: 4
Post Light Sensor dector, + line following.
Okay so I'm in a rut here, I have to do a project for an entry level engineering class and
my final in the class is to program an NXT robot to follow a line and based on the color of the line
it will display what color the line is, in my head the program sounds easy but when I think about
actually trying to write the code I just cannot figure it out. I know this is kind of a huge request
but can someone either get me going in the right direction I.E. Write the code for one color, lets say blue.
and then I could finish the rest or just give me huge hints, I'm really stuck and this is stressing me out.
I cannot use a color sensor, I have to use a light sensor for this project as my class does not have access
to color sensors and I have the values of the colors I'm supposed to use.
* Blue = 21
* Red = 57
* Green = 47
* Yellow = 60
* Orange = 53
Sorry if this post sounded whiny or rude, I'm just really frustrated and would appreciate some help. Thanks
in advance for any help or advice.


Mon Apr 02, 2012 12:34 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Light Sensor dector, + line following.
Squidgy wrote:
Okay so I'm in a rut here, I have to do a project for an entry level engineering class and
my final in the class is to program an NXT robot to follow a line and based on the color of the line
it will display what color the line is, in my head the program sounds easy but when I think about
actually trying to write the code I just cannot figure it out. I know this is kind of a huge request
but can someone either get me going in the right direction I.E. Write the code for one color, lets say blue.
and then I could finish the rest or just give me huge hints, I'm really stuck and this is stressing me out.
I cannot use a color sensor, I have to use a light sensor for this project as my class does not have access
to color sensors and I have the values of the colors I'm supposed to use.
* Blue = 21
* Red = 57
* Green = 47
* Yellow = 60
* Orange = 53
Sorry if this post sounded whiny or rude, I'm just really frustrated and would appreciate some help. Thanks
in advance for any help or advice.


What color is the backround? Unless it's really bright or really dark, I'm not sure that this would work. Could you post a pic of the track, or a drawing, or similar? Some of the values you list are very close(some identical)to the average values for black and white surfaces.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Mon Apr 02, 2012 1:25 pm
Profile WWW
Rookie

Joined: Mon Apr 02, 2012 12:18 pm
Posts: 4
Post Re: Light Sensor dector, + line following.
The background is white and the track is just like a decently big sized piece of paper different parts of the oval being
the different colors, I.E.blue, orange, yellow, etc.


Mon Apr 02, 2012 4:32 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Light Sensor dector, + line following.
Squidgy wrote:
The background is white and the track is just like a decently big sized piece of paper different parts of the oval being
the different colors, I.E.blue, orange, yellow, etc.


That sounds simple enough. Have you tested to make sure that there is at least a 5 percent difference between the backround and the line at all times? If there isn't enough contrast between the line and the backround, the robot might not see the line and then you could get some peculiar behavior. If the robot can't distinguish the line from the backround at some point, it would require a significantly different algorithm the if it could see at all times. Also, how many sensors is it using to "see" the line?

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Mon Apr 02, 2012 4:49 pm
Profile WWW
Rookie

Joined: Mon Apr 02, 2012 12:18 pm
Posts: 4
Post Re: Light Sensor dector, + line following.
All we are allowed to use is one NXT Light Sensor. :/
We first tried programming it in the LEGO MindStorms program but found it
to be very confusing for this task. and yes there is a 5% difference so
no worries about that.


Mon Apr 02, 2012 5:01 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Light Sensor dector, + line following.
I apoligize for the delay in response, I was really busy this past week. I've got an idea, but have you made any progress yet?

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Wed Apr 11, 2012 12:54 pm
Profile WWW
Rookie

Joined: Mon Apr 02, 2012 12:18 pm
Posts: 4
Post Re: Light Sensor dector, + line following.
I have made no progress due to people in my family becoming hospitalized,
but anyways; what's your idea? :)


Wed Apr 11, 2012 9:37 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Light Sensor dector, + line following.
My idea is this: I think that you would want to use a simple line-following algorithm, yes? If so, then you would be turning one direction when on the line, and the other when off. So you would want to do something like this: BTW, this is written in suedo-code. If you put this in the editor, it will not actually work.
Code:
while(true)//loop forever
{
   if(sensor doesn't see the line)
   {
      do whatever to get back on the line
   }
   else
   {
      do whatever to turn away from the line

      Now here's the bit your having trouble with.
      It's actually pretty simple, if you know what to do.
      if(SensorValue(LightSens) >= lowercolorval && SensorValue(LightSens) <= uppercolorval)
      {
          Display name of color;
      }
      repeat for each color there is.
   }
}


So, basically, it's a simple bang-bang line follower, that checks the reflection when it's on the line and compares it with known values to determine the color of the line, and then display it. Have I explained it well enough?

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Thu Apr 12, 2012 6:59 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.