Testing Help

So I have a program to be tested wondering if someone could test it as I don’t have the robot for a week from now. So the code down below should work like this you need to download it to your robot then click start. The objective of this code is to record 15 sec or user control period for autonomous and you would get the code for autonomous from the debugger window. Thanks in advance if someone is willing to do this.

#pragma config(Sensor, in1,    Pot,            sensorPotentiometer)
#pragma config(Motor,  port1,           Claw,          tmotorVex393_HBridge, openLoop)
#pragma config(Motor,  port2,           fourLeft,      tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor,  port3,           fourRight,     tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port4,           sixLeft,       tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor,  port5,           sixRight,      tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port6,           XDriveA,       tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor,  port7,           XDriveB,       tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port8,           XDriveC,       tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor,  port9,           XDriveD,       tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port10,          Goal,          tmotorVex393_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#pragma DebuggerWindows("debugStream")

// HOW TO USE THIS RECORDER:
// 1. Look for the THREE ---->>> paste X here <<<---- comments and paste the described code from your competition template.
// 2. Have a game field set up and a driver ready to drive the bot for an autonomous run.
// 3. While using the programming cable with the controller connected to the robot via vexNet, download this code.
// 4. With the debug stream window open, press start to run the code. There will be a 3 second count down, then 15 seconds to drive.
// 5. Copy the text from the debug stream window into your autonomous task
// 6. Copy the following variables and functions into your competition template above the pre-autonomous task.
/*-----------------------------------------------------------------------------------------------------------*/

int static const R_FREQ = 50; // 50 the frequency of the recording in milisecons.
int R_Batt; // the battery voltage at the time of the recording.
int P_Freq; // the replay frequency in miliseconds


// function to assess battery voltage and adjust replay frequency
void replayFreq()
{
	P_Freq = R_FREQ * (R_Batt / nImmediateBatteryLevel);	//  ~1mS difference in playback per 160mV difference
	// recording at 8200mV and playback at 7200mV would make P_Freq = 57mS, meaning the last 2.1 secs would be stopped by competition control
	// what is the real relationship of voltage and speed?  would vary greatly by robot weight and geomoetry.  Add a constant for teams to tune?
}

// function to replay recorded vexRT signals
void replayVexRT(int C1, int C2, int C3, int C4, int B5D, int B5U, int B6D, int B6U, int B7D, int B7U, int B7L, int B7R, int B8D, int B8U, int B8L, int B8R,
int xC1, int xC2, int xC3, int xC4, int xB5D, int xB5U, int xB6D, int xB6U, int xB7D, int xB7U, int xB7L, int xB7R, int xB8D, int xB8U, int xB8L, int xB8R)
{

	motor[XDriveA] = vexRT[C3] + vexRT[C1] - vexRT[C4];
	motor[XDriveB] = vexRT[C3] - vexRT[C1] + vexRT[C4];
	motor[XDriveC] = vexRT[C3] + vexRT[C1] + vexRT[C4];
	motor[XDriveD] = vexRT[C3] - vexRT[C1] - vexRT[C4];

	if (vexRT[B6U] == 1)
	{
		motor[fourLeft] = 127;
		motor[fourRight] = 127;
		motor[sixLeft] = 127;
		motor[sixRight] = 127;
	}
	else if (vexRT[B6D] == 1)
	{
		motor[fourLeft] = -127;
		motor[fourRight] = -127;
		motor[sixLeft] = -127;
		motor[sixRight] = -127;
	}
	else
	{
		motor[fourLeft] = 0;
		motor[fourRight] = 0;
		motor[sixLeft] = 0;
		motor[sixRight] = 0;
	}

	// replace all the vexRT] statements with the corresponding variable
	// i.e. change "motor[port1] = vexRT[Ch3];" to "motor[port1] = C3;"
	// if your button code is written as a boolean test for true or false, change true to 1 and false to 0
	wait1Msec(P_Freq);
}
/*-----------------------------------------------------------------------------------------------------------*/






// variables to hold the vexRT signal values from main controller
int C1, C2, C3, C4, B5D, B5U, B6D, B6U, B7D, B7U, B7L, B7R, B8D, B8U, B8L, B8R;

// variables to hold the vexRT signal values from partner controller
int xC1, xC2, xC3, xC4, xB5D, xB5U, xB6D, xB6U, xB7D, xB7U, xB7L, xB7R, xB8D, xB8U, xB8L, xB8R;

