Go to Post I'm going to get kicked out of the mentor club for this one... - Not2B [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-02-2016, 13:56
Coupon4504 Coupon4504 is offline
Registered User
FRC #4504
 
Join Date: Jan 2015
Location: Blount County, Tennessee
Posts: 5
Coupon4504 is an unknown quantity at this point
Outputing files to the PC with ofstream in Autonomous

In by Test function, I have the following code to output gyro values. I was wanting to record values every 10 miliseconds and save them to a file to plot, where I would experiment with different PID values.
Code:
void Test()
{
	static const double Kp = 0.03;
	gyro->Reset();
	std::ofstream file("gyro.txt");
	while(true)
	{
		double angle = gyro->GetAngle();
		static int revolutions = 0;
		if(file.is_open())
		{
			file << revolutions << '\t';
			file << -angle * Kp << '\n';
			SmartDashboard::PutString("Error: ", " ");
		}else
		{
			SmartDashboard::PutString("Error: ", "Cannot load file");
		}
		Wait(0.01);
		revolutions++;
	}
	file.close();
}
The problem is file.is_open() always returns false. Is there something else I need to do to get files to be created?

Last edited by Coupon4504 : 02-02-2016 at 14:58.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:19.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi