Go to Post I don't even care if it doesn't work as well as they would like. YOU MADE IT. You may never use it, but you made it. AWESOME. Every year there has been 1 team (sometimes 2) that has done something that really stood out. This year 1 team has done 2 things that stand out. Thanks guys. - rees2001 [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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 08-09-2016, 09:00
cpapplefamily cpapplefamily is offline
Registered User
FRC #3244 (Granite City Gearheads)
Team Role: Mentor
 
Join Date: May 2015
Rookie Year: 2015
Location: Minnesota
Posts: 237
cpapplefamily has a spectacular aura aboutcpapplefamily has a spectacular aura about
Roborio CPU what is resonable

We been digging into why it appears that our Roborio CPU utilization seems high. Disabled and Teleop seem to run at 80-90%. Its tough to tell by simply watching the graph but it trends nearly on top of the voltage plot. When we deploy new code it drops to 40-50% as it relaunches then back to 80-90%.

We are running the command based program, Vision is processed on a co-possessor (Kangaroo), Camera is an IP Axis webcam. The Roborio has been recently re-imaged to try and assure no old on Roborio GRIP stuff is still there. We have removed most of our SmartDashboard.put_______ code from the program

Last night we tried a new program written from scratch using Robotbuilder that simply had one Subsystem (Drive train), one command (DriveRobot), and one Joystick. Drive Train has 4 talons and 1 analog gyro to drive the Mecanums. No bells, no whistles. Simple get 3 Joystick analog values and Drive. Even with this the Roborio CPU was 50%.

What is reasonable CPU usage?

Last edited by cpapplefamily : 08-09-2016 at 09:12.
Reply With Quote
  #2   Spotlight this post!  
Unread 08-09-2016, 09:36
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 305
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Roborio CPU what is resonable

Looking at some old logs still on my computer from build season, it looks like 50-70% is "reasonable". The Rio is not all that powerful...
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #3   Spotlight this post!  
Unread 08-09-2016, 13:26
Thad House Thad House is offline
Volunteer, WPILib Contributor
no team (Waiting for 2021)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Thousand Oaks, California
Posts: 1,071
Thad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond repute
Re: Roborio CPU what is resonable

So a robot program with nothing running causes about 30% cpu usage by default. This is inherent to the driver station thread, and slow IPC calls on arm linux, which are used to get the driver station values and joysticks. We are currently working on some fixes for this, but for the 2017 season the slow calls all happen on a separate thread, so other threads should be free to do as they please.

I would have to see your code, but depending on how the joystick code is written, and some other things, it is really easy for code usage to get out of hand really quick. One of the big things currently is a call to any of the Driver Station status checks (IsOperatorControl(), IsAutonomous() etc..) or accessing any joystick properties other then axes, povs or buttons will be a fairly slow call (relatively, 100-200us vs the expected 1us or so) and can cause the RoboRIO to show excess CPU usage when in reality it is probably OK.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of RobotDotNet, a .NET port of the WPILib.
Reply With Quote
  #4   Spotlight this post!  
Unread 09-09-2016, 02:58
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: Roborio CPU what is resonable

Quote:
Originally Posted by euhlmann View Post
Looking at some old logs still on my computer from build season, it looks like 50-70% is "reasonable". The Rio is not all that powerful...
That made me laugh. Back when I was a student, we were excited about a 10 MHz Microchip processor that you could program in C (instead of Basic), and it was pretty fast. Now I'm dating myself...

The roboRIO is actually very fast. It is a dual core A15 clocked about 1 ghz with a FPGA attached to it and 256 MB of ram. That's a serious amount of CPU power. An A15 is also an out of order processor, and (if I'm reading right), triple issue, and has vectorized floating point math. That means that it can execute 3 instructions in parallel per core, and will re-order instructions to be more efficient. It's not quite as fast as a brand new cell-phone processor, but it's actually pretty close.


The challenge, as Thad aptly put it, is that it takes about 50% of the CPU to interact with the services running on the roboRIO to talk to the field and the CAN bus. That's before you write a line of code. There are also certain calls which use a bunch of CPU. Setting solenoids is one of them. Reading joystick values/DS values is another. If you are worried about CPU usage, you want to minimize those calls. You can benchmark the various calls to see how much CPU they use.

We run our roboRIO at about 80-90% CPU. About 50% of the CPU is taken up by code outside our control.
Reply With Quote
  #5   Spotlight this post!  
Unread 09-09-2016, 06:26
cpapplefamily cpapplefamily is offline
Registered User
FRC #3244 (Granite City Gearheads)
Team Role: Mentor
 
Join Date: May 2015
Rookie Year: 2015
Location: Minnesota
Posts: 237
cpapplefamily has a spectacular aura aboutcpapplefamily has a spectacular aura about
Re: Roborio CPU what is resonable

I've posted the code before here on CD. Here it is againhttps://github.com/GraniteCiyGearhea...ntsABot_Summer admitted its an overburden to read. With some of this feed back we are building a fresh program slowly adding in the functions we really used and focusing on the CPU usage as we go to see if there is a point it get out of control. This is also to get a better understating to what might be happening.

