Go to Post A clean pit is a happy pit, a clean pit is a controlled pit, a clean pit is a safe pit. - DjAlamose [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-22-2015, 07:51 PM
abraker abraker is offline
Registered User
FRC #0333
 
Join Date: Jan 2015
Location: Brooklyn
Posts: 6
abraker is an unknown quantity at this point
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());
   }
}
Reply With Quote
  #2   Spotlight this post!  
Unread 01-23-2015, 03:46 PM
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,547
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Wierd roboRIO lag spike

Does the driver station log show anything when this happens?
Reply With Quote
  #3   Spotlight this post!  
Unread 01-23-2015, 04:33 PM
abraker abraker is offline
Registered User
FRC #0333
 
Join Date: Jan 2015
Location: Brooklyn
Posts: 6
abraker is an unknown quantity at this point
Re: Wierd roboRIO lag spike

Where do I find the log files?
Reply With Quote
  #4   Spotlight this post!  
Unread 01-23-2015, 04:34 PM
Team3266Spencer's Avatar
Team3266Spencer Team3266Spencer is offline
Team Captain and Lead Programmer
AKA: Spencer Lanman
FRC #3266 (Robots-R-US)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Richmond, Indiana
Posts: 280
Team3266Spencer is an unknown quantity at this point
Re: Wierd roboRIO lag spike

Where is this code segment located?
__________________
2012: Buckeye Regional, Queen City Regional, Human Player
2013: Queen City Regional, Buckeye Regional, Crossroads Regional
Shooter Operator
2014: Crossroads Regional, Queen City Regional
Catapult Operator
2015: Georgia Southern Classic Regional (Winner), Queen City Regional
Chainsaw Operator
Want to talk? TeamSpeak: team3266.noip.me
Reply With Quote
  #5   Spotlight this post!  
Unread 01-23-2015, 04:40 PM
abraker abraker is offline
Registered User
FRC #0333
 
Join Date: Jan 2015
Location: Brooklyn
Posts: 6
abraker is an unknown quantity at this point
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.

Last edited by abraker : 01-23-2015 at 04:44 PM.
Reply With Quote
  #6   Spotlight this post!  
Unread 01-23-2015, 04:44 PM
Team3266Spencer's Avatar
Team3266Spencer Team3266Spencer is offline
Team Captain and Lead Programmer
AKA: Spencer Lanman
FRC #3266 (Robots-R-US)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Richmond, Indiana
Posts: 280
Team3266Spencer is an unknown quantity at this point
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.
__________________
2012: Buckeye Regional, Queen City Regional, Human Player
2013: Queen City Regional, Buckeye Regional, Crossroads Regional
Shooter Operator
2014: Crossroads Regional, Queen City Regional
Catapult Operator
2015: Georgia Southern Classic Regional (Winner), Queen City Regional
Chainsaw Operator
Want to talk? TeamSpeak: team3266.noip.me

Last edited by Team3266Spencer : 01-23-2015 at 04:57 PM. Reason: Correction
Reply With Quote
  #7   Spotlight this post!  
Unread 01-23-2015, 04:57 PM
abraker abraker is offline
Registered User
FRC #0333
 
Join Date: Jan 2015
Location: Brooklyn
Posts: 6
abraker is an unknown quantity at this point
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.

Last edited by abraker : 01-23-2015 at 05:01 PM.
Reply With Quote
  #8   Spotlight this post!  
Unread 01-23-2015, 05:05 PM
Team3266Spencer's Avatar
Team3266Spencer Team3266Spencer is offline
Team Captain and Lead Programmer
AKA: Spencer Lanman
FRC #3266 (Robots-R-US)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Richmond, Indiana
Posts: 280
Team3266Spencer is an unknown quantity at this point
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?
__________________
2012: Buckeye Regional, Queen City Regional, Human Player
2013: Queen City Regional, Buckeye Regional, Crossroads Regional
Shooter Operator
2014: Crossroads Regional, Queen City Regional
Catapult Operator
2015: Georgia Southern Classic Regional (Winner), Queen City Regional
Chainsaw Operator
Want to talk? TeamSpeak: team3266.noip.me
Reply With Quote
  #9   Spotlight this post!  
Unread 01-23-2015, 05:09 PM
abraker abraker is offline
Registered User
FRC #0333
 
Join Date: Jan 2015
Location: Brooklyn
Posts: 6
abraker is an unknown quantity at this point
Re: Wierd roboRIO lag spike

Yes the encoder data is correct, and yes the motor randomly stops later than intended.
Reply With Quote
  #10   Spotlight this post!  
Unread 01-23-2015, 05:15 PM
Team3266Spencer's Avatar
Team3266Spencer Team3266Spencer is offline
Team Captain and Lead Programmer
AKA: Spencer Lanman
FRC #3266 (Robots-R-US)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Richmond, Indiana
Posts: 280
Team3266Spencer is an unknown quantity at this point
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.
__________________
2012: Buckeye Regional, Queen City Regional, Human Player
2013: Queen City Regional, Buckeye Regional, Crossroads Regional
Shooter Operator
2014: Crossroads Regional, Queen City Regional
Catapult Operator
2015: Georgia Southern Classic Regional (Winner), Queen City Regional
Chainsaw Operator
Want to talk? TeamSpeak: team3266.noip.me
Reply With Quote
  #11   Spotlight this post!  
Unread 01-23-2015, 05:18 PM
abraker abraker is offline
Registered User
FRC #0333
 
Join Date: Jan 2015
Location: Brooklyn
Posts: 6
abraker is an unknown quantity at this point
Re: Wierd roboRIO lag spike

Note that it happens randomly. Most of the time it does a beautiful 360 and is deadly accurate.
Reply With Quote
Reply


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 09:03 AM.

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