VRC autonomous code not stopping


#1

Hi there. Not sure if this is the correct place to put this, but I’m having some problems with my autonomous code. It doesn’t seem to stop running, and even when I’ve made the code simple by commenting out everything except absolutely necessary, it still just keeps driving. Any ideas what’s wrong with my code?

#pragma config(Motor,  port2,           left,          tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor,  port3,           leftB,         tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor,  port4,           right,         tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor,  port5,           rightB,        tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor,  port6,           coll,          tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*        Description: Competition template for VEX EDR                      */
/*                                                                           */
/*---------------------------------------------------------------------------*/

//#pragma config(Motor,  port6,           lift,          tmotorVex393_MC29, openLoop)
//#pragma config(Motor,  port7,           lift2,         tmotorVex393_MC29, openLoop)

// This code is for the VEX cortex platform
#pragma platform(VEX2)

// Select Download method as "competition"
#pragma competitionControl(Competition)

// Open frequently used debugger windows
#pragma DebuggerWindows("vexCompetitionControl")

//Main competition background code...do not modify!
#include "Vex_Competition_Includes.c"

/*---------------------------------------------------------------------------*/
/*                          Pre-Autonomous Functions                         */
/*                                                                           */
/*  You may want to perform some actions before the competition starts.      */
/*  Do them in the following function.  You must return from this function   */
/*  or the autonomous and usercontrol tasks will not be started.  This       */
/*  function is only called once after the cortex has been powered on and    */
/*  not every time that the robot is disabled.                               */
/*---------------------------------------------------------------------------*/

void pre_auton()
{
  // Set bStopTasksBetweenModes to false if you want to keep user created tasks
  // running between Autonomous and Driver controlled modes. You will need to
  // manage all user created tasks if set to false.
  bStopTasksBetweenModes = true;

	// Set bDisplayCompetitionStatusOnLcd to false if you don't want the LCD
	// used by the competition include file, for example, you might want
	// to display your team name on the LCD in this function.
	// bDisplayCompetitionStatusOnLcd = false;

  // All activities that occur before the competition starts
  // Example: clearing encoders, setting servo positions, ...

  //setPIDforMotor(left, true);
  //setPIDforMotor(right, true);

  //resetMotorEncoder(left);
  //resetMotorEncoder(right);


  slaveMotor(leftB, left);
  slaveMotor(rightB, right);
}

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*                              Autonomous Task                              */
/*                                                                           */
/*  This task is used to control your robot during the autonomous phase of   */
/*  a VEX Competition.                                                       */
/*                                                                           */
/*  You must modify the code to add your own robot specific commands here.   */
/*---------------------------------------------------------------------------*/

task autonomous()
{
  // ..........................................................................
  // Insert user code here.
  // ..........................................................................

  // Remove this function call once you have "real" code.
  //AutonomousCodePlaceholderForTesting();

	motor[left] = 127;
	motor[right] = 127;
	wait(5000);
	motor[left] = 0;
	motor[right] = 0;

}

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*                              User Control Task                            */
/*                                                                           */
/*  This task is used to control your robot during the user control phase of */
/*  a VEX Competition.                                                       */
/*                                                                           */
/*  You must modify the code to add your own robot specific commands here.   */
/*---------------------------------------------------------------------------*/

task usercontrol()
{
  // User control code here, inside the loop

  while (1)
  {
    // This is the main execution loop for the user control program.
    // Each time through the loop your program should update motor + servo
    // values based on feedback from the joysticks.

    // ........................................................................
    // Insert user code here. This is where you use the joystick values to
    // update your motors, etc.
    // ........................................................................

    // Remove this function call once you have "real" code.
    //UserControlCodePlaceholderForTesting();

		motor[left] = vexRT[Ch3];
		//motor[leftB] = vexRT[Ch3];
		motor[right] = vexRT[Ch2];
		//motor[rightB] = vexRT[Ch2];
		//motor[lift] = vexRT[Btn5D] ? 127 : vexRT[Btn5U] ? -127 : 0;
		motor[coll] = vexRT[Btn6D] ? 127 : vexRT[Btn6U] ? -127 : 0;





  }
}

#2

I could be wrong, but I believe you are waiting 5000 seconds. You would probably want to change your wait to wait1ms


#3

Yes. Or just wait(5).


#4

+1. You need the 1msec after the wait.