Go to Post I've never seen a spam bot edit posts before - Vikesrock [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 06-02-2016, 13:10
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 : 06-02-2016 at 13:13.
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 10:00.

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