// task to record vexRT signals to the debug stream once every R_FREQ ms
task recordVexRT()
{
	while(true)
	{
		// main controller values
		C1 = vexRT[Ch1];
		C2 = vexRT[Ch2];
		C3 = vexRT[Ch3];
		C4 = vexRT[Ch4];
		B5D = vexRT[Btn5D];
		B5U = vexRT[Btn5U];
		B6D = vexRT[Btn6D];
		B6U = vexRT[Btn6U];
		B7D = vexRT[Btn7D];
		B7U = vexRT[Btn7U];
		B7L = vexRT[Btn7L];
		B7R = vexRT[Btn7R];
		B8D = vexRT[Btn8D];
		B8U = vexRT[Btn8U];
		B8L = vexRT[Btn8L];
		B8R = vexRT[Btn8R];

		// partner controller values
		xC1 = vexRT[Ch1Xmtr2];
		xC2 = vexRT[Ch2Xmtr2];
		xC3 = vexRT[Ch3Xmtr2];
		xC4 = vexRT[Ch4Xmtr2];
		xB5D = vexRT[Btn5DXmtr2];
		xB5U = vexRT[Btn5UXmtr2];
		xB6D = vexRT[Btn6DXmtr2];
		xB6U = vexRT[Btn6UXmtr2];
		xB7D = vexRT[Btn7DXmtr2];
		xB7U = vexRT[Btn7UXmtr2];
		xB7L = vexRT[Btn7LXmtr2];
		xB7R = vexRT[Btn7RXmtr2];
		xB8D = vexRT[Btn8DXmtr2];
		xB8U = vexRT[Btn8UXmtr2];
		xB8L = vexRT[Btn8LXmtr2];
		xB8R = vexRT[Btn8RXmtr2];

		// write the values to the debug stream window
		writeDebugStreamLine("replayVexRT(", C1, ",%d", C2, ",%d", C3, ",%d", C4, ",%d", B5D, ",%d", B5U, ",%d", B6D, ",%d", B6U, ",%d",
		B7D, ",%d", B7U, ",%d", B7L, ",%d", B7R, ",%d", B8D, ",%d", B8U, ",%d", B8L, ",%d", B8R);
		writeDebugStream(",%d", xC1, ",%d", xC2, ",%d", xC3, ",%d", xC4, ",%d", xB5D, ",%d", xB5U, ",%d", xB6D, ",%d", xB6U, ",%d", xB7D, ",%d",
		xB7U, ",%d", xB7L, ",%d", xB7R, ",%d", xB8D, ",%d", xB8U, ",%d", xB8L, ",%d", xB8R, ");");

		wait1Msec(R_FREQ);
	}
}


task main()
{
	// clear previous recordings
	clearDebugStream();
	wait1Msec(1000);

	// countdown in debug stream
	writeDebugStreamLine("Begin recording in: 3");
	wait1Msec(1000);
	writeDebugStreamLine("Begin recording in: 2");
	wait1Msec(1000);
	writeDebugStreamLine("Begin recording in: 1");
	wait1Msec(1000);

	// start recording the vexRT signals
	startTask (recordVexRT);
	writeDebugStreamLine("// BEGIN AUTONOMOUS RECORDING");

	writeDebugStreamLine("// Copy the following lines into your autonomous task:");
	writeDebugStreamLine("R_Batt = ", nImmediateBatteryLevel,";");
	writeDebugStreamLine("replayFreq();");

	// allow driver control for 15 seconds
	clearTimer(T1);
	while (time1[T1] < 15000)
	{
		motor[XDriveA] = vexRT[Ch3] + vexRT[Ch1] - vexRT[Ch4];
		motor[XDriveB] = vexRT[Ch3] - vexRT[Ch1] + vexRT[Ch4];
		motor[XDriveC] = vexRT[Ch3] + vexRT[Ch1] + vexRT[Ch4];
		motor[XDriveD] = vexRT[Ch3] - vexRT[Ch1] - vexRT[Ch4];
	}
	if (vexRT[B6U] == 1)
	{
		motor[fourLeft] = 127;
		motor[fourRight] = 127;
		motor[sixLeft] = 127;
		motor[sixRight] = 127;
	}
	else if (vexRT[B6D] == 1)
	{
		motor[fourLeft] = -127;
		motor[fourRight] = -127;
		motor[sixLeft] = -127;
		motor[sixRight] = -127;
	}
	else
	{
		motor[fourLeft] = 0;
		motor[fourRight] = 0;
		motor[sixLeft] = 0;
		motor[sixRight] = 0;
	}


	// stop recording the vexRT signals
	stopTask (recordVexRT);
	writeDebugStreamLine("// END AUTON RECORDING");

	// stop all motors
	motor[port1] = motor[port2] = motor[port3] = motor[port4] = motor[port5] = motor[port6] = motor[port7] = motor[port8] = motor[port9] = motor[port10] = 0;
} 

