We have an application where we need to print large amounts of data to a text file, but can't figure out what we're doing. We're trying to save a log of the values sent to the motor controllers (I know 1500 may be a bit excessive, but it's for a reason). First we made text files "RIGHT" and "LEFT" (and eventually tried "right" and "left") and added them to our project (screenshot attached). We considered comma separated value data in one text file on two separate lines, but two separate text files seemed easier to use. This is the code we're using:
Code:
//imported #include <fstream>
//leftdrive, rightdrive, and myrobot(leftdrive, rightdrive) are already initilized
int counter;
while (IsOperatorControl())
{
float driverLeftY = driverXbox->GetRawAxis(2);
float driverRightY = driverXbox->GetRawAxis(5);
myRobot->TankDrive(-driverLeftY, driverRightY);
ofstream left;
ofstream right;
left.open ("LEFT.txt");
right.open ("RIGHT.txt");
while (counter <= 1500) //while (samples <= 1500)
{
right << RightDrive->Get() << "," << endl;
left << LeftDrive->Get() << "," << endl;
counter++;
Wait(0.01);
}
left.close();
right.close();
}
When we check the text files, there is no change. Has anyone else tried utilizing text files in their code?