I will not function if you break my heart.
Home
Go Back   Chief Delphi > Competition > Rules/Strategy
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
  #2   Spotlight this post!  
Unread 09-02-2017, 15:18
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 417
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Faster loop scheduling

Code:
int rate = 200; // Hz

private void mySuperFastLoop() {
  while (true) {
    // do some fast stuff
    
    try {
      Thread.sleep(1000 / rate);
    } catch (InterruptedException ex) {}
  }
}

protected void robotInit() {
  Thread superFastLoopThread = new Thread(this::mySuperFastLoop);
  superFastLoopThread.setDaemon(true);
  superFastLoopThread.setName("Custom Super Fast Loop");
  superFastLoopThread.start();
}
What we use fast off-thread loops for:
- Dead reckoning. Integrating gyro angle with encoder distance for approximate field position. We run it at 60 Hz, the update rate of the NavX, for best accuracy
- 775pro monitoring. If close to stall current is detected, it immediately shuts off the motors. This is an important safety control so we don't want it potentially hung up by main thread stuff.
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org

Last edited by euhlmann : 09-02-2017 at 15:22.
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 20:17.

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