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