Go to Post My wife thought the lead singer, Ozzy Kamen was cute. Darn those rockers. - Andy Baker [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
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 10-02-2011, 20:58
mahumnut's Avatar
mahumnut mahumnut is offline
Registered User
FRC #1418 (Vae Victus)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2009
Location: DC area
Posts: 23
mahumnut is an unknown quantity at this point
Camera Processing Script Causing Obscene Lag

Hello cheif delphi community,
So through testing, I have found that the 3 step circle finding script that I made in vision assistant and implemented into the vision processing vi is causing major lag in the other robot systems.
When driving (or operating any other feature) the motors will sporadically continue driving according to the last command 1-3 seconds after the input from the controller has stopped. Specifically, we would pulse the joystick that drives the driving motors, every few pulses, the motors would continue to drive 1-3 seconds after the pulse finished.
I then put the cricle finding script in a disable structure and re-tryed the test: NO LAG. So based on this testing, there is something about the circle processing script I'm using, or its implementation that is causing this lag.
Does anybody have any suggestinos to fix this problem/is there something glaringly obvious I am doing wrong that is causing this problem?
Attached to this post are the vision processing vi and the finding circles script (in its own vi called by vision processing)
findCirclePink.vi

Vision Processing.vi
Reply With Quote
  #2   Spotlight this post!  
Unread 10-02-2011, 21:22
Nerd_Skywalker's Avatar
Nerd_Skywalker Nerd_Skywalker is offline
Walker of Skies
FRC #1111
Team Role: Animator
 
Join Date: Dec 2010
Rookie Year: 2008
Location: -Classified-
Posts: 42
Nerd_Skywalker is an unknown quantity at this point
Re: Camera Processing Script Causing Obscene Lag

You're having it running in Teleop?

Maybe only have it run whilst a button is being pressed?
__________________
Re-dun-dant adj. 1. See redundant
Reply With Quote
  #3   Spotlight this post!  
Unread 10-02-2011, 22:12
SuperS_5's Avatar
SuperS_5 SuperS_5 is offline
[Certified LabVIEW Developer]
FRC #1219
 
Join Date: Dec 2010
Rookie Year: 2010
Location: Canada
Posts: 140
SuperS_5 will become famous soon enoughSuperS_5 will become famous soon enough
Re: Camera Processing Script Causing Obscene Lag

This sounds like the vision loop is staving other processes of cRIO resources. Use a millisecond wait in the vision loop, specifically in the enabled case. (I typically use between 1-50ms, but that depends on the complexity of the vision code)

PS: After posting, I actually looked that your VI. I am sure it is consuming most of the cRIO's processor, and starving other loops.
__________________
Mike B

Last edited by SuperS_5 : 10-02-2011 at 22:19.
Reply With Quote
  #4   Spotlight this post!  
Unread 11-02-2011, 01:45
mahumnut's Avatar
mahumnut mahumnut is offline
Registered User
FRC #1418 (Vae Victus)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2009
Location: DC area
Posts: 23
mahumnut is an unknown quantity at this point
Re: Camera Processing Script Causing Obscene Lag

Quote:
Originally Posted by SuperS_5 View Post
This sounds like the vision loop is staving other processes of cRIO resources. Use a millisecond wait in the vision loop, specifically in the enabled case. (I typically use between 1-50ms, but that depends on the complexity of the vision code)

PS: After posting, I actually looked that your VI. I am sure it is consuming most of the cRIO's processor, and starving other loops.
There should already be a 100 ms wait timer in the vision processing vi loop. Back when I put it in, it helped a little with the lag, but it is still a major problem, is their any particular reason why you think it is starving other processes, is it the actual steps in my script?
Reply With Quote
  #5   Spotlight this post!  
Unread 11-02-2011, 07:54
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: Camera Processing Script Causing Obscene Lag

I suspect it is that your script takes quite awhile to execute. And putting a delay in parallel will not help if the call is into a DLL marching through pixels. Have you timed it? You may be able to lower the priority of the vision code so that the tele will postpone the vision stuff. You may also need a more CPU efficient way to process the image.

Greg McKaskle
Reply With Quote
  #6   Spotlight this post!  
Unread 11-02-2011, 23:23
SuperS_5's Avatar
SuperS_5 SuperS_5 is offline
[Certified LabVIEW Developer]
FRC #1219
 
Join Date: Dec 2010
Rookie Year: 2010
Location: Canada
Posts: 140
SuperS_5 will become famous soon enoughSuperS_5 will become famous soon enough
Re: Camera Processing Script Causing Obscene Lag

In the code that you posted, the delay was only in the (vision) disabled case. When vision is enabled, that loop is free running. Most of the advanced vision VIs use external code to do their work, but most are in-line processes. (The subVI waits for the processing to complete before returning) Any wait in sequence with the code will slow down that loop, freeing up the processor. In my opinion, the vision loop as a lower priority than actually driving the robot. I didn't mention setting VI priorities last time to keep things simple. Setting the vision VI to a lower priority may help, but other processes may still be impacted. (Other low priority processes, that you may want to use reliably.) I would typically use both a wait primitive, AND priority settings to achieve the desired balance.

I would also take a second look at your image processing, although I didn't see anything too resource intensive there. Maybe you could try using a lower resolution image. While making some videos, we found that even the lowest resolution setting worked fairly well, while greatly reducing processing.

PS: Thanks Greg for reminding me about priorities, and the great march through the pixels.
__________________
Mike B
Reply With Quote
  #7   Spotlight this post!  
Unread 12-02-2011, 01:22
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,579
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Camera Processing Script Causing Obscene Lag

Quote:
Originally Posted by SuperS_5 View Post
In the code that you posted, the delay was only in the (vision) disabled case. When vision is enabled, that loop is free running. Most of the advanced vision VIs use external code to do their work, but most are in-line processes. (The subVI waits for the processing to complete before returning) Any wait in sequence with the code will slow down that loop, freeing up the processor. In my opinion, the vision loop as a lower priority than actually driving the robot. I didn't mention setting VI priorities last time to keep things simple. Setting the vision VI to a lower priority may help, but other processes may still be impacted. (Other low priority processes, that you may want to use reliably.) I would typically use both a wait primitive, AND priority settings to achieve the desired balance.
The get image vi appears to wait until the next image is available using a notifier.
Reply With Quote
  #8   Spotlight this post!  
Unread 12-02-2011, 06:11
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: Camera Processing Script Causing Obscene Lag

The wait for next image will return immediately if the time to process is larger than the time to time to acquire a new image. The first thing I'd do is add timers to the loop to see how often it is running and for how long. I think we'll find that the loop never pauses because there is always another image to process.

Greg McKaskle
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 20:29.

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