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

need help on my autonomous. robot wont stop at desire time.
http://robotc.net/forums/viewtopic.php?f=11&t=4819
Page 1 of 1

Author:  themigthy [ Mon Sep 10, 2012 8:11 pm ]
Post subject:  need help on my autonomous. robot wont stop at desire time.

Code:
void pre_auton()
{
  motor[RightFront] = true;
  motor[RightBack] = true;    //this is just the pre-autonomous it does nothing but set the motors to true
  motor[LeftFront] = true;
  motor[LeftBack] = true;
  bStopTasksBetweenModes = true;
}


Code:
void getTurn(){ //I made a function to get a 90 degree turn using the gyro.
 
  SensorType[gyro] = sensorNone;
  wait1Msec(1000);
 
  SensorType[gyro] = sensorGyro;
  wait1Msec(2000);


  int degrees10 = 900;


  while(abs(SensorValue[gyro]) < degrees10)
  {
  motor[RightFront] = 25;
  motor[RightBack] = 25;
  motor[LeftFront] = -25;
  motor[LeftBack] = -25;
   
  }

  motor[RightFront] = -10;
  motor[RightBack] = -10;
  motor[LeftFront] = 10;
  motor[LeftBack] = 10;
  wait1Msec(250);
  }



Code:
task autonomous()
{
  motor[RightFront] = 50;  // this makes the robot go forward
  motor[RightBack] = 50;  //the problem is that the robot keeps on going for about 2 seconds and then does the 90 degree turn
  motor[LeftFront] = 50;   
  motor[LeftBack] = 50;
   wait1Msec(100); //it doesn't matter how many seconds or milliseconds i apply to it, the robot just keeps on going for about 2 seconds
                          // the turn is great, but the robot passes the line where i would like it to stop
   getTurn(); // I call the function for the 90 degree turn 
}



Code:
task usercontrol()
{
   
   while (true)
   {
   motor[RightFront] = vexRT[Ch2] + vexRT[Ch1];
  motor[RightBack] = vexRT[Ch2] + vexRT[Ch2];
  motor[LeftFront] = vexRT[Ch2] + vexRT[Ch2];
  motor[LeftBack] = vexRT[Ch2] + vexRT[Ch2];
   }
}

Author:  JohnWatson [ Tue Sep 11, 2012 2:59 pm ]
Post subject:  Re: need help on my autonomous. robot wont stop at desire ti

What specifically do you want the robot to do? I'm assuming move forward for two seconds, stop, then make a 90 degree turn, correct?

I see move forward commands, I see 90 degree turn commands, but I don't see the motors being stopped at all. :)

Author:  themigthy [ Tue Sep 11, 2012 7:35 pm ]
Post subject:  Re: need help on my autonomous. robot wont stop at desire ti

No, I'm trying to make the robot move for 1/10 of a second, but the robot keeps on moving for 2 seconds.

Author:  JohnWatson [ Wed Sep 12, 2012 9:16 am ]
Post subject:  Re: need help on my autonomous. robot wont stop at desire ti

My mistake, it was a typo. But the reasoning remains valid; the reason it is going for two seconds is because the motors are never told to stop. One thing to remember is that he wait command means 'keep doing what you were doing for x amount of time, and don't do anything else for the duration', NOT 'keep doing what you were doing for x amount of time, and don't do anything else for the duration, and then stop what you were doing".

Since the gyro calibration takes about 3 seconds to perform (which is the next command set after telling the robot to move forward), the robot will keep doing what it was previously doing for that time until it hits different motor commands (the 90 degree turn).

Author:  themigthy [ Wed Sep 12, 2012 9:31 am ]
Post subject:  Re: need help on my autonomous. robot wont stop at desire ti

Thank you, this was extremely helpfull.

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