View Single Post
  #1   Spotlight this post!  
Unread 02-06-2016, 01:10 PM
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
CAN Transmit Error and standard output

I have created a function that calculates the I part of PID and then outputs the data to the console to create a graph and analyze different constants (Ki). This is a side project while we wait on build to finish what they are working on. The integral function works, but when I add it to our Sample Robot, it fails for multiple reasons: I get the error below when running the test code, and The output does not go to the console unless I go into teleop mode.

Why is the output delayed and why did this error occur? Any easier ways to output data? File I/O does not work. I have tried using cout and printf, and both have this problem. Usually cout works better

Quote:
FRC: Robot radio detection times. Error on line 238 CTRE CAN Transmit Error
at /home/lvuser/FRCUserProgram() [0x1fcc4]
at /home/lvuser/FRCUserProgram() [0x27904]
at /home/lvuser/FRCUserProgram() [0x87210]
at /home/lvuser/FRCUserProgram() [0x898f0]
at /home/lvuser/FRCUserProgram() [0x9a3cc]
at /home/lvuser/FRCUserProgram() [0x9499c]
at /home/lvuser/FRCUserProgram() [0xc0804]
at /opt/GenICam_v2_3/bin/Linux_armv7-a/libstdc++.so.6(+0xa2cb0) [0xb6af1cb0]
Code:
double integral(double angle, double x)
{
	double result = 0;
	int n = 1;
	result += gyros[0];
	if(x > 0.1)
	{
		for(double i = 1; i <= x * 10; i += 1)
		{
			result += 2*gyros[i];
			n++;
		}
	}
	result += angle;
	result *= x/(2*n);
	std::cout << result << '\n';
	return result;
}

void Test() override
{
	for(int x = 0; x < 10000; x++)
	{
		double angle = gyro->GetAngle();
		myRobot->Drive(0.15, -Kp*angle );
		gyros.push_back(angle);
                std::cout << x << ' ' << Kp*integral(angle, x) << ',';
		printf("%d %e,", x, Ki*integral(angle, x));
		Wait(0.01);
	}
        myRobot->SetLeftRightMotorOutputs(0.0, 0.0);
}

Last edited by Coupon4504 : 02-06-2016 at 01:13 PM.
Reply With Quote