This is my first year as head programmer for my school's team, I shadowed under someone last year but we didn't have to use autonomous in our game, this year we do. I've tried using the template but I keep getting an error message saying "Executable statements not valid in 'main' declaration block" for my user controlled portion. Can anyone help explain what i'm doing wrong? Here's my code.

int pushstate = 0;bool latch = false;///////////////////////////////////////////////////////////////////////////////////////////// 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.

There are a couple of major problems with the code that I'm seeing, but don't get discouraged; they are fairly simple mistakes, you have the right idea, and you are headed on the right track. Check out the comments I've made in the autonomous code (below):

if(SensorValue[RightLight] <= 100) //If the right light sensor is less than/equal to 100, do this { motor[Pushers] = 127; wait10Msec(100); } if(SensorValue[LeftLight] <= 100) //If the left light sensor is less than/equal to 100, do this; what happens if both are less than 100? { motor[Pushers] = -127; wait10Msec(100); } else //if the left light sensor is not less than or equal to 100, do this instead { motor[BackLeft] = 127; motor[BackRight] = 127; motor[FrontLeft] = 127; motor[FrontRight] = 127; wait10Msec(100); motor[BackLeft] = -127; motor[BackRight] = 127; motor[FrontLeft] = -127; motor[FrontRight] = 127; wait10Msec(150); } }

else //If the Sonar value is not less than or equal to 3, do this { motor[BackLeft] = -127; motor[BackRight] = -127; motor[FrontLeft] = -127; motor[FrontRight] = -127; }}

And also the user control code (which is where the error is coming from):

Code:

task usercontrol(){// User control code here, inside the loop

}

Remember, each task starts and stops with a matching set of braces. In this case, the usercontrol task has no code to execute because of the misplaced end brace }. Then, ROBOTC sees all of the other code outside of the task and tells you that 'Executable statements (meaning, user code) not valid in 'main' declaration block (outside of tasks, functions, etc)'. If you move the closing brace to the very end and 'encompass' all the rest of your user control code, ROBOTC will compile it without error. You may not get the results you'd like from the program, but the syntax should be correct.

I would suggest taking a look through our Video Trainer Curriculum for VEX (http://www.education.rec.ri.cmu.edu/pro ... index.html) as it can walk you through, step by step, all of the programming procedures I've described here. Not only will it reinforce what you already know, but you may also be able to pick up some neat tricks to make your robot run smoother.

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