Go to Post Its always reassuring to share a design with a respected, competitive and veteran team. - Adama [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 22-01-2012, 18:38
edthetoad edthetoad is offline
Registered User
no team
 
Join Date: Jan 2012
Location: Here
Posts: 7
edthetoad is an unknown quantity at this point
Worried about cRIO CPU usage when using vision

Hello,
Our team is looking into using a camera to help us with shooting baskets. We were worried that the cRIO might have some trouble with running the vision and normal programming. We usually have fairly complex programs with many PID loops and usually we use about 80% of the CPU after we spend time optimizing the code. We find that running the basic drive code and a basic vision code gives us about 95% usage. This is a large increase from the 50% from a basic code. When we probe data/view images in a front panel our CPU usage on cRIO jumps to about 100%. After several seconds of 100% CPU our robot will disable itself. This also happens if we change PID loop variables or we change some vision settings while we have vision processing running. Currently we have switches that disable our drive/PID loops/vision processing but this cannot be a permanent solution for us. We would like to know if there would be a way to lower our CPU usage. What are you guys seeing for CPU while using vision. We are a little worried about our cRIO as sometimes when it runs some new code after we have deployed it the CPU usage spikes to 100% and it loses connection. Should the cRIO be disabling/crashing when it is overworked. For our vision code we are using a modified version of the included rectangle tracking. We have gone back to the original version of the rectangle code and our problems are much worse. What could we be doing wrong? Has anybody been able to send vision processing to a laptop on the robot. Currently we are using 95% running fairly optimized versions of drive/vision/a single PID loop. We have done research and have found that several teams have removed the safety checks for motors. How would we do that? Is there also a way to see which vi's are using the CPU the most?
  #2   Spotlight this post!  
Unread 22-01-2012, 18:55
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: Worried about cRIO CPU usage when using vision

We are currently running all of our code in Timed Loops, so the vision will always suffer first.

This way, since all of the important things (control loops mostly) MUST run at their given interval, the vision gets whatever is left. It also runs in a low priority thread.

The CPU will be pegged at 100%, but the important code should still run.

As for performance monitoring, here are your options:
-There is a block called "RT CPU usage" which tells you the CPU usage by thread priority. If you set priorities correctly, this will tell you what is using the most CPU time.
-There is a more precise performance monitoring tools in Tools->Profile, but you need to do a fairly precise test to get good data - You start the profiler, start the VI for a fairly short period of time, stop the VI, and stop the profiler. This tool will tell you execution time of each VI, which can be helpful for finding which VI's are taking too long to execute.
-There used to be a nice System Monitor somewhere in 8.6, but I have not yet found it in 2011.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
  #3   Spotlight this post!  
Unread 22-01-2012, 19:20
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,753
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: Worried about cRIO CPU usage when using vision

The system monitor functionality is now reached by right clicking on the RT Target in the Project window. Then go to Utilities and choose System Monitor.

This information is also on the Charts tab of the DS.

As for things using lots of CPU. Vision has a tendency of doing that. One thing to consider is how often or when the vision code needs to run. Do you run it when you think your robot is at a scoring location, or all the time? Do you run it while driving in tele, or when a button is pressed? Do you need it to run at 320x240, or can you run it on a smaller image (perhaps when close)? Do you need to do the convex hull and other operations on the whole image, or do you know something from previous images to help look where you expect things rather than look at the entire image?

And the profiler or your own instrumentation is the right way to look for how often code is running or at the CPU usage. The cRIO should not crash when run at 100%, but it likely means that some things aren't running as fast as you asked them to run. That will affect the control performance, so you may want to think about how fast things are running to see if you can slow some things down or prioritize things.

Greg McKaskle
  #4   Spotlight this post!  
Unread 22-01-2012, 21:01
Johnny_5's Avatar
Johnny_5 Johnny_5 is offline
Whose cooking motor?
AKA: Isaac
FRC #3484 (Short Circuit)
Team Role: College Student
 
Join Date: Dec 2010
Rookie Year: 2010
Location: Marysville Ohio
Posts: 150
Johnny_5 has a spectacular aura aboutJohnny_5 has a spectacular aura about
Re: Worried about cRIO CPU usage when using vision

Isn't there a way to off load the vision processing back onto the drivers station during a match?
  #5   Spotlight this post!  
Unread 22-01-2012, 21:16
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 990
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Worried about cRIO CPU usage when using vision

Quote:
Originally Posted by Johnny_5 View Post
Isn't there a way to off load the vision processing back onto the drivers station during a match?
Yes, but at a cost of increased latency. Camera->D-Link->field AP->DS Computer->field AP->D-Link->cRIO with 2 wireless legs instead of camera->D-Link->cRIO with no wireless legs.

As with most engineering problems, there are tradeoffs to be evaluated when choosing between various options.
  #6   Spotlight this post!  
Unread 22-01-2012, 21:18
the man's Avatar
the man the man is offline
Registered User
AKA: Jacob Overla
FRC #4004
Team Role: Mechanical
 
Join Date: Jan 2009
Rookie Year: 2009
Location: muskegon MI
Posts: 344
the man is on a distinguished road
Re: Worried about cRIO CPU usage when using vision

Not completely sure but cant we have something else on the robot to co-process the image data received?
__________________
Every day is a new adventure!!!
  #7   Spotlight this post!  
Unread 23-01-2012, 07:50
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: Worried about cRIO CPU usage when using vision

Quote:
Originally Posted by RufflesRidge View Post
Yes, but at a cost of increased latency. Camera->D-Link->field AP->DS Computer->field AP->D-Link->cRIO with 2 wireless legs instead of camera->D-Link->cRIO with no wireless legs.

As with most engineering problems, there are tradeoffs to be evaluated when choosing between various options.
This is true if you use the dashboard to handle the processing, but you can use any network attached computer running smart dashboard. If you have an extra 400 bucks and 2.5lbs you could put a laptop on the robot minimizing network latency.
__________________
"Never let your schooling interfere with your education" -Mark Twain
  #8   Spotlight this post!  
Unread 23-01-2012, 08:09
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,753
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: Worried about cRIO CPU usage when using vision

When discussing using laptops for vision, here are a few things to keep in mind.

The camera and cRIO are enet devices. They are already on a network with the dashboard. A laptop on the robot will be on the network too. The networks are different, but not as black and white as it may seem.

As discussed in other threads, you will gain yourself some additional CPU, but you will soon use that up too. Yesterday, I ran a team's dashboard that pegged my core 2 duo laptop with a 640x480 image stream. I could only process 20fps and they were sending 30. This resulted in seconds of lag.

Think about this as a budgeting exercise. Can you determine what is possible with the CPU resources in the cRIO? If you add more CPU, what will it be used for? What will it cost in $ and lbs?

There are certainly tasks that will benefit from adding a laptop, but it is not magic. It should really follow the same process as adding a motor or pneumatics.

Greg McKaskle
  #9   Spotlight this post!  
Unread 23-01-2012, 08:33
the man's Avatar
the man the man is offline
Registered User
AKA: Jacob Overla
FRC #4004
Team Role: Mechanical
 
Join Date: Jan 2009
Rookie Year: 2009
Location: muskegon MI
Posts: 344
the man is on a distinguished road
Re: Worried about cRIO CPU usage when using vision

What if the laptop was only used for processing the image to find out the distance of the target rectangle, but you did not stream any thing back to your driver-station?
__________________
Every day is a new adventure!!!
  #10   Spotlight this post!  
Unread 23-01-2012, 08:57
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: Worried about cRIO CPU usage when using vision

Quote:
Originally Posted by the man View Post
What if the laptop was only used for processing the image to find out the distance of the target rectangle, but you did not stream any thing back to your driver-station?
The rectangle detection algorithms are the expensive process. I would advise trying to think of ways to locate the target that wouldn't require opencv.

For example I am looking at the rectangle as two parallel lines. The distance to the hoop can be determined based on the lines and your robots heading. In my case I'm using the kinect but that's more to limit the amount of field calibration that needs to be done.
__________________
"Never let your schooling interfere with your education" -Mark Twain
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 18:59.

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