Monday, January 9, 2012

J2IT Autonomous Code

J2IT Autonomous Code

The following program is one of four for each position, in this case this is the blue team, exterior side.











task main()
{
  initializeRobot();
  waitForStart(); // Wait for the beginning of autonomous phase.
  ///////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////
  ////                                                   ////
  ////    Add your robot specific autonomous code here.  ////
  ////                                                   ////
  ///////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////
  motor[W_Left] = universal_speed - 10;
  motor[W_Right] = universal_speed;
  wait1Msec(3500);
  if (red == true)
  {
    if (exterior == true)
    {
      left_turn(1000);
    }
    else
    {
      left_turn(1500);
    }
  }
  else
  {
    if (exterior == true)
    {
      right_turn(1000);
    }
    else
    {
      right_turn(1500);
    }
  }
  straight(2000);
  if (exterior == true)
  {
    if (red == true)
    {
      //Turn Left
      left_turn(850);
    }
    else
    {
      //Turn Right
      right_turn(850);
    }
  }
  straight(6500);
  motor[W_Right] = 0;
  motor[W_Left] = 0;
}

No comments:

Post a Comment