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?