Go to Post Luck *good or bad* and opportunity will always affect what happens to teams. - Brian C [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 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:	39
Size:	36.8 KB
ID:	12171Click image for larger version

Name:	Untitled2.png
Views:	33
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
  #2   Spotlight this post!  
Unread 01-03-2012, 17:46
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 671
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Strange lag issue

I don't know how this could cause the lag either. Then why did you say this is the most likely culprit? In any case, since you are using float, you should use fabs() instead of abs(). I don't know what abs() will do to float. But if it truncates it to integer, you could still be dividing by zero.
__________________
Reply With Quote
  #3   Spotlight this post!  
Unread 02-03-2012, 16:09
Supernovapsy Supernovapsy is offline
Registered User
FRC #1334
 
Join Date: Feb 2012
Location: Canada
Posts: 18
Supernovapsy is an unknown quantity at this point
Re: Strange lag issue

We found out that the jaguars were not given the right ports, and after we switched it, everything worked fine.

Thank you!
Reply With Quote
  #4   Spotlight this post!  
Unread 03-03-2012, 09:17
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Strange lag issue

Does that explain why the CPU usage increased over time?

Greg McKaskle
Reply With Quote
  #5   Spotlight this post!  
Unread 12-03-2012, 16:52
Supernovapsy Supernovapsy is offline
Registered User
FRC #1334
 
Join Date: Feb 2012
Location: Canada
Posts: 18
Supernovapsy is an unknown quantity at this point
Re: Strange lag issue

No, I guess it doesn't.

Well, now there's another issue whereby the robot loses communication by itself. Here's a look at the charts. The robot has vision tracking implemented, so the CPU is really high.

When the robot starts, there seems to be a huge number of messages, but then drops back down again. Furthermore, there is a constant number of dropped packets. When the number of messages became lower, I enabled the robot, and tried moving it, but it immediately lost communication and disabled itself

Can anyone suggest what may be the cause of this problem?
Thank you.

P.S. This happens with pretty much all of our robots. Do you think batteries might be the problem?
Reply With Quote
  #6   Spotlight this post!  
Unread 12-03-2012, 16:54
Supernovapsy Supernovapsy is offline
Registered User
FRC #1334
 
Join Date: Feb 2012
Location: Canada
Posts: 18
Supernovapsy is an unknown quantity at this point
Re: Strange lag issue

Here's the image

Click image for larger version

Name:	Lost Packets.png
Views:	22
Size:	25.3 KB
ID:	12293
Reply With Quote
  #7   Spotlight this post!  
Unread 13-03-2012, 13:51
frdrake frdrake is offline
Registered User
FRC #0233
 
Join Date: Feb 2012
Location: Melbourne
Posts: 23
frdrake is on a distinguished road
Re: Strange lag issue

Have you tried opening up the WTX console to see if any errors are being output there that might be relevant?
Reply With Quote
  #8   Spotlight this post!  
Unread 13-03-2012, 20:23
nighterfighter nighterfighter is offline
1771 Alum, 1771 Mentor
AKA: Matt B
FRC #1771 (1771)
Team Role: Mentor
 
Join Date: Sep 2009
Rookie Year: 2007
Location: Suwanee/Kennesaw, GA
Posts: 835
nighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant futurenighterfighter has a brilliant future
Re: Strange lag issue

Couple of things:

One- Your wireless router is connected to the correct power port, right? Maybe you are enabling and it its losing power?

Two- Have you tried running just the crio? No jaguars or anything, and see if it still crashes.

There- Could you post the rest of your code, and we can help find the problem.

Four- Are you doing any camera tracking? That could cause the problem also.
Reply With Quote
  #9   Spotlight this post!  
Unread 13-03-2012, 20:40
AllenGregoryIV's Avatar
AllenGregoryIV AllenGregoryIV is offline
Engineering Coach
AKA: Allen "JAG" Gregory
FRC #3847 (Spectrum)
Team Role: Coach
 
Join Date: Jul 2008
Rookie Year: 2003
Location: Texas
Posts: 2,557
AllenGregoryIV has a reputation beyond reputeAllenGregoryIV has a reputation beyond reputeAllenGregoryIV has a reputation beyond reputeAllenGregoryIV has a reputation beyond reputeAllenGregoryIV has a reputation beyond reputeAllenGregoryIV has a reputation beyond reputeAllenGregoryIV has a reputation beyond reputeAllenGregoryIV has a reputation beyond reputeAllenGregoryIV has a reputation beyond reputeAllenGregoryIV has a reputation beyond reputeAllenGregoryIV has a reputation beyond repute
Send a message via AIM to AllenGregoryIV
Re: Strange lag issue

From that graph it looks like you are dropping a lot of packets have you tried moving your router around on the robot, away from the jaguars and motors and seeing if that fixes the problem?
__________________

Team 647 | Cyber Wolf Corps | Alumni | 2003-2006 | Shoemaker HS
Team 2587 | DiscoBots | Mentor | 2008-2011 | Rice University / Houston Food Bank
Team 3847 | Spectrum | Coach | 2012-20... | St Agnes Academy
LRI | Alamo Regional | 2014-20...
"Competition has been shown to be useful up to a certain point and no further, but cooperation, which is the thing we must strive for today, begins where competition leaves off." - Franklin D. Roosevelt
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 03:04.

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