View unanswered posts | View active topics It is currently Thu Oct 02, 2014 8:33 am






Reply to topic  [ 4 posts ] 
Autonomous HELP - in school testing 
Author Message
Rookie

Joined: Wed Mar 14, 2012 3:11 pm
Posts: 8
Post Autonomous HELP - in school testing
We want to test our Autonomous in our school, not sure how to initiate the program to begin. I'm attaching the code, if someone can take a look at it? We were just testing it to move forward and then back.

#pragma config(Motor, port2, frontright, tmotorVex269, openLoop)
#pragma config(Motor, port3, backright, tmotorVex269, openLoop, reversed)
#pragma config(Motor, port4, frontleft, tmotorVex269, openLoop)
#pragma config(Motor, port5, backleft, tmotorVex269, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#pragma platform(VEX)

//Competition Control and Duration Settings

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

/////////////////////////////////////////////////////////////////////////////////////////
//
// Pre-Autonomous Functions
//
// You may want to perform some actions before the competition starts. Do them in the
// following function.
//
/////////////////////////////////////////////////////////////////////////////////////////

void pre_auton()
{
// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, ...
}

/////////////////////////////////////////////////////////////////////////////////////////
//
// 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()
{while(true)

motor[port2]= 127;
wait1Msec(2000);

motor[port3]= 127;
wait1Msec(2000);

motor[port4]= 127;
wait1Msec(2000);

motor[port5]= 127;
wait1Msec(2000);


///////////////////////////////////////////////////////////////////////////////////

motor[port2]= 0;
wait1Msec(2000);

motor[port3]= 0;
wait1Msec(2000);

motor[port4]= 0;
wait1Msec(2000);

motor[port5]= 0;
wait1Msec(2000);


//////////////////////////////////////////////////////////////////////////////////



motor[port2]= -127;
wait1Msec(2000);

motor[port3]= -127;
wait1Msec(2000);

motor[port4]= -127;
wait1Msec(2000);

motor[port5]= -127;
wait1Msec(2000);
}

/////////////////////////////////////////////////////////////////////////////////////////
//
// 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()

{while(true)

{
// Joystic Control:
motor[port2] = vexRT[Ch2]; //Motor port 2 speed is determined by Ch2 on the VEXnet Transmitter
motor[port3] = vexRT[Ch2]; //Motor port 3 speed is determined by Ch3 on the VEXnet Transmitter
motor[port4] = vexRT[Ch3];
motor[port5] = vexRT[Ch3];


// Button Control:
if(vexRT[Btn5U] == 1) //If button 5U is pressed:
{
motor[port6] = 32; //run motor port 5 at quarter speed (i.e. lift an arm)
}
else if(vexRT[Btn5D] == 1) //If button 5D is pressed:
{
motor[port6] = -32; //run motor port 5 at quarter speed reversed (i.e. lower an arm)
}
else //If neither buttons 5U or 5D are pressed:
{
motor[port6] = 0; //stop motor port 5 (i.e. don't move arm up or down)
}

}


}


Wed Sep 11, 2013 11:30 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Autonomous HELP - in school testing
Are you posting to the right forum? This is for FTC which uses NXT not VEX.


Wed Sep 11, 2013 6:45 pm
Profile
Rookie

Joined: Thu May 02, 2013 10:52 am
Posts: 22
Post Re: Autonomous HELP - in school testing
Code:
////////////////////////////////////////////////////////////////////////////////////////
//
// 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()
{
   while(true)

   motor[port2]= 127;
   wait1Msec(2000);

   // the rest of your code

}


A while loop needs to have {}, and in side of the {} the code you want to run, otherwise it will run only the next line of code. So in your case it will repeat motor[port2]= 127; and nothing else. If you want to have it repeat your whole auton program you would do like this:
Code:
task autonomous()
{
   while(true)
   {
      motor[port2]= 127;
      wait1Msec(2000);

      // the rest of your auton code
   }
}

Just a warning on that, if you run it like that as soon as it reaches the end of your auton program it will repeat your auton code forever (until the auton mode is over).

To switch the robot between modes (RC/Auton) start at page 7:
http://www.robotc.net/support/cortex/RO ... _Guide.pdf
You can also do it with a USB A-A from your computer to the cortex.

If you aren't doing this for competition look at this, you won't use the competition template:
http://www.education.rec.ri.cmu.edu/pro ... sample.pdf

Quote:
Are you posting to the right forum? This is for FTC which uses NXT not VEX.

As MHTS said, this section of the forum is for FTC (uses the NXT and tetrix platform), but the RobotC competition template you are using is for vex (cotex and PIC).

_________________
What is easy you have done, what is hard you can do, what is impossible will take a little longer


Wed Sep 11, 2013 9:28 pm
Profile
Rookie

Joined: Wed Mar 14, 2012 3:11 pm
Posts: 8
Post Re: Autonomous HELP - in school testing
Sorry about posting in the wrong area. Thanks for your messages. We are still learning.


Thu Sep 12, 2013 9:14 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.