View unanswered posts | View active topics It is currently Sun Nov 23, 2014 10:51 pm






Reply to topic  [ 3 posts ] 
ROBOTC Sensing Obstacle Course 
Author Message
Rookie

Joined: Fri Oct 19, 2012 2:12 pm
Posts: 3
Post ROBOTC Sensing Obstacle Course
I seem to have a problem when I am trying to do the line tracking. When ever the robot gets to the line, some how it turns right instead of beginning on the line. :?: :breakcomputer:


Attachments:
sensing_lauren.c [3.6 KiB]
Downloaded 467 times
Fri Nov 02, 2012 1:26 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 609
Post Re: ROBOTC Sensing Obstacle Course
There were a couple of problems with the program that I saw.

The first problem (and the biggest) was that you had assigned the Light sensor to port two. The problem with this is that the second port in the Virtual Worlds curriculum is reserved for the Compass sensor. Running the program as-is, you can see that the value of the sensor flips between 0 and 360 (which is a good indication of the problem). To resolve this, go into the Motors and Sensors Setup window and select the 'Virtual Worlds NXT' bot from the Standard Models tab. This will automatically configure the robot for the Virtual Worlds environment.

The second, smaller issue is that the line tracking is using a zero value for the 'pivot' wheel. While this will work, you may notice that the robot moves through the line tracking segment very slowly. This is because the robot will literally pivot from side to side to follow the line; it will appear to be 'shuddering' down the line. To solve this, you can simply increase the zero value to a value that moves the motor but is still less than the other motor (for example, instead of using 80 and 0 for motor values, try using 80 and 30). You can increase this number as for a faster line tracking program, but be forewarned; by increasing the speed too much, you run the risk of losing the line on a curve (the sharper the curve, the more likely it is to lose the line).

Two ways to avoid this is to either decrease the motor speeds or increase the gap between the motor speeds. For this application though, 80 and 30 appeared to work quite well.

Code:
#pragma config(StandardModel, "Virtual Worlds NXT")

task main()
{
   while(SensorValue(touch) == 0)   //a while loop is declared with the touchsensor's value being 0 as it true condition
   {
      motor[motorC] =100;
      motor[motorB] =100;

   }
   motor[motorC] =-75;
   motor[motorB] =-75;
   wait1Msec(2000);

   motor[motorC] = 100;
   motor[motorB] = 100;
   wait1Msec(1500);

   motor[motorC] = 0;
   motor[motorB] = 100;
   wait1Msec(650);

   motor[motorC] = 100;
   motor[motorB] = 100;
   wait1Msec(1800);

   while(true)
   {
      while(SensorValue(light) < 45)
      {
         motor[motorB] = 80;
         motor[motorC] = 30;
      }
      while(SensorValue(light) > 45)
      {
         motor[motorB] = 30;
         motor[motorC] = 80;
      }
   }
}


As a side note; you may have noticed the robot sliding a bit between maneuvers. This is because the robot's motors and wheels are going from full speed (or near to full speed) in one direction to full speed in another direction. To alleviate this, a short stop command between motions will stop the motor and decrease the amount of 'slide'.

Code:
motor[motorB] = 0;
motor[motorC] = 0;

wait1MSec(250);

_________________
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


Mon Nov 05, 2012 12:25 pm
Profile
Rookie

Joined: Tue Sep 10, 2013 1:51 am
Posts: 2
Post Re: ROBOTC Sensing Obstacle Course
All of the sensors are going to give you a variable number...what you decide to do with that number is where the programming comes in.i have know little bit about like that course

_________________
http://www.plagiarism-checker.info/
http://en.wikipedia.org/wiki/Plagiarism
http://definitions.uslegal.com/p/plagiarism/


Tue Sep 10, 2013 2:00 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.