Go to Post Be afraid. Be very, very, graciously afraid. - Rich Kressly [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 06-02-2012, 19:52
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

UDP is a very basic communications protocol, quite good for sending small amounts of data in a repeating fashion. If you find yourself with more data than will fit in UDP ( about 1500 bytes is typical ), I'd suggest using TCP.

TCP will automatically break a big packet into smaller ones, and reassemble on the read end. It ignores duplicates, checks for missing elements and corrupted elements, and puts sub packets back in order if they happen to arrive out of order. There are other difference too, but the camera and other HTTP sessions are based on TCP.

The error you received was indicating that the buffer was bigger than the UDP limit. When the issue looked cleared up, it was just that you were discarding the error.

As I pointed out in the other thread, there is no reason to send an image. The dashboard already displays it. Why send it again?

Greg McKaskle
Reply With Quote
  #2   Spotlight this post!  
Unread 07-02-2012, 17:09
Pirate programe's Avatar
Pirate programe Pirate programe is offline
Registered User
FRC #0354
 
Join Date: Jan 2012
Location: Queens,NY
Posts: 53
Pirate programe is an unknown quantity at this point
Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

How big is the UDP buffer? Because all that I'm sending is the Target Info array from the vision code flattened to a string...

Last edited by Pirate programe : 07-02-2012 at 17:14.
Reply With Quote
  #3   Spotlight this post!  
Unread 07-02-2012, 20:40
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

I believe the UDP limit is somewhat dependent on the devices being used, but in this instance, I think 1500 bytes or so.

Greg McKaskle
Reply With Quote
  #4   Spotlight this post!  
Unread 08-02-2012, 17:24
Pirate programe's Avatar
Pirate programe Pirate programe is offline
Registered User
FRC #0354
 
Join Date: Jan 2012
Location: Queens,NY
Posts: 53
Pirate programe is an unknown quantity at this point
Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

The TCP code in the screenshot is giving me the following error:

Quote:
Error 56 in TCP Write in Dashboard Main.Vi

Possible reason(s); The network operation exceeded the user specified or system time limit.
I can only assume this means it's timing out, but why would it do that? It seems as if all of the parts are in the right place.
Attached Thumbnails
Click image for larger version

Name:	scrncap.png
Views:	145
Size:	5.7 KB
ID:	11802  
Reply With Quote
  #5   Spotlight this post!  
Unread 28-02-2012, 00:11
Bendito's Avatar
Bendito Bendito is offline
Registered User
AKA: Benjamin LaRoche
FTC #7837 (The Thunder Colts)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2011
Location: Dorr, MI
Posts: 13
Bendito is an unknown quantity at this point
Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

This thread has been quite helpful. I am still somewhat stuck with an issue on the cRIO crashing when I send UDP to it. I suspect it has something to do with the buffers, but if anyone has helpful advice, I'm open to it!
Attached Files
File Type: zip NetworkcRIO.zip (52.0 KB, 12 views)
File Type: zip Screenshots.zip (57.0 KB, 10 views)
File Type: zip 2012 Dashboard ProjectVisionProcessor.zip (315.3 KB, 13 views)
Reply With Quote
  #6   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
  #7   Spotlight this post!  
Unread 28-02-2012, 08:21
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

I didn't run your code yet, but looking at the screenshots, it does look like you are only reading the udp data five times a second, pretty slow. But you shouldn't crash the cRIO doing that. What sort of crash is it?

Greg McKaskle
Reply With Quote
  #8   Spotlight this post!  
Unread 28-02-2012, 15:39
Doug Norman's Avatar
Doug Norman Doug Norman is offline
Registered User
no team (National Instruments)
Team Role: Engineer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Austin, TX
Posts: 137
Doug Norman will become famous soon enoughDoug Norman will become famous soon enough
Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

Quote:
Originally Posted by Bendito View Post
This thread has been quite helpful. I am still somewhat stuck with an issue on the cRIO crashing when I send UDP to it. I suspect it has something to do with the buffers, but if anyone has helpful advice, I'm open to it!
When you say crash - exactly what happens? If you can reproduce a crash with a simplified program, please contact National Instruments via our FRC forum. We can have application engineers look into it.
__________________
Doug Norman
National Instruments
Reply With Quote
  #9   Spotlight this post!  
Unread 28-02-2012, 20:55
marccenter's Avatar
marccenter marccenter is offline
Registered User
FRC #3548 (RoboRavens2)
Team Role: Coach
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Royal Oak
Posts: 406
marccenter has a spectacular aura aboutmarccenter has a spectacular aura about
Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

CD,
Man, most of this stuff is over my head. Is there a simple example somewhere to show how to display a PWM channel, Joystick Input, or global variable on the Dashboard?
__________________
Marc Center
FIRST FRC Mentor/Coach - Team 3548 Royal Oak RoboRavens#2 - on Sabbatical 2017 season
marc.center@gmail.com
Mobile: 248-255-7377
Reply With Quote
  #10   Spotlight this post!  
Unread 28-02-2012, 21:05
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,833
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

There is an example in the Tutorials that come with LabVIEW.
From the Getting Started window, look at
Tutorials -> Tutorial 7 - Integrating Examples into Robot Code
Then page down to Part 2 and it gives a step-by-step using a gyro output as an example.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #11   Spotlight this post!  
Unread 28-02-2012, 22:57
Bendito's Avatar
Bendito Bendito is offline
Registered User
AKA: Benjamin LaRoche
FTC #7837 (The Thunder Colts)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2011
Location: Dorr, MI
Posts: 13
Bendito is an unknown quantity at this point
Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

Quote:
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.
Thank you, I fixed this, and created a much more simplified communication system. It actually works flawlessly now (even through repeated power ups/downs between robot and driverstation) I have some screenshots of it included.

Quote:
When you say crash - exactly what happens? If you can reproduce a crash with a simplified program, please contact National Instruments via our FRC forum. We can have application engineers look into it.
The crash that occurs was happening whenever I was trying to debug the robot through running the robot program while still in labview with probes set up. It seems that when the driverstation tries to connect with the robot, it boots off labview's connection with the cRIO. A "Connection with the cRIO was lost" would appear, and there would be no way to put more code on without closing the driverstation. This was causing me to think it was crashing, and causing a lot of hair pulling in the debugging process, but was eventually figured out.
Attached Thumbnails
Click image for larger version

Name:	[Dashboard Main.vi] Block Diagram on 2012 Dashboard ProjectVisionPro.png
Views:	197
Size:	28.6 KB
ID:	12158  Click image for larger version

Name:	UDPReceiveRun.vi Block Diagram _2012-02-28_22-50-50.png
Views:	121
Size:	13.9 KB
ID:	12157  
Reply With Quote
  #12   Spotlight this post!  
Unread 29-02-2012, 06:36
marccenter's Avatar
marccenter marccenter is offline
Registered User
FRC #3548 (RoboRavens2)
Team Role: Coach
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Royal Oak
Posts: 406
marccenter has a spectacular aura aboutmarccenter has a spectacular aura about
Question Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

Thanks Mark for pointing me to the right section. One observation and one question remains.

Observation - It may be implied or understood, however, in order to have the Dashboard Main.vi become updated with the changes shown in the tutorial I found myself creating my own dashboard project on the classmate and then manually moving the 3 files created by the dashboard project (C:\Users\developer\documents\Labview Data\builds|FRC Dashboard Project|FRC PC Dashboard) to the C:\Program Files\FRCDashboard subdirectory in order for the classmate to find the new Dashboard Main.vi (did I rename the two original files in the directory late last night before copying?).

Question: I am trying to extend the example to multiple pieces of data rather than just one by trying to use the bundle function in the Dashboard Main.vi function but it doesn't seem to take it. I was able to bundle, flatten to string and input this to the Driver station Set User Data HI function inside my robot project code. Should I be able to unpack this in my new dashboard project or is the Data Hi function simplistic?
__________________
Marc Center
FIRST FRC Mentor/Coach - Team 3548 Royal Oak RoboRavens#2 - on Sabbatical 2017 season
marc.center@gmail.com
Mobile: 248-255-7377
Reply With Quote
  #13   Spotlight this post!  
Unread 29-02-2012, 09:01
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

Quote:
Originally Posted by marccenter View Post
I was able to bundle, flatten to string and input this to the Driver station Set User Data HI function inside my robot project code. Should I be able to unpack this in my new dashboard project or is the Data Hi function simplistic?
You can certainly do what you are suggesting. When you do the "unflatten" operation in the Dashboard, you need to show it an example of the data type you want it to create. That means you need either a bundle constant that matches the arrangement of the bundle you created in the robot project, or a typedef that you can share between the robot and dashboard projects so the robot code can do a bundle by name instead of just bundling raw data.
Reply With Quote
  #14   Spotlight this post!  
Unread 29-02-2012, 09:05
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,833
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

Copying the Dashboard files to FRC Dashboard works, you also have the options of changing the build destination to FRC Dashboard so it always gets put there when you build, or changing the Driver Station .ini file to point to your dashboard location.

Here is an example of some quick Dashboard diagnostics looked at from both the robot and the PC side of things. This is slapped together, so take it as development code. The elements are in the order they were added to the cluster on the robot side. I recreate an indicator "358 Custom data" whenever I add or remove elements, then copy that to the Dashboard side to define the order/types of elements in the cluster.
In the final robot I'd create a TypeDef to define each data element. That gives everything a name making it easier to digest and clearer to work with.
Attached Thumbnails
Click image for larger version

Name:	Dashboard-data-robotside.png
Views:	88
Size:	83.3 KB
ID:	12161  Click image for larger version

Name:	Dashboard-data-PCside.png
Views:	83
Size:	47.9 KB
ID:	12162  
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #15   Spotlight this post!  
Unread 29-02-2012, 19:34
marccenter's Avatar
marccenter marccenter is offline
Registered User
FRC #3548 (RoboRavens2)
Team Role: Coach
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Royal Oak
Posts: 406
marccenter has a spectacular aura aboutmarccenter has a spectacular aura about
Smile Re: Transmitting data to the cRIO from the Driver's station via TCP/UDP

Alan and Mark,
Alan - Thanks for commenting. I understand what you are saying, just need to fumble my way through Labview to make it work.
Mark - Jackpot! That's exactly the example I was looking to find. Now, time to fight with Labview again to make it work. Is there a way to bookmark/highlight that example in our documentation - great job!
BTW, can you point to an example about the 358 Custom Data vi object? This is a new function for me to work with. Mine is not shaded pink yet.
__________________
Marc Center
FIRST FRC Mentor/Coach - Team 3548 Royal Oak RoboRavens#2 - on Sabbatical 2017 season
marc.center@gmail.com
Mobile: 248-255-7377

Last edited by marccenter : 29-02-2012 at 19:44. Reason: completeness
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 20:43.

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