Go to Post Theres just something about a big honkin' robot that's irresistible. - seanwitte [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Spotlight this post!  
Unread 27-01-2016, 21:41
SamCarlberg's Avatar
SamCarlberg SamCarlberg is offline
GRIP, WPILib. 2084 alum
AKA: Sam Carlberg
no team
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 42
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: [Vision] Multithreading?

Something like this might work for you:

Code:
// Create a new Timer to schedule vision processing
Timer visionScheduler = new Timer("Vision Scheduler", true);

void doVisionProcessing() {
    // Your vision code here
}

public void autonomousInit() {
    ...
    // Perform vision processing every 50ms, starting in 0ms (i.e. now)
    visionScheduler.scheduleAtFixedRate(new TimerTask() {
            public void run() {
                doVisionProcessing();
            }
        }, 0, 50);
}
Keep in mind that you'll need to do the normal threading stuff like locks/synchronization blocks and declaring shared variables volatile, but that applies for any multithreaded program.
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote
 


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 23:30.

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