Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Wierd roboRIO lag spike (http://www.chiefdelphi.com/forums/showthread.php?t=133360)

abraker 22-01-2015 19:51

Wierd roboRIO lag spike
 
Hi teams!

We are trying to debug encoders to get an accurate reading, and determined that some sort of lag spikes happen randomly. I stripped the loop so that it only checks for a raw value (for debugging purposes), and stops the motor when the value is >=1440 (360 deg rotation using k4X encoding type) and prints the number of milliseconds it took. Most of the time it runs for ~630 ms, but when the random lag spike hits, it runs for anywhere between 700 ms to 800 ms.

Our loop:

Code:

t1.set(0.15);
t2.set(0.15);
while(isAutonomous() && isEnabled()){
  if(encoder.getRaw())>=1440-56){  // it overshoots everytime, so -56 to compensate
      t1.set(0.0);
      t2.set(0.0);
      clock.stop();
      SmartDashboard.putNumber("Timer: ", clock.get());
  }
}


Joe Ross 23-01-2015 15:46

Re: Wierd roboRIO lag spike
 
Does the driver station log show anything when this happens?

abraker 23-01-2015 16:33

Re: Wierd roboRIO lag spike
 
Where do I find the log files?

Team3266Spencer 23-01-2015 16:34

Re: Wierd roboRIO lag spike
 
Where is this code segment located?

abraker 23-01-2015 16:40

Re: Wierd roboRIO lag spike
 
inside
Code:

public void autonomous()
the logs just read "Warning" and "WARNING" messages and nothing else

Edit: The warning are just for events like Driver station loosing communication, and other network communication events probably from reloading the code.

Team3266Spencer 23-01-2015 16:44

Re: Wierd roboRIO lag spike
 
Try putting a
Code:

Timer.delay(0.05);
in the loop. That will reduce the load on the roboRIO.

Edit: Sorry
Code:

Timer.delay(0.005);
is what I meant to put, 50 ms of delay is probably extensive.

abraker 23-01-2015 16:57

Re: Wierd roboRIO lag spike
 
When I put in the timer delay, it's not updating fast enough and overshoots inconsistently.

EDIT: I tried the 0.005 timer delay. It's more consistent, but still hiccups. Every 6-12 times we test it, it overshoots by a lot, somewhere from 100 ms to a second longer overshoot.

Team3266Spencer 23-01-2015 17:05

Re: Wierd roboRIO lag spike
 
When you say it overshoots, are you saying the encoder data is correct but the motors do not respond until 100 ms after they should have stopped?

abraker 23-01-2015 17:09

Re: Wierd roboRIO lag spike
 
Yes the encoder data is correct, and yes the motor randomly stops later than intended.

Team3266Spencer 23-01-2015 17:15

Re: Wierd roboRIO lag spike
 
I don't see any reason in the code for that to happen. I would ensure the encoder is providing proper feedback, maybe adjust oversampling rates, etc. You should also try using a PID loop and see if smarter code can compensate for the lag.

abraker 23-01-2015 17:18

Re: Wierd roboRIO lag spike
 
Note that it happens randomly. Most of the time it does a beautiful 360 and is deadly accurate.


All times are GMT -5. The time now is 11:44.

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