Robotc autonomous

This is my 3rd year robotics, and first for Robotc, and i cant seem to make autonomous work for field control. I have a basic program, and it wont work.

task autonomous()
		motor[port7] = 127;//mogo out

		motor[port1] = 127;//
		motor[port3] = 127;//base forward
		motor[port8] = 127;//
		motor[port10] = 127;//

		motor[port7] = -127;//mogo in

please help me

So what does happen? Nothing?

After you download the program, you need to click the TEENY “Start” button in the popup box before the competition switch will work.

Can you provide any more details?

Looking at your code, you have a few items that seem problematic; these are definitely not the things that are causing you problems, but I thought I’d point them out.

The MoGo motor is never turning off; you turn it on to 127, and after 3 seconds (1000 + 2000) you set it to -127, and then it stays on at -127 forever (until the end of the 15 second auton) because you never tell it to stop. You need

motor[port7] = 0;

both when it’s moving at +127 and when it’s at -127. Also, it’s not great to switch your motors quickly from full-forward to full-back. So even if you did want your MoGo motor on the whole time, it’s good practice to set it to 0, have a very small wait command, and then turn it to full-backward.

For the chassis, you’re also never turning it off; it will drive forward at full throttle until the end of the 15 seconds. You need 4 more lines of code wherever it is you want the chassis to stop (I assume it’s right after the wait 2000ms line):

motor[portXX] = 0;

Again, these are not the things that are causing your “doesn’t work” problem, but I thought I’d point them out.


After i fixed my code, it looks like this.

task autonomous()
	driveForward (2000,127);

Does this look right?

Does your program include this stuff from the competition template?:

// This code is for the VEX cortex platform
#pragma platform(VEX2)

// Select Download method as "competition"
#pragma competitionControl(Competition)

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

Also, when you say:

What exactly are you using for the field control? There are a few options, like a real field, or the VexNet competition switch (that black square with the switches that you plug your controller into), or the one of the emulators built into RobotC?

Your new code definitely looks better, and looks like your robot will no longer drive off into the sunset. :slight_smile:

Defining a variable would definetly help you.

Define the motors before the task main so that after the code will look cleaner.

Hope it helps