ROBOTC.net forums
http://robotc.net/forums/

Autonomous programming in competition template
http://robotc.net/forums/viewtopic.php?f=11&t=5334
Page 1 of 1

Author:  matchmaker [ Mon Jan 07, 2013 10:27 pm ]
Post subject:  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;

}



}
}

Author:  RoboDesigners [ Tue Jan 08, 2013 10:30 am ]
Post subject:  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?

Author:  matchmaker [ Tue Jan 08, 2013 9:12 pm ]
Post subject:  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.

Author:  JohnWatson [ Thu Jan 10, 2013 12:22 pm ]
Post subject:  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

Author:  matchmaker [ Fri Jan 11, 2013 6:17 pm ]
Post subject:  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.

Author:  JohnWatson [ Mon Jan 14, 2013 6:29 pm ]
Post subject:  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.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/