Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   PSA: Enable Vision Race Condition (http://www.chiefdelphi.com/forums/showthread.php?t=154572)

flemdogmillion 01-02-2017 09:31

PSA: Enable Vision Race Condition
 
1 Attachment(s)
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!

Hess1113 01-02-2017 14:28

Re: PSA: Enable Vision Race Condition
 
1 Attachment(s)
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.

flemdogmillion 01-02-2017 14:35

Re: PSA: Enable Vision Race Condition
 
Quote:

Originally Posted by Hess1113 (Post 1639115)
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.

Hess1113 01-02-2017 14:41

Re: PSA: Enable Vision Race Condition
 
Quote:

Originally Posted by flemdogmillion (Post 1639123)
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.

flemdogmillion 01-02-2017 14:46

Re: PSA: Enable Vision Race Condition
 
Quote:

Originally Posted by Hess1113 (Post 1639126)
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.

JeffB 01-02-2017 17:27

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?

thatnameistaken 01-02-2017 17:37

Re: PSA: Enable Vision Race Condition
 
Quote:

Originally Posted by flemdogmillion (Post 1639131)
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.

flemdogmillion 02-02-2017 09:52

Re: PSA: Enable Vision Race Condition
 
Quote:

Originally Posted by thatnameistaken (Post 1639220)
Per which rule? I'm not seeing it.

R07-M.
Quote:

Originally Posted by JeffB (Post 1639215)
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.

Bkeeneykid 02-02-2017 10:03

Re: PSA: Enable Vision Race Condition
 
Quote:

Originally Posted by flemdogmillion (Post 1639414)
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.

JeffB 07-02-2017 11:35

Re: PSA: Enable Vision Race Condition
 
Quote:

Originally Posted by flemdogmillion (Post 1639414)
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?

flemdogmillion 07-02-2017 13:52

Re: PSA: Enable Vision Race Condition
 
Quote:

Originally Posted by JeffB (Post 1641582)
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.


All times are GMT -5. The time now is 04:56.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi