View Single Post
  #17   Spotlight this post!  
Unread 28-02-2012, 08:14
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

A couple of TCP and UDP tips and comments:

-A UDP packet is designed to fit in one Ethernet frame, limiting it to 1500bytes minus UDP headers. I believe a UDP header is 8 bytes, but don't quote me on that

-TCP is designed to send streams of bytes instead of packetized data. The disadvantage to this is that the sending application must explicitly manage the send buffer and force TCP to send it all of the bytes, and the receiving application must manage packet starts/ends.

-TCP is also a reliable medium, with error checking and retransmission. This is usually a bad thing if you care more about getting the data fast than getting all of it (if you miss a targeting packet, you will get another one in about 50ms, so you just ignore it).

-UDP is a better choice for this application due to the speed and packet-oriented nature.


-The UDP listener should have errors trapped and a timeout set to a fairly low number (I use 1000ms) - I use trapped errors as a source of determining if I actually should unbundle the packet and use it

-The UDP listener should exist in its own thread (While loop) throttled by nothing other than itself - There should be no waits. The UDP listener will block for new packets, and if you are behind in receiving packets then it's a bad thing.

-Send the smallest packets possible - Do all target filtering and multiple target analysis (stuff that works with arrays of targets) on the laptop, and send a single target coordinate to the robot over UDP - This keeps the packet size under the limit and non-variable.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
Reply With Quote