Go to Post Let the team grow, let them fail, let them learn and always be ready to lend a helping hand. I think that's the best way to help rookie teams. - Justin Montois [more]
Home
Go Back   Chief Delphi > Technical > Programming
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
  #1   Spotlight this post!  
Unread 23-02-2016, 18:19
cantdecide cantdecide is offline
Registered User
FRC #5773 (YAFL Mechatronics)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2016
Location: Turkey
Posts: 31
cantdecide is an unknown quantity at this point
Our very entertaining experience with network lag, and how we mitigated it

We use OpenCV and Python on a Raspberry Pi to do vision processing, and the script itself works wonders. However, we transmit data over NetworkTables(using the wonderful pynetworktables library; go check it out!), and that intrinsically adds some latency, and when you add Ethernet lag over that, the latency renders our autonomous simply useless. I've seen latencies over 300ms, and at the speed that a robot moves, after 300ms, we're probably way past the goal.

Now, keep in mind, I'm no network engineer, but the way I solved this is by adding an out-of-band signal(using an Arduino in my case) and triggering it from the Pi on startup. A loop runs on the roboRIO which resets an internal time offset every time the DIO line connected to the Arduino is driven high, essentially creating a synchronized timer on both processors. Now that we have shared time, lag compensation is easy.

When sending data from the Pi, I also put the current Pi time and a rough estimate of target velocity across the image(calculated according to last position and time of target) along with coordinate data. When reading data on the roboRIO, the NetworkTables timestamp from the Pi is subtracted from the synchronized timer, and from that we get the amount of total latency between the RIO and the Pi.

Finally, when we multiply the latency by velocity and add that to the coordinate data, we can get a pretty accurate estimation of actual current target location, provided that our robot is rotating at a constant speed.

I know that this may not seem like a lot, but this completely fixed all of our autonomous problems, and was relatively easy for the huge amount of gain. Hopefully, this will help a team out.
 


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:06.

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