Go to Post “I hope you all had a good weekend. If you didn’t you can try again in five days.” -Honors Debate teacher - Joe J. [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 01-02-2017, 09:31
flemdogmillion's Avatar
flemdogmillion flemdogmillion is online now
Programmer, Builder, Driver...
FRC #3007
 
Join Date: Nov 2016
Rookie Year: 2015
Location: Minnesota
Posts: 125
flemdogmillion will become famous soon enoughflemdogmillion will become famous soon enough
PSA: Enable Vision Race Condition

Just solved a really sneaky race condition last night, so I thought I would do something so other people don't fall in that trap and blame their vision slowness on "LabVIEW is slow."

In Robot Main.vi, there is a bit of code shown in the attached image that applies what is effectively a constant (an unwired control) to the global variable Enable Vision. You need to remove this bit of code if you are going to at all use this variable, say, to turn a ring LED on or off. If you do not, you can easily miss this, since you're "not supposed to edit Robot Main.vi." I certainly missed it.

This race condition is characterized by your vision code taking almost exactly 50 ms to loop every time, while it appears to take about 300 ms to update the result variables. As a result, it pretty much just looks like it's running slow.

Happy coding!
Attached Thumbnails
Click image for larger version

Name:	EnableVisionRace.PNG
Views:	46
Size:	2.1 KB
ID:	21671  
__________________
Team 4506: 2015-2016
Team 3007: 2017

Jack of all trades except C++ & Java
Reply With Quote
  #2   Spotlight this post!  
Unread 01-02-2017, 14:28
Hess1113's Avatar
Hess1113 Hess1113 is online now
Grab a computer and code it up!
AKA: Christopher Hess
FRC #0291 (Creativity In Action)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2017
Location: Erie, PA
Posts: 23
Hess1113 is an unknown quantity at this point
Re: PSA: Enable Vision Race Condition

I found that the enable vision variable in Global Data.vi (or something like that) is false unless you press the button and save it as true.
Attached Thumbnails
Click image for larger version

Name:	Sketch.png
Views:	17
Size:	513.2 KB
ID:	21672  
__________________
Christopher Hess
Co-Lead Programmer
Webmaster
FRC-Team 291 CIA
www.team291.com
Reply With Quote
  #3   Spotlight this post!  
Unread 01-02-2017, 14:35
flemdogmillion's Avatar
flemdogmillion flemdogmillion is online now
Programmer, Builder, Driver...
FRC #3007
 
Join Date: Nov 2016
Rookie Year: 2015
Location: Minnesota
Posts: 125
flemdogmillion will become famous soon enoughflemdogmillion will become famous soon enough
Re: PSA: Enable Vision Race Condition

Quote:
Originally Posted by Hess1113 View Post
I found that the enable vision variable in Global Data.vi (or something like that) is false unless you press the button and save it as true.
You can still write code that manipulates the variable, causing it to change.
__________________
Team 4506: 2015-2016
Team 3007: 2017

Jack of all trades except C++ & Java
Reply With Quote
  #4   Spotlight this post!  
Unread 01-02-2017, 14:41
Hess1113's Avatar
Hess1113 Hess1113 is online now
Grab a computer and code it up!
AKA: Christopher Hess
FRC #0291 (Creativity In Action)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2017
Location: Erie, PA
Posts: 23
Hess1113 is an unknown quantity at this point
Re: PSA: Enable Vision Race Condition

Quote:
Originally Posted by flemdogmillion View Post
You can still write code that manipulates the variable, causing it to change.
Or replace any instance of the "Enable Vision" variable with a true Boolean.
__________________
Christopher Hess
Co-Lead Programmer
Webmaster
FRC-Team 291 CIA
www.team291.com
Reply With Quote
  #5   Spotlight this post!  
Unread 01-02-2017, 14:46
flemdogmillion's Avatar
flemdogmillion flemdogmillion is online now
Programmer, Builder, Driver...
FRC #3007
 
Join Date: Nov 2016
Rookie Year: 2015
Location: Minnesota
Posts: 125
flemdogmillion will become famous soon enoughflemdogmillion will become famous soon enough
Re: PSA: Enable Vision Race Condition

Quote:
Originally Posted by Hess1113 View Post
Or replace any instance of the "Enable Vision" variable with a true Boolean.
If you do that while using the variable to simultaneously enable vision code and turn on a ring light, the ring light will be always on, which is not allowed.
__________________
Team 4506: 2015-2016
Team 3007: 2017

Jack of all trades except C++ & Java
Reply With Quote
  #6   Spotlight this post!  
Unread 01-02-2017, 17:27
JeffB JeffB is online now
Registered User
FRC #5052 (RoboLobos)
Team Role: Mentor
 
Join Date: Apr 2015
Rookie Year: 2014
Location: Austin
Posts: 64
JeffB is a splendid one to beholdJeffB is a splendid one to beholdJeffB is a splendid one to beholdJeffB is a splendid one to beholdJeffB is a splendid one to beholdJeffB is a splendid one to beholdJeffB is a splendid one to behold
Re: PSA: Enable Vision Race Condition

Wouldn't it make more sense to create a variable to control your ring light rather than alter the way it's already functioning to control the vision system as a whole?
__________________
Reply With Quote
  #7   Spotlight this post!  
Unread 01-02-2017, 17:37
thatnameistaken thatnameistaken is offline
Registered User
AKA: Joshua Johnston
FRC #2191 (Flux Core)
Team Role: College Student
 
Join Date: Oct 2012
Rookie Year: 2013
Location: Hamilton, NJ
Posts: 62
thatnameistaken is on a distinguished road
Re: PSA: Enable Vision Race Condition

Quote:
Originally Posted by flemdogmillion View Post
If you do that while using the variable to simultaneously enable vision code and turn on a ring light, the ring light will be always on, which is not allowed.
Per which rule? I'm not seeing it.
Reply With Quote
  #8   Spotlight this post!  
Unread 02-02-2017, 09:52
flemdogmillion's Avatar
flemdogmillion flemdogmillion is online now
Programmer, Builder, Driver...
FRC #3007
 
Join Date: Nov 2016
Rookie Year: 2015
Location: Minnesota
Posts: 125
flemdogmillion will become famous soon enoughflemdogmillion will become famous soon enough
Re: PSA: Enable Vision Race Condition

Quote:
Originally Posted by thatnameistaken View Post
Per which rule? I'm not seeing it.
R07-M.
Quote:
Originally Posted by JeffB View Post
Wouldn't it make more sense to create a variable to control your ring light rather than alter the way it's already functioning to control the vision system as a whole?
It seems clumsy to leave your vision code, which uses a lot of resources, running when it's not in use. Just my opinion, so I followed it.
__________________
Team 4506: 2015-2016
Team 3007: 2017

Jack of all trades except C++ & Java
Reply With Quote
  #9   Spotlight this post!  
Unread 02-02-2017, 10:03
Bkeeneykid's Avatar
Bkeeneykid Bkeeneykid is offline
#wheatcoastneatcoast
AKA: Devin Keeney
FRC #1982 (Cougar Robotics); Season Long Fantasy FIRST (F3)
Team Role: Leadership
 
Join Date: Feb 2015
Rookie Year: 2015
Location: Lenexa, Kansas
Posts: 367
Bkeeneykid has much to be proud ofBkeeneykid has much to be proud ofBkeeneykid has much to be proud ofBkeeneykid has much to be proud ofBkeeneykid has much to be proud ofBkeeneykid has much to be proud ofBkeeneykid has much to be proud ofBkeeneykid has much to be proud ofBkeeneykid has much to be proud of
Re: PSA: Enable Vision Race Condition

Quote:
Originally Posted by flemdogmillion View Post
R07-M.

R07-M really depends on which light source you're using. If you're using something with a 300 lumen output, you're probably going to have a bad time, but if you're simply just using the LED ring in FC or a smaller LED that was mentioned in another thread, I doubt anyone will rule that illegal.

Please note: I am not an inspector. Please at least run it though a spike just in case. The ability to be able to turn it off will not be a bad choice at all.
__________________

F4 Network Website Designer

2010-2012: A Whole Buncha FLL Teams; Team Spirit, Gracious Professionalism Award winner
2015-Current: FRC 1982, Captain, Electrical Lead
Beginning FIRST Volunteer

Moderator on the FIRSTwiki
Reply With Quote
  #10   Spotlight this post!  
Unread Yesterday, 11:35
JeffB JeffB is online now
Registered User
FRC #5052 (RoboLobos)
Team Role: Mentor
 
Join Date: Apr 2015
Rookie Year: 2014
Location: Austin
Posts: 64
JeffB is a splendid one to beholdJeffB is a splendid one to beholdJeffB is a splendid one to beholdJeffB is a splendid one to beholdJeffB is a splendid one to beholdJeffB is a splendid one to beholdJeffB is a splendid one to behold
Re: PSA: Enable Vision Race Condition

Quote:
Originally Posted by flemdogmillion View Post
R07-M.

It seems clumsy to leave your vision code, which uses a lot of resources, running when it's not in use. Just my opinion, so I followed it.
I'd imagine you're planning on your team operating in the portions of the field clouded by one, or both, airships. Is your vision code not streaming a feed to your drivers to help them drive the robot in these cases?
__________________
Reply With Quote
  #11   Spotlight this post!  
Unread Yesterday, 13:52
flemdogmillion's Avatar
flemdogmillion flemdogmillion is online now
Programmer, Builder, Driver...
FRC #3007
 
Join Date: Nov 2016
Rookie Year: 2015
Location: Minnesota
Posts: 125
flemdogmillion will become famous soon enoughflemdogmillion will become famous soon enough
Re: PSA: Enable Vision Race Condition

Quote:
Originally Posted by JeffB View Post
I'd imagine you're planning on your team operating in the portions of the field clouded by one, or both, airships. Is your vision code not streaming a feed to your drivers to help them drive the robot in these cases?
The streaming code is a self-looping VI that starts when Vision Processing.vi initializes. It is separate from the actual vision loop that you write. It lies far outside the Enable Vision case structure.
__________________
Team 4506: 2015-2016
Team 3007: 2017

Jack of all trades except C++ & Java

Last edited by flemdogmillion : Yesterday at 13:55.
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 10:52.

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