View Single Post
  #1   Spotlight this post!  
Unread 01-03-2012, 16:14
Supernovapsy Supernovapsy is offline
Registered User
FRC #1334
 
Join Date: Feb 2012
Location: Canada
Posts: 18
Supernovapsy is an unknown quantity at this point
Strange lag issue

My team is currently testing out kitbots and bots from previous years, but we have encountered a really strange CPU lag issue where the following pattern emerges every time the robot is rebooted and restarted:

Click image for larger version

Name:	Untitled.png
Views:	38
Size:	36.8 KB
ID:	12171Click image for larger version

Name:	Untitled2.png
Views:	32
Size:	37.3 KB
ID:	12172

The CPU starts off at nearly zero, but gradually increases to 100%. This problem is causing a great lag for the robot. The most likely candidate for the lag issue is this:

Code:
void Adjust(float& left, float& right)
{
	float difference = abs(abs(left) - abs(right));
	if (difference < tolerance)
	{
		float average = (abs(left) + abs(right)) / 2;
		if (left != 0)
			left = average * (left / abs(left));
		if (right != 0)
			right = average * (right / abs(right));
	}
	left = left * left * left * left_sensitivity;
	right = right * right * right * right_sensitivity;
	
	if (left > 1)
		left = 1;
	else if (left < -1)
		left = -1;
	if (right > 1)
		right = 1;
	else if (right < -1)
		right = -1;
}
even though I don't know how this would cause any lag.
Reply With Quote