You do realize that no two teams have the same robot, right?

Yeah this won’t work unless it’s the exact same robot from my understanding

i just ran it and my tank drive started strafing

Well let me put it different way, here a same code but insert your user code and follow the directions from there

#pragma config(Sensor, in1,    Pot,            sensorPotentiometer)
#pragma config(Motor,  port1,           Claw,          tmotorVex393_HBridge, openLoop)
#pragma config(Motor,  port2,           fourLeft,      tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor,  port3,           fourRight,     tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port4,           sixLeft,       tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor,  port5,           sixRight,      tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port6,           FL,            tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor,  port7,           FR,            tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port8,           BR,            tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor,  port9,           BL,            tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port10,          Goal,          tmotorVex393_HBridge, openLoop)
#pragma DebuggerWindows("debugStream")

// HOW TO USE THIS RECORDER:
// 1. Look for the THREE ---->>> paste X here <<<---- comments and paste the described code from your competition template.
// 2. Have a game field set up and a driver ready to drive the bot for an autonomous run.
// 3. While using the programming cable with the controller connected to the robot via vexNet, download this code.
// 4. With the debug stream window open, press start to run the code. There will be a 3 second count down, then 15 seconds to drive.
// 5. Copy the text from the debug stream window into your autonomous task
// 6. Copy the following variables and functions into your competition template above the pre-autonomous task.
/*-----------------------------------------------------------------------------------------------------------*/

int static const R_FREQ = 50; // 50 the frequency of the recording in milisecons.
int R_Batt; // the battery voltage at the time of the recording.
int P_Freq; // the replay frequency in miliseconds


// function to assess battery voltage and adjust replay frequency
void replayFreq()
{
	P_Freq = R_FREQ * (R_Batt / nImmediateBatteryLevel);	//  ~1mS difference in playback per 160mV difference
	// recording at 8200mV and playback at 7200mV would make P_Freq = 57mS, meaning the last 2.1 secs would be stopped by competition control
	// what is the real relationship of voltage and speed?  would vary greatly by robot weight and geomoetry.  Add a constant for teams to tune?
}

// function to replay recorded vexRT signals
void replayVexRT(int C1, int C2, int C3, int C4, int B5D, int B5U, int B6D, int B6U, int B7D, int B7U, int B7L, int B7R, int B8D, int B8U, int B8L, int B8R,
int xC1, int xC2, int xC3, int xC4, int xB5D, int xB5U, int xB6D, int xB6U, int xB7D, int xB7U, int xB7L, int xB7R, int xB8D, int xB8U, int xB8L, int xB8R)
{
	// ---->>> paste your user control code here <<<----
	// replace all the vexRT] statements with the corresponding variable
	// i.e. change "motor[port1] = vexRT[Ch3];" to "motor[port1] = C3;"
	// if your button code is written as a boolean test for true or false, change true to 1 and false to 0
	wait1Msec(P_Freq);
}
/*-----------------------------------------------------------------------------------------------------------*/






// variables to hold the vexRT signal values from main controller
int C1, C2, C3, C4, B5D, B5U, B6D, B6U, B7D, B7U, B7L, B7R, B8D, B8U, B8L, B8R;

// variables to hold the vexRT signal values from partner controller
int xC1, xC2, xC3, xC4, xB5D, xB5U, xB6D, xB6U, xB7D, xB7U, xB7L, xB7R, xB8D, xB8U, xB8L, xB8R;

