View unanswered posts | View active topics It is currently Fri Dec 19, 2014 9:36 pm






Reply to topic  [ 3 posts ] 
Autonumus 
Author Message
Rookie

Joined: Sun Jan 27, 2013 7:21 pm
Posts: 4
Post Autonumus
I'm working on this program for our robot but when we run the teleOP it also runs the autonumus part, can someon say what's wrong about it?
Code:
#pragma config(Hubs,  S1, MatrxRbtcs, none,     none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Motor,  mtr_Matrix_S1_1, LinksAchter,     tmotorMatrix, openLoop)
#pragma config(Motor,  mtr_Matrix_S1_2, RechtsAchter,    tmotorMatrix, openLoop)
#pragma config(Motor,  mtr_Matrix_S1_3, LinksVoor,       tmotorMatrix, openLoop)
#pragma config(Motor,  mtr_Matrix_S1_4, RechtsVoor,      tmotorMatrix, openLoop)
#pragma config(Servo,  srvo_Matrix_S1_1, ArmSchaar1,            tServoStandard)
#pragma config(Servo,  srvo_Matrix_S1_2, ArmSchaar2,            tServoStandard)
#pragma config(Servo,  srvo_Matrix_S1_3, servo3,               tServoNone)
#pragma config(Servo,  srvo_Matrix_S1_4, servo4,               tServoNone)

#include "JoystickDriver.c"                                                //Include the Joystick/Game variables driver

task TTankDrive
{
   int threshold = 6;                                      //Makes it so it dooesn't make unnessesary movs
   while(true)
   {
      getJoystickSettings(joystick);                                  //Updates the game and joystick variables
      if(abs(joystick.joy1_y2) > threshold)
      {
         motor[RechtsVoor] = (-joystick.joy1_y2/2);
      motor[RechtsAchter] = (-joystick.joy1_y2/2);
    }
      else
    {
      motor[RechtsVoor] = 0;
      motor[RechtsAchter] = 0;
    }
    if(abs(joystick.joy1_y1) > threshold)
    {
      motor[LinksVoor] = (joystick.joy1_y1/2);
      motor[LinksAchter] = (joystick.joy1_y1/2);
    }
    else
    {
      motor[LinksVoor] = 0;
      motor[LinksAchter] = 0;
    }
  }
  return;
}

task TSideDrive
{
   int threshold = 6;
   while(true)
   {
      getJoystickSettings(joystick);                                  //Updates the game and joystick variables
      if(abs(joystick.joy1_x2) > threshold)
      {
         motor[RechtsVoor] = (-joystick.joy1_x2/2);
      motor[RechtsAchter] = (-joystick.joy1_x2/2);
    }
      else
    {
      motor[RechtsVoor] = 0;
      motor[RechtsAchter] = 0;
    }
    if(abs(joystick.joy1_x1) > threshold)
    {
      motor[LinksVoor] = (joystick.joy1_x1/2);
      motor[LinksAchter] = (joystick.joy1_x1/2);
    }
    else
    {
      motor[LinksVoor] = 0;
      motor[LinksAchter] = 0;
    }
  }
  return;
}

task TButton
{
   while(1 == 1)
      {
            getJoystickSettings(joystick);
            servoChangeRate[ArmSchaar1] = 3;
            servoChangeRate[ArmSchaar2] = 3;
          if(joy1Btn(08) == 1)
             {
              servo[ArmSchaar1] = 255;
              servo[ArmSchaar2] = 0;
             }
            if (joy1Btn(07) == 1)
               {
                servo[ArmSchaar1] = 0;
                servo[ArmSchaar2] = 255;
          }
        if (joy1Btn(05) == 0)                         //If the LB-button isn't pressed you can drive in Normal mode
               {
                StartTask(TTankDrive);
                StopTask(TSideDrive);
          }
        if (joy1Btn(05) == 1)
               {
                StartTask(TSideDrive);
                StopTask(TTankDrive);
          }
   }
   return;
}

void initializeRobot()
{
   servo[ArmSchaar1] = 0;
   servo[ArmSchaar2] = 0;
   return;
}

task main()
{
  initializeRobot();
  waitForStart();
  motor[LinksVoor] = 20;    motor[RechtsVoor] = -20;
  motor[LinksAchter] = 20;  motor[RechtsAchter] = -20;
  wait1Msec(2000);
  motor[LinksVoor] = 20;    motor[RechtsVoor] = 20;
  motor[LinksAchter] = 20;  motor[RechtsAchter] = 20;
  wait1Msec(4000);
  motor[LinksVoor] = 20;    motor[RechtsVoor] = -20;
  motor[LinksAchter] = 20;  motor[RechtsAchter] = -20;
  wait1Msec(2000);
  motor[LinksVoor] = 0;       motor[RechtsVoor] = 0;
  motor[LinksAchter] = 0;   motor[RechtsAchter] = 0;
   StartTask(TButton);
   while(true)
   {
   }
return;
}


Tue Jan 29, 2013 4:01 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1366
Post Re: Autonumus
For FTC competition, you need to compile two separate programs, one contains only autonomous code and the other contains only teleop code.
The way the Field Control System works is that at the beginning of the completion, you will start your autonomous program. After the autonomous period is over, the Field Control System will instruct your brick to terminate the autonomous program, load the "TeleOp" program and run it. That's why you need to "pick your teleop program" by running the program chooser who will create an FTCConfig.txt file on the brick containing the name of your teleop program. If you have a single program that contains both autonomous and teleop code and you pick your single program as the teleop program, then your program will be terminated after the Autonomous period is over and re-launched as the teleop program which means it will re-run the autonomous code again.
It is possible to write a single program that contains both autonomous and teleop code but the logic would be a lot more complex that what you have. The easiest thing for you to do is to split your code into two programs.


Tue Jan 29, 2013 5:16 pm
Profile
Rookie

Joined: Sun Jan 27, 2013 7:21 pm
Posts: 4
Post Re: Autonumus
Thanks a lot, again


Tue Jan 29, 2013 6:22 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.