View unanswered posts | View active topics It is currently Sat Aug 30, 2014 3:07 am






Reply to topic  [ 5 posts ] 
need help on my autonomous. robot wont stop at desire time. 
Author Message
Rookie

Joined: Wed Dec 21, 2011 4:22 pm
Posts: 26
Post 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];
   }
}


Mon Sep 10, 2012 8:11 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 566
Post 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. :)

_________________
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 Sep 11, 2012 2:59 pm
Profile
Rookie

Joined: Wed Dec 21, 2011 4:22 pm
Posts: 26
Post 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.


Tue Sep 11, 2012 7:35 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 566
Post 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).

_________________
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


Wed Sep 12, 2012 9:16 am
Profile
Rookie

Joined: Wed Dec 21, 2011 4:22 pm
Posts: 26
Post Re: need help on my autonomous. robot wont stop at desire ti
Thank you, this was extremely helpfull.


Wed Sep 12, 2012 9:31 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.