Thanks for all the feed back and confirming 50% is the starting point.
Reply With Quote
  #6   Spotlight this post!  
Unread 10-09-2016, 03:42
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: Roborio CPU what is resonable

Quote:
Originally Posted by cpapplefamily View Post
I've posted the code before here on CD. Here it is againhttps://github.com/GraniteCiyGearhea...ntsABot_Summer admitted its an overburden to read. With some of this feed back we are building a fresh program slowly adding in the functions we really used and focusing on the CPU usage as we go to see if there is a point it get out of control. This is also to get a better understating to what might be happening.

Thanks for all the feed back and confirming 50% is the starting point.
(As much as I'd love to read through your code and give advice, I'm not a strong Java programmer, and am too busy to really dig in and do it justice)

Admittedly, this is a very C++ targeted answer, but you can use strace to help understand which calls are triggering a RPC, and which calls are accessing the memory mapped IO of the FPGA. As you can probably imagine, the RPC is expensive, and the memory access is cheap. You can likely use strace with Java, but there could be more noise from other calls that Java makes.

I always struggle to get good benchmarking numbers, but the limited numbers that I got were from gperftools' sample based profiler. They showed that most of our execution time was associated with the RPC calls, and a good 60% of the time in the RPC calls was in the kernel.
Reply With Quote
  #7   Spotlight this post!  
Unread 12-09-2016, 08:34
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
Re: Roborio CPU what is resonable

We use LabView and typically have a decent amount of code running on our robot. According to the log viewer, our CPU usage was 55% when not enabled and 65-70% when enabled. This was with our vision processing code running on the RIO. I suspect the increase in tele was due to us having the "devref get" active in our teleop section of code when it really only needs to run once.

I'm not familiar with the FRC Java API, but I do have some questions for you based on what I can read.
1) How often are your PID loops running? (in ms or hz)
2) How often are you updating Smart Dashboard? (in ms or hz)
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
Reply With Quote
  #8   Spotlight this post!  
Unread 08-10-2016, 19:10
cpapplefamily cpapplefamily is offline
Registered User
FRC #3244 (Granite City Gearheads)
Team Role: Mentor
 
Join Date: May 2015
Rookie Year: 2015
Location: Minnesota
Posts: 237
cpapplefamily has a spectacular aura aboutcpapplefamily has a spectacular aura about
Re: Roborio CPU what is resonable

Quote:
Originally Posted by adciv View Post
We use LabView and typically have a decent amount of code running on our robot. According to the log viewer, our CPU usage was 55% when not enabled and 65-70% when enabled. This was with our vision processing code running on the RIO. I suspect the increase in tele was due to us having the "devref get" active in our teleop section of code when it really only needs to run once.

I'm not familiar with the FRC Java API, but I do have some questions for you based on what I can read.
1) How often are your PID loops running? (in ms or hz)
2) How often are you updating Smart Dashboard? (in ms or hz)
I found two PID's set to .001 ms period. Changed to .002 made a difference. Shouldn't it be more like .02 ms? Maybe .01 ms?

How do we control Smart Dashboard updates?
Reply With Quote
  #9   Spotlight this post!  
Unread 08-10-2016, 21:29
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 305
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Roborio CPU what is resonable

SmartDashboard updates happen when you call the "set" methods on the SmartDashboard object. You can try calling them less often (instead of on every tick, try once every 2 or 3 ticks)
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #10   Spotlight this post!  
Unread 08-10-2016, 21:37
cpapplefamily cpapplefamily is offline
Registered User
FRC #3244 (Granite City Gearheads)
Team Role: Mentor
 
Join Date: May 2015
Rookie Year: 2015
Location: Minnesota
Posts: 237
cpapplefamily has a spectacular aura aboutcpapplefamily has a spectacular aura about
Re: Roborio CPU what is resonable

Is there a simple trick to pick the tick? Do we wrap the update dashboard variable condition and set the variable true every few program scans?

We have removed a lot of the none necessary dashboard data.
Reply With Quote
  #11   Spotlight this post!  
Unread 09-10-2016, 01:43
Thad House Thad House is offline
Volunteer, WPILib Contributor
no team (Waiting for 2021)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Thousand Oaks, California
Posts: 1,071
Thad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond repute
Re: Roborio CPU what is resonable

By default, SmartDashboard only actually sends new data every 100ms. It stores the data locally in the table before that time. Yes too many updated keys can be a problem, but in all honestly 50+ keys isn't bad at all, and many teams run many more keys.

The PIDController set to 1 ms is definitely a problem. Unless you are using CAN, PWM motor controllers can only update every 5 ms. So running much faster then that isn't actually helping much. Plus unless your code loops can handle that speed, or you are running a shooter wheel, even 5 ms is too fast. We usually recommend between 10 and 20 ms, as there is usually plenty of CPU power to run that, and most mechanical and control systems can't handle much faster then that anyway.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of RobotDotNet, a .NET port of the WPILib.
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 12: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