ROBOTC.net forums
http://www.robotc.net/forums/

ROBOTC Sensing Obstacle Course
http://www.robotc.net/forums/viewtopic.php?f=55&t=5059
Page 1 of 1

Author:  laurencalzada [ Fri Nov 02, 2012 1:26 pm ]
Post subject:  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 797 times

Author:  JohnWatson [ Mon Nov 05, 2012 12:25 pm ]
Post subject:  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);

Author:  kingston king [ Tue Sep 10, 2013 2:00 am ]
Post subject:  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

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/