Go to Post A good measure of Integrity is what you do when nobody's watching. - DonRotolo [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 31-03-2016, 22:41
Oldgoer Oldgoer is offline
Registered User
FRC #3814
Team Role: Mentor
 
Join Date: Mar 2016
Rookie Year: 2015
Location: Kentucky
Posts: 3
Oldgoer is an unknown quantity at this point
CPU usage idles at 80% and hits 100% when running teleop code

Just recently we ran into an issue during competition that lead to our robot being disabled due to data pack loss issues. when going over the logs of the roborio we realized that basically since any code was loaded to the RIO the robot's CPU has been idling at 80%. when teh code is put into teleop mode we max out eh CPU at 100%. until just recently this appears to have not affected us, but today it appears the stars aligned ans cause our robot to fail during competition. We systematically went through our code removing things to try to figure out what was causing the issue. We basically have the code stripped down to the class calls of the attached devices and that is it and the CPU still idles at 80% with a non-existent teleop code at 100%. does anybody have any suggestion on what our problem might be. our code was never that complex to begin with so i see no reason as to why the code would peg the CPU during the teleop mode. here is a link to our robot code: http://pastebin.com/KVbgbMXF

list of trouble shooting we have tried
1. reflash the roborio -- with absloutly no code on the rio the cpu ran at a resonable CPU usage. as soon as code was loaded idle 80%, teleop 100%
2. strip down code to just class calls, variable ids, and empty voids. -- CPU idle 80%, teleop (with basically no code) 100%
3. load robot with last year code -- CPU idle 80%, teleop 100% (last year cod has significantly less in it... no camera, no CANTalon, no encoders for autonomous);
  #2   Spotlight this post!  
Unread 31-03-2016, 23:18
nickbrickmaster's Avatar
nickbrickmaster nickbrickmaster is online now
Captain
AKA: Nick Schatz
FRC #3184 (Blaze Robotics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2014
Location: Eagan MN
Posts: 143
nickbrickmaster is an unknown quantity at this point
Re: CPU usage idles at 80% and hits 100% when running teleop code



But seriously, a few things I would try:

Why is Scheduler being run at all?, especially in disabled?
Do you have the latest roboRio image?
SSH into the 'rio and run
Code:
top
top will tell you the most about your problem.
__________________
I have approximate knowledge of many things.

FRC 3184: 2014-, FTC 10648: 2015-
  #3   Spotlight this post!  
Unread 31-03-2016, 23:22
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: CPU usage idles at 80% and hits 100% when running teleop code

Try putting a Wait(0.05) at the end of your tele-op periodic.

Right now, your code just hammers through the teleop periodic. Having a tiny Wait() should bring your CPU usage down.
__________________
1771- Programmer, Captain, Drive Team (2009-2012)
4509- Mentor (2013-2015)
1771- Mentor (2015)
  #4   Spotlight this post!  
Unread 31-03-2016, 23:32
AustinSchuh AustinSchuh is offline
Registered User
FRC #0971 (Spartan Robotics) #254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Los Altos, CA
Posts: 800
AustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond repute
Re: CPU usage idles at 80% and hits 100% when running teleop code

Quote:
Originally Posted by nighterfighter View Post
Try putting a Wait(0.05) at the end of your tele-op periodic.

Right now, your code just hammers through the teleop periodic. Having a tiny Wait() should bring your CPU usage down.
That's not true

Code:
 97     } else {
 98       // call TeleopInit() if we are now just entering teleop mode from
 99       // either a different mode or from power-on
100       if (!m_teleopInitialized) {
101         lw->SetEnabled(false);
102         TeleopInit();
103         m_teleopInitialized = true;
104         // reset the initialization flags for the other modes
105         m_disabledInitialized = false;
106         m_autonomousInitialized = false;
107         m_testInitialized = false;
108         Scheduler::GetInstance()->SetEnabled(true);
109       }
110       HALNetworkCommunicationObserveUserProgramTeleop();
111       TeleopPeriodic();
112     }
113     // wait for driver station data so the loop doesn't hog the CPU
114     m_ds.WaitForData();
115   }
116 }
TeleopPeriodic is called every time you get data from the driver station.


Try removing the CameraServer and seeing if that reduces your CPU usage. I'd suggest trying to comment out parts of your code and see what is causing the high usage.

FYI, you are sleeping in TeleopPeroidic. This will cause none of the rest of your motors to update while you are sleeping.

Last edited by AustinSchuh : 31-03-2016 at 23:35.
Closed Thread


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 09:09.

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