View unanswered posts | View active topics It is currently Wed Nov 26, 2014 9:46 pm






Reply to topic  [ 5 posts ] 
line follower without sensor 
Author Message
Rookie

Joined: Tue Dec 31, 2013 1:24 am
Posts: 2
Post line follower without sensor
I want to make a line follower code. Initially the robot path using a light sensor, and will stop if any obstacle without crashing into obstacles with the help of sonar sensors. after that the "wait for push button" robots to run again but all the sensors turned off, and the robot goes according to the previous track. how? please help

this my line follower code using light sensor

Code:
task main()
{

wait1Msec(100);

int dark = SensorValue[lightSensor];
nxtDisplayCenteredTextLine(4, "%d", dark);
wait1Msec(1000);
motor[motorB] = 35;
motor[motorC] = -35;

wait1Msec(300);
motor[motorB] = 0;
motor[motorC] = 0;

int light = SensorValue[lightSensor];
nxtDisplayCenteredTextLine(4, "%d",light);
wait1Msec(1000);

int tepi = (dark + light)/2;
motor[motorB] = -35;
motor[motorC] = 35;
wait1Msec(200);
nxtDisplayCenteredTextLine(4, "%d", tepi);
motor[motorB] = 0;
motor[motorC] = 0;
wait1Msec(1000);

int distance_in_cm = 30;   // Create variable 'distance_in_cm' and initialize it to 30(cm).

while(SensorValue[sonarSensor] > distance_in_cm)   // While the Sonar Sensor readings are less than the specified, 'distance_in_cm':
{
if(SensorValue[lightSensor] < tepi){
motor[motorB] = 60;
motor[motorC] = 0;

}
else
{
motor[motorB] = 0;
motor[motorC] = 60;

}
  }

   motor[motorB] = 0;
   motor[motorC] = 0;
}


Tue Dec 31, 2013 1:35 am
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 610
Post Re: line follower without sensor
A quick glance through the code you've posted looks like it should work (assuming the light/dark readings are accurate and the threshold value is calculated correctly) to line-track the robot within 30 cm of an object detected by the sonar sensor.

To move the robot back to the start (following the same path) without using sensors, however, will increase the complexity of this program by quite a large amount. Basically, you will need to 'record' the encoder values of the wheels after each movement, store it in an array of variables, then 'replay' the movement in reverse once you're done. The problem is that the length of the track can easily fill up the maximum array values quickly and cause you to run into an overflow issue.

Is there any way that you could possibly turn the robot around and line track backwards (without using the sonar sensor, but rather the encoder values)? This would greatly simplify the program for you, if possible. If not, how long of a track are you looking at?

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Tue Dec 31, 2013 3:20 pm
Profile
Rookie

Joined: Tue Dec 31, 2013 1:24 am
Posts: 2
Post Re: line follower without sensor
yea.. but robots can't go back backwards , the track length is not limited to the cessation of the robot if there is a barrier .


Wed Jan 01, 2014 10:58 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3293
Location: Rotterdam, The Netherlands
Post Re: line follower without sensor
Why did you post this again in the third party sensors sub forum and again in this sub forum? Don't do this, it won't get you an answer quicker, it will only annoy the moderators.

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Wed Jan 01, 2014 11:12 am
Profile WWW
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 610
Post Re: line follower without sensor
Ah I see the problem now, I apologize for the confusion. Just to clarify, the robot will use a light sensor to track a line forward until the sonar sensor detects an object. When it does, the robot will stop, be physically moved back to the starting point, and (when a touch sensor is pressed by the user) move forward for the same distance as the original run (but this time without using the sonar or light sensors), correct?

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Fri Jan 03, 2014 10:15 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.