Go to Post The function of that part is to keep one student occupied playing with it during the entire build season. It doesn't have to be the same student all the time, they can take turns. - MrForbes [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 19-01-2009, 16:32
ellisk ellisk is offline
Registered User
FRC #1540
 
Join Date: Dec 2008
Location: Vancouver, WA
Posts: 41
ellisk is on a distinguished road
Image processing and performance

Hi everyone,
Currently, I've gotten my program to recognize the pink and green flags, but the image processing functions take a long time (about 1/4 a second or more). I'm using threads ("tasks" on the cRIO) for the different parts of our code, and there's currently 3 threads. I'm wondering if the threads are all getting 1/3 of the CPU, and so that's slowing down our code. Is that possible? If so, can I set the priority of some threads to be higher? I noticed in the constructor for the Task class that I can specify a priority (it defaults to 100). Is 1 the highest or 100? How can I set the priority of the thread which runs OperatorControl?

Thanks,
-Kevin
Reply With Quote
  #2   Spotlight this post!  
Unread 19-01-2009, 19:48
gvarndell's Avatar
gvarndell gvarndell is offline
Software Engineer
AKA: Addi's and Georgie's Dad
FRC #1629 (GaCo)
Team Role: Parent
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Grantsville, Maryland
Posts: 350
gvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond repute
Re: Image processing and performance

Quote:
Originally Posted by ellisk View Post
I'm using threads ("tasks" on the cRIO) for the different parts of our code, and there's currently 3 threads. I'm wondering if the threads are all getting 1/3 of the CPU, and so that's slowing down our code. Is that possible?
It's possible but not likely. The vxWorks kernel doesn't schedule tasks for a fixed length of time. If it did, and there were only 3 tasks, then each would 'use' approximately 1/3 of the CPU time. Under vxWorks, tasks are made ready by events and the highest priority ready task is scheduled to run. That task will run until a) it relinquishes control or b) is preempted by a higher priority task becoming ready. (think about the implications of a high priority task that doesn't relinquish control)

Quote:
Originally Posted by ellisk View Post
can I set the priority of some threads to be higher? I noticed in the constructor for the Task class that I can specify a priority (it defaults to 100). Is 1 the highest or 100?
Yes. You can do so before the task is created or any time after.
The highest priority is 0 -- 255 is the lowest.
Take my word for this, you don't want to use a priority higher than 51 for your robot tasks unless you know exactly what you're doing.

Quote:
Originally Posted by ellisk View Post
How can I set the priority of the thread which runs OperatorControl?
If you can get hold of the 'object' for that task, then yes.
Just call the SetPriority method.
I'm neither a C++ fan nor a C++ expert, so I can't tell you how to 'get' a task object for a task your didn't 'instantiate'.
Note that you can create tasks and do whatever you like with them, in a less obfuscated way, by simply calling the vxWorks taskLib API.
Reply With Quote
  #3   Spotlight this post!  
Unread 19-01-2009, 21:51
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: Image processing and performance

It is possible to set priority of a task, but you should be somewhat careful as a higher priority task that doesn't sleep may largely shut down lower priority tasks. A better approach is to look at the tasks and see which of them should be more efficient or sleep because it has nothing better to do.

Greg McKaskle
Reply With Quote
  #4   Spotlight this post!  
Unread 20-01-2009, 07:45
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Image processing and performance

Did you try reducing the resolution of the frame?
Reply With Quote
  #5   Spotlight this post!  
Unread 20-01-2009, 09:54
j_johnson j_johnson is offline
Registered User
FRC #0226 (Hammerheads)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2003
Location: Shelby Township, MI
Posts: 10
j_johnson is an unknown quantity at this point
Re: Image processing and performance

If you are using a class inherited from IterativeRobot, note that there is no built in delay, so it will use as much processing power as possible, the kernel splitting it equally with tasks of the same priority. To correct this, you can add a taskDelay() call in each of the XXXContinuous functions.

The delay should be long enough to cede as much processing power to other threads as possible without being so long that you are missing calls to the XXXPeriodic functions. (Assuming you are not using the XXXContinuous for anything time sensitive.) Make sure to include taskLib.h which declares this method.

Here is some documentation on VxWorks tasks if you are interested in reading more.
Reply With Quote
  #6   Spotlight this post!  
Unread 20-01-2009, 13:32
nathanww nathanww is offline
Hacker
FRC #1678 (Citrus Circuits)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2007
Location: Davis, CA
Posts: 224
nathanww is just really nicenathanww is just really nicenathanww is just really nicenathanww is just really nice
Re: Image processing and performance

You also probably want to take a look at your vision processing system and see if anything can be sped up there. Using the lowest resolution at which you can still identify the target will be helpful, as well as using a nested structure for target identification(for example, only look for a pink flag if a suitable green flag has already been found)
__________________
Get yer robot source code here!
Reply With Quote
  #7   Spotlight this post!  
Unread 20-01-2009, 16:48
gvarndell's Avatar
gvarndell gvarndell is offline
Software Engineer
AKA: Addi's and Georgie's Dad
FRC #1629 (GaCo)
Team Role: Parent
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Grantsville, Maryland
Posts: 350
gvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond repute
Re: Image processing and performance

Quote:
Originally Posted by j_johnson View Post
If you are using a class inherited from IterativeRobot, note that there is no built in delay, so it will use as much processing power as possible, the kernel splitting it equally with tasks of the same priority.
Note that vxWorks will not, by default, do round-robin scheduling of tasks with the same priority. If there are 3 tasks with priority 100, and one of them never blocks (timed wait, request unavailable resource, etc.) then that task will forever be the only priority 100 task to run. Lower priority tasks will be locked out -- of course, higher priority tasks can still run.
To enable round-robin scheduling, the user code needs to call kernelTimeSlice() and pass it a tick count.
Those interested in knowing more about this stuff should use the Workbench HELP facility -- Help -> Help Contents.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[not-FIRST] Camera Image Processing Greg Marra Programming 11 11-03-2008 21:10
Image Processing on mouth ROI tommy_chai Programming 0 20-11-2007 08:32
thoughts about image processing 3dude_2231 Technical Discussion 5 12-11-2007 13:26
Critique my image processing program... Salik Syed Programming 13 29-06-2006 16:57
STAMP (Statistical Team Analysis of Match Performance) is off and running! Ethulin Scouting 6 04-02-2006 23:12


All times are GMT -5. The time now is 11: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