View Single Post
  #6   Spotlight this post!  
Unread 14-02-2013, 01:49
Toa Circuit's Avatar
Toa Circuit Toa Circuit is offline
Thaddeus Maximus
AKA: Thad Hughes
FRC #4213 (MetalCow Robotics)
Team Role: Leadership
 
Join Date: Nov 2012
Rookie Year: 2012
Location: Shirley, IL
Posts: 131
Toa Circuit is an unknown quantity at this point
Re: Printing to a text file

Using ofstream is fine... but one thing. When you create or open ofstream objects, the file is cleared out. If you want to keep a running log, do this so that you only create the objects once.

Code:
//imported #include <fstream>
//leftdrive, rightdrive, and myrobot(leftdrive, rightdrive) are already initilized
int counter;
ofstream left;
ofstream right;
left.open ("LEFT.txt");
right.open ("RIGHT.txt");
while (IsOperatorControl())
{
	float driverLeftY = driverXbox->GetRawAxis(2);
	float driverRightY = driverXbox->GetRawAxis(5);
	myRobot->TankDrive(-driverLeftY, driverRightY);
	while (counter <= 1500) //while (samples <= 1500)
	{
	    right << RightDrive->Get() << "," << endl; 
            left << LeftDrive->Get() << "," << endl;
	    counter++;
	    Wait(0.01);
	}					
}
left.close();
right.close();
Once you have this, use a FTP program like FileZilla to read off the cRIO flash at 10.xx.yy.2
__________________

2012 Head of Programming and Electrical
2013-14 Overall Team Captain and Programming Head
2012-14 Mentor of FLL Team Power Surge
2014 Dean's List Finalist
2014 CIR Xerox Creativity Award
Webpage
Reply With Quote