![]() |
[Vision] Multithreading?
What is the best way to have a vision loop that constantly updates numbers, but with a short sleep period but not hinder the normal teleop loop?
If I want to update the numbers every half second or so is there a way I can do that without making the whole teleop loop wait? I've looked at Runnables, but is there an easier way to do this? |
Re: [Vision] Multithreading?
as long as you're sure that this is what you want to do..
Code:
new Thread("Vision Processing Thread"){public void run(){ |
Re: [Vision] Multithreading?
Quote:
|
Re: [Vision] Multithreading?
Something like this might work for you:
Code:
|
Re: [Vision] Multithreading?
Otherwise you could put it in a periodic method.
|
Re: [Vision] Multithreading?
We have a utility in our github to do this. Send an e-mail to gixxy if you have any questions (he doesn't check CD daily).
|
Re: [Vision] Multithreading?
Code:
Thread cameraThread = new Thread()Code:
cameraThread.sleep(timeInMillis);Code:
cameraThread.stop(); //not sure if this is depreciated |
Re: [Vision] Multithreading?
We have a vision target module in our library that will take care of the multi-threading stuff. It spawns a separate thread and will process each frame to look for objects for the specified criteria. If a new frame is processed, the new result will overwrite the old one. In other words, we always have the latest result cached. If the main robot thread wants to look for "targets", it gets the cached result from the vision targeting thread.
|
Re: [Vision] Multithreading?
We have it running as a separate program on the Driver Station. We use Network Tables to communicate with the RoboRio. It grabs the same picture that is being displayed on the DS for the driver.
when "picture" is 0, the vision program does nothing. When "picture" is 1, it starts vision processing, and changes the value to "2" to indicate it is working. When it is done calculating, it sets "Angle", and "Distance", and changes "picture" back to 0. On the RoboRio, it waits for "picture" to go back to "0". when it sees that, it takes "Angle" and "Distance" and drives there (using NavX). Rinse, repeat, until Angle and Distance are close enough to shoot. |
| All times are GMT -5. The time now is 17:31. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi