I am fully in agreement about sensor based programming being the proper solution, but expect that the people asking for this playback feature are looking for (or would accept) a brute-force record of a human controlling the robot for 15 seconds.
If that premise is correct, then wouldn’t you want to record the signals from the controller at x frequency, then call a function that holds all the signal and runs the same code they use in their user control task?
I am not much of a programmer, but something like this:
int C1, C2, C3, C4, B5D, B5U, B6D, B6U, B7D, B7U, B7L, B7R, B8D, B8U, B8L, B8R;
// paste this function above the pre-autonomous task in your competition template code
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)
{
// paste your user control code here, replacing all the vexRT] statements with the corresponding variable
// if your button code is written as a boolean test for true or false, change true to 1 and false to 0
wait1Msec(50);
}
task recordVexRT()
{
while(true)
{
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];
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, ");");
wait1Msec(50);
}
}
task main()
{
writeDebugStreamLine("Begin recording in: 3");
wait1Msec(1000);
writeDebugStreamLine("Begin recording in: 2");
wait1Msec(1000);
writeDebugStreamLine("Begin recording in: 1");
wait1Msec(1000);
startTask (recordVexRT);
writeDebugStreamLine("BEGIN AUTON RECORDING");
writeDebugStreamLine("// Copy the following lines into your autonomous task:");
clearTimer(T1);
while (time1[T1] < 15000)
{
// paste user control code here
}
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;
}