View Single Post
  #1   Spotlight this post!  
Unread 09-02-2013, 14:44
mrklempae mrklempae is offline
Registered User
no team
 
Join Date: Jan 2013
Location: Montana
Posts: 19
mrklempae is an unknown quantity at this point
Printing to a text file

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?
Attached Thumbnails
Click image for larger version

Name:	ProjectExplorerCap.PNG
Views:	35
Size:	11.5 KB
ID:	13882  
Reply With Quote