// task to record vexRT signals to the debug stream once every R_FREQ ms
task recordVexRT()
{
	while(true)
	{
		// main controller values
		C1 = vexRT[Ch1];
		C2 = vexRT[Ch2];
		C3 = vexRT[Ch3];
		C4 = vexRT[Ch4];
		B5D = vexRT[Btn5D];
		B5U = vexRT[Btn5U];
		B6D = vexRT[Btn6D];
		B6U = vexRT[Btn6U];
		B7D = vexRT[Btn7D];
		B7U = vexRT[Btn7U];
		B7L = vexRT[Btn7L];
		B7R = vexRT[Btn7R];
		B8D = vexRT[Btn8D];
		B8U = vexRT[Btn8U];
		B8L = vexRT[Btn8L];
		B8R = vexRT[Btn8R];

		// partner controller values
		xC1 = vexRT[Ch1Xmtr2];
		xC2 = vexRT[Ch2Xmtr2];
		xC3 = vexRT[Ch3Xmtr2];
		xC4 = vexRT[Ch4Xmtr2];
		xB5D = vexRT[Btn5DXmtr2];
		xB5U = vexRT[Btn5UXmtr2];
		xB6D = vexRT[Btn6DXmtr2];
		xB6U = vexRT[Btn6UXmtr2];
		xB7D = vexRT[Btn7DXmtr2];
		xB7U = vexRT[Btn7UXmtr2];
		xB7L = vexRT[Btn7LXmtr2];
		xB7R = vexRT[Btn7RXmtr2];
		xB8D = vexRT[Btn8DXmtr2];
		xB8U = vexRT[Btn8UXmtr2];
		xB8L = vexRT[Btn8LXmtr2];
		xB8R = vexRT[Btn8RXmtr2];

		// write the values to the debug stream window
		writeDebugStreamLine("replayVexRT(", C1, ",%d", C2, ",%d", C3, ",%d", C4, ",%d", B5D, ",%d", B5U, ",%d", B6D, ",%d", B6U, ",%d",
		B7D, ",%d", B7U, ",%d", B7L, ",%d", B7R, ",%d", B8D, ",%d", B8U, ",%d", B8L, ",%d", B8R);
		writeDebugStream(",%d", xC1, ",%d", xC2, ",%d", xC3, ",%d", xC4, ",%d", xB5D, ",%d", xB5U, ",%d", xB6D, ",%d", xB6U, ",%d", xB7D, ",%d",
		xB7U, ",%d", xB7L, ",%d", xB7R, ",%d", xB8D, ",%d", xB8U, ",%d", xB8L, ",%d", xB8R, ");");

		wait1Msec(R_FREQ);
	}
}


task main()
{
	// clear previous recordings
	clearDebugStream();
	wait1Msec(1000);

	// countdown in debug stream
	writeDebugStreamLine("Begin recording in: 3");
	wait1Msec(1000);
	writeDebugStreamLine("Begin recording in: 2");
	wait1Msec(1000);
	writeDebugStreamLine("Begin recording in: 1");
	wait1Msec(1000);

	// start recording the vexRT signals
	startTask (recordVexRT);
	writeDebugStreamLine("// BEGIN AUTONOMOUS RECORDING");

	writeDebugStreamLine("// Copy the following lines into your autonomous task:");
	writeDebugStreamLine("R_Batt = ", nImmediateBatteryLevel,";");
	writeDebugStreamLine("replayFreq();");

	// allow driver control for 15 seconds
	clearTimer(T1);
	while (time1[T1] < 15000)
	{
		// ---->>> paste user control code here  <<<----
	}

	// stop recording the vexRT signals
	stopTask (recordVexRT);
	writeDebugStreamLine("// END AUTON RECORDING");

	// stop all motors
	motor[port1] = motor[port2] = motor[port3] = motor[port4] = motor[port5] = motor[port6] = motor[port7] = motor[port8] = motor[port9] = motor[port10] = 0;
}

HOLY COW THIS IS THE GOD CODE!! IT DEFIES ALL MECHANICAL RESTRAINTS!!

@Juster can you please now add to the code that it will make the robot always win
Thanks

@Easton What do you mean, Does it work to get a autonomous code

They’re just joking with you :stuck_out_tongue:
I’ll try and load your code on my bot later tonight to test it for you :slight_smile:

@Joseph W(182 C) Thanks I appreciate

Alright, I was able to run it and it doesn’t work like you hoped it would. I noticed you got it from this thread. I would recommend you look at that thread again and learn from some of the further discussion that happened to get it to work.
This thread also has some good re-run code in it that I would recommend looking at. Hope you can get it working :slight_smile:
If you want me to post back with the things that didn’t work I can do that as well(I was just a bit rushed tonight trying to do school :P).

Well thanks, I don’t run any sensors and competition is tomorrow wondering if you have a code for a 4 motor tank drive? Just a basic one maybe a mobile goal and bring it back to 5 or 10 point zone.

@Juster
Sorry but I don’t atm.
You can write your own really quick like this:

void forward(int HowLong, float speed)
{
  motor[drive] = speed;
  wait1Msec(HowLong);
  motor[drive] = 0;
}

This is timed so it won’t be as accurate as using sensors but I guess it doesn’t matter since you were willing to do time based in the first place with the re-run program :stuck_out_tongue:

This function can be called out in your auton program and will let you specify how long the motor(s) should run and at what speed(both specified when you call the function). Hope you get it working :slight_smile:
calling the function would look like this:

task autonomous()
{
  forward(1000, 50);//move forward for 1000 milliseconds(1 second) at 50 motor power//
}