My team is prepping for a Toss-Up Competition tomorrow, and have run into a problem with their program.They have finally built their autonomous code, but are having problems. They have programmed into the competition template, but only the task (usercontrol) commands are working.

We have been searching forums and sample code, and have come across using either a completion switch (which we don’t have), or the debugger window.

Trying the debugger window has not worked so far

Any ideas?

Fri Jan 31, 2014 6:14 pm

JohnWatson

Site Admin

Joined: Thu May 24, 2012 12:15 pmPosts: 722

Re: Competition code problem

Please post your code (including the #pragmas) using the [code] tags and we will be more than happy to take a look at it for you. Also, please do not double post; this only creates confusion and splits the discussion between two identical threads.

///////////////////////////////////////////////////////////////////////////////////////////// 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;

///////////////////////////////////////////////////////////////////////////////////////////// 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.///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////// 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.

//Right side of the robot is controlled by the right joystick, Y-axis motor[rightMotor] = vexRT[Ch2];

//Left side of the robot is controlled by the left joystick, Y-axis motor[leftMotor] = vexRT[Ch3];

Double check the settings under the 'Robot -> VEX Cortex Communication Mode', and make sure it is set to 'Competition (VEXNet)' and not 'VEXNet or USB' or 'USB Only'. This will force the Cortex to check for the competition switch settings. Once this setting is changed, redownload the program to the Cortex and power cycle it (turn the Cortex off, remove the USB cable (if applicable; the USB cable will power the Cortex otherwise), and turn the Cortex back on) to save this setting. Try this first as it is the most common error, and let us know if this solves the issue.

There are a couple of other things I can suggest checking on the code as well:

Code:

//bleebleebloop

I would recommend removing this comment from the #pragma area as this may cause issue later on. You can safely consider anything above the //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// line to be almost hands-off for best performance.

Code:

task autonomous()

{

There's a lot of empty space between the task autonomous() line and the opening brace; I would also recommend removing this extra space to make sure it doesn't interfere with the code in any way (it shouldn't, but it never hurts to be safe).

Code:

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.

//Right side of the robot is controlled by the right joystick, Y-axis motor[rightMotor] = vexRT[Ch2];

//Left side of the robot is controlled by the left joystick, Y-axis motor[leftMotor] = vexRT[Ch3];

}

Be careful with the opening and closing parenthesis. It looks like you only have the left and right control in the infinite loop, and not the arm control; you will need to make sure all of your code is encapsulated inside of the while loop's opening and closing brace structure in order to have the joystick control both the drive and the arm of the robot.

///////////////////////////////////////////////////////////////////////////////////////////// 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;

///////////////////////////////////////////////////////////////////////////////////////////// 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.///////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////// 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. // .....................................................................................{

} UserControlCodePlaceholderForTesting(); // Remove this function call once you have "real" code. }}

Fri Oct 17, 2014 12:32 pm

CARBOT

Expert

Joined: Thu Dec 01, 2011 12:07 amPosts: 151

Re: Competition code problem

I assume you are not connected to a competition field. You don't say if it runs pre-auton or user control.

Without a competition field and it's connections you may need to set competitionControl to OFF to give control to your program.

#pragma competitionControl(competition_mode) - Controls the competition mode thatthe VEX is in. There are two different competition modes that you can pass:OFF - No competition control.Competition - The VEX will respond to field control commands and switch betweenAutonomous and User Control modes at the competition-specified times. Use this mode forcompetitions.

Fri Oct 17, 2014 9:51 pm

blackbee045

Rookie

Joined: Sat Oct 18, 2014 2:22 amPosts: 1

Re: Competition code problem

It looks like you only have the left and right control in the infinite loop, and not the arm control; you will need to make sure all of your code is encapsulated inside of the while loop's opening and closing brace structure in order to have the joystick control both the drive and the arm of the robot.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum