View Single Post
  #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.