View unanswered posts | View active topics It is currently Fri Nov 28, 2014 10:24 pm






Reply to topic  [ 6 posts ] 
Autonomous programming in competition template 
Author Message
Rookie

Joined: Wed Jan 02, 2013 3:50 pm
Posts: 5
Post Autonomous programming in competition template
I'm having some trouble with the autonomous portion of my program. For some reason ports 1 and 10 do no movement at all. Am I missing something?

//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#pragma platform(VEX)

//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(15)
#pragma userControlDuration(120)

#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()
{
// Set bStopTasksBetweenModes to false if you want to keep user created tasks running between
// Autonomous and Tele-Op modes. You will need to manage all user created tasks if set to false.
bStopTasksBetweenModes = true;

// 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()
{
// .....................................................................................
// Insert user code here.
// .....................................................................................

motor[port1] = -127;
motor[port10] = 127;
wait1Msec(700);
motor[port1] = 0;
motor[port10] = 0;
wait1Msec(500);
}

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

bMotorFlippedMode[port6] = true;
bMotorFlippedMode[port8] = true;



motor[port2] = vexRT[Ch3]; // Remove this function call once you have "real" code.
motor[port4] = vexRT[Ch3];
motor[port6] = vexRT[Ch2];
motor[port8] = vexRT[Ch2];

if(vexRT[Btn6U] == 1)
{
motor[port3] = -127;
motor[port5] = -127;
motor[port7] = 127;
motor[port9] = 127;

}
else if(vexRT[Btn6D] == 1)
{
motor[port3] = 127;
motor[port5] = 127;
motor[port7] = -127;
motor[port9] = -127;
}
else
{
motor[port3] = 0;
motor[port5] = 0;
motor[port7] = 0;
motor[port9] = 0;
}

if(vexRT[Btn5U] == 1)
{
motor[port1] = -127;
motor[port10] = 127;


}
else if(vexRT[Btn5D] == 1)
{
motor[port1] = 127;
motor[port10] = -127;

}
else
{
motor[port1] = 0;
motor[port10] = 0;

}



}
}


Mon Jan 07, 2013 10:27 pm
Profile
Novice
User avatar

Joined: Sat Jul 10, 2010 3:06 pm
Posts: 86
Location: Roanoke, VA
Post Re: Autonomous programming in competition template
How are you running the autonomous portion of your program? Are you using a competition switch, or are you expecting the code to run as soon as you turn the robot on?

_________________
Check out my website! www.RoboDesigners.com

VRC Team 2190

Twitter: @RoboDesigners


Tue Jan 08, 2013 10:30 am
Profile WWW
Rookie

Joined: Wed Jan 02, 2013 3:50 pm
Posts: 5
Post Re: Autonomous programming in competition template
I am expecting the robot to run through autonomous mode by just powering on the cortex. I am not using the competition control thing.


Tue Jan 08, 2013 9:12 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 610
Post Re: Autonomous programming in competition template
If you are using the competition template you will need to send the Cortex a command to start each section of code (autonomous and user control sections, respectively). To do this, you will need to use either a physical competition switch or ROBOTC's built in Competition Switch Debugger window. More information on using the Competition Switche(s) can be found on our wiki: http://www.robotc.net/wiki/VEX2_Competi ... -_Debugger

_________________
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


Thu Jan 10, 2013 12:22 pm
Profile
Rookie

Joined: Wed Jan 02, 2013 3:50 pm
Posts: 5
Post Re: Autonomous programming in competition template
I went to use the debugger switch and it was gray. When I clicked on it nothing happened. I had everything hooked up properly.


Fri Jan 11, 2013 6:17 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 610
Post Re: Autonomous programming in competition template
Double check that your Compiler Target is set to Physical Robot, the Cortex Communication Mode is set to Competition (VEXNet), and that the program is loaded onto the robot and ready to be started (the Debug window should pop up with the Start/Step commands, all done through the Robot menu). You won't be able to select any of the other debug windows, such as the Competition Control Debug, until the program is downloaded and the Debug window is opened; the window will appear automatically when the program is downloaded but can also be started manually by selecting the 'Open Debugger Manually' option in the Robot menu.

Also, make sure that the Cortex is communicating to the VEXNet controller properly (check out our VEXNewt setup guide if needed) before trying to download a program to the Cortex.

_________________
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


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