Go to Post Its always good to read the rules yourself rather than listen to "word of mouth" rules. - Killraine [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-02-2012, 15:04
Wildcats1378 Wildcats1378 is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: hawaii
Posts: 93
Wildcats1378 is an unknown quantity at this point
Sending Data from Dashboard to Robot?

Hey Chief Delphi,

Head Programmer from 3878 here.

I want to be able to send a number value set by a control on the dashboard to be usable in Teleop.vi on our robot. I want the ability to set a motor's speed through the dashboard. I was thinking of using UDP to send the numeric data to the robot, but I do not know how I would go about such a task. How would I retrieve the data on the robot (possibly using Periodic Tasks?) and be able to access it in Teleop?

This is really stumping me. Could someone help us with this?

Thanks very much,
Chris
Team 3787
Reply With Quote
  #2   Spotlight this post!  
Unread 10-02-2012, 15:06
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,114
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Sending Data from Dashboard to Robot?

Try this thread.
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
Reply With Quote
  #3   Spotlight this post!  
Unread 10-02-2012, 15:19
Wildcats1378 Wildcats1378 is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: hawaii
Posts: 93
Wildcats1378 is an unknown quantity at this point
Re: Sending Data from Dashboard to Robot?

I had already seen this thread and found it very helpful. Thanks anyway.

What I need help with receiving the data and processing it properly on the cRIO.
Reply With Quote
  #4   Spotlight this post!  
Unread 10-02-2012, 15:27
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,114
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Sending Data from Dashboard to Robot?

Data will be sent (via UDP/TCP) in string form. You'll have to use flatten to string and unflatten from string to, well, flatten and unflatten your data from a string. You'll have to supply the desired datatype when you unflatten (i.e. a constant that represents the cluster you've flattened). See the attached VIs in this post to see what I mean. Then, once you get your data from the string, you can do whatever you need to with it - just as if it was any other input to your robot.
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
Reply With Quote
  #5   Spotlight this post!  
Unread 10-02-2012, 16:21
Wildcats1378 Wildcats1378 is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: hawaii
Posts: 93
Wildcats1378 is an unknown quantity at this point
Re: Sending Data from Dashboard to Robot?

And what if it's a number from a slider? What I did was I converted it into a string using the Decimal Number to String and then flattened it, and sent that. I didn't use a constant. What I was wondering was where should I put the receive stuff in my robot code? I want to access the data in Teleop, but I don't think that is where the Open and Close should go. That's what I was wondering about.

Thanks very much,
Chris
Team 3878
Reply With Quote
  #6   Spotlight this post!  
Unread 10-02-2012, 16:48
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,114
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Sending Data from Dashboard to Robot?

Actually, you can flatten the double output from the slider to a string, and when you unflatten it, wire a double constant to the unflatten VI (to tell LV what datatype out you want).

I would probably put the UDP listener in Periodic Tasks.vi, so it won't slow down your other code. You're also going to want to wire a timeout to UDP read (make it small: ~50 ms) so that your code won't hang there. You can open/close your references inside Periodic Tasks (but outside of a while loop) and put your listener code inside a while loop.
Attached Thumbnails
Click image for larger version

Name:	udp read.png
Views:	67
Size:	15.0 KB
ID:	11837  
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
Reply With Quote
  #7   Spotlight this post!  
Unread 10-02-2012, 17:03
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: Sending Data from Dashboard to Robot?

Using TCP has been giving us a whole strong problems with no apparent cause or solution, and UDP's buffer size is too small for the data we want to send.

The code in the second thumbnail is in the PC Dashboard, and the first's from Periodic Tasks.vi. It seems like we've conformed with the proper way of setting up a TCP connection, but we've been getting timeout errors, corrupt data structure errors, error 62, among other things.

Is there a flaw in the code somewhere? Do I need to adjust some settings somewhere?
Attached Thumbnails
Click image for larger version

Name:	scrncap.png
Views:	45
Size:	12.4 KB
ID:	11838  Click image for larger version

Name:	scrncap1.png
Views:	43
Size:	12.1 KB
ID:	11839  
Reply With Quote
  #8   Spotlight this post!  
Unread 10-02-2012, 17:20
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,114
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Sending Data from Dashboard to Robot?

Quote:
Originally Posted by Pirate programe View Post
Is there a flaw in the code somewhere? Do I need to adjust some settings somewhere?
I'm not sure about the code you posted; it looks fine to me - how do you open the connections?

I think the best way for you to tackle your problem is to use UDP and split the data up into multiple packets. For an example of this, look in Build DashBoard Data.vi (VI snippet attached). You see how it rotates through sending all the data in 50 iteration cycles. The first 15 send analog data, digital data is sent on 20 and 30, and solenoid data on 40. This process repeats, and that's how the dashboard sends lots of information over UDP.
Attached Thumbnails
Click image for larger version

Name:	build db data.png
Views:	48
Size:	105.1 KB
ID:	11841  
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
Reply With Quote
  #9   Spotlight this post!  
Unread 10-02-2012, 17:34
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: Sending Data from Dashboard to Robot?

Quote:
I'm not sure about the code you posted; it looks fine to me - how do you open the connections?
We open them with the robot IP, 10.te.am.2, and the port number 1180. Is that wrong? It seems like there are a lot of things that are semantically and logically correct but don't work for unseen reasons this year...

I think I'd prefer to make this TCP connection work than start using another completely different code, only to have it not work and then need to debug it again... but I'll give it a try.

EDIT: And I'm not sure that would even work. How would I reassemble the data on the other side?

ANOTHER EDIT BECAUSE BUMPS ARE BAD: It seems that UDP isn't having much of a problem sending information anymore, as I'm not getting the internal message buffer error anymore, but the UDP Read.vi seems to be timing out without receiving any information.

Last edited by Pirate programe : 10-02-2012 at 19:15. Reason: slow responders
Reply With Quote
  #10   Spotlight this post!  
Unread 10-02-2012, 20:26
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: Sending Data from Dashboard to Robot?

First off, that is quite the error message, but to answer the question.

It looks to me like the flatten and unflatten nodes do not match. You turned off the prepend size on one and left it unwired and on on the other. My suggestion would be to delete the False constant and leave it default. The case where you decide not to send size info is when it is a fixed amount in the protocol and the size is just extra overhead.

Kinda like in the other threads about comms, rather than delay your read loop, you can just let the read control the speed of communications. If you aren't careful, your read gets a little behind and cannot catch up.

I can't see a delay in the write loop, but hopefully something throttles how often it sends data.

Greg McKaskle
Reply With Quote
  #11   Spotlight this post!  
Unread 10-02-2012, 20:32
Wildcats1378 Wildcats1378 is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: hawaii
Posts: 93
Wildcats1378 is an unknown quantity at this point
Re: Sending Data from Dashboard to Robot?

Okay, Thanks guys! It works great!

Just one problem, I can't get the unflattened, unbundled data from Periodic Tasks to Teleop. I tried some things such as variables and it didn't send properly. Can anyone help?
Reply With Quote
  #12   Spotlight this post!  
Unread 10-02-2012, 20:47
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: Sending Data from Dashboard to Robot?

I'm not sure what to do. What sort of problem? Are you sure that the value going to the variable write is the correct one?

Greg McKaskle
Reply With Quote
  #13   Spotlight this post!  
Unread 10-02-2012, 20:51
Wildcats1378 Wildcats1378 is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: hawaii
Posts: 93
Wildcats1378 is an unknown quantity at this point
Re: Sending Data from Dashboard to Robot?

Quote:
Originally Posted by Greg McKaskle View Post
I'm not sure what to do. What sort of problem? Are you sure that the value going to the variable write is the correct one?

Greg McKaskle
The value going to the variable is indeed correct, but whenever I try to pass the data from Periodic Tasks (where I got it) to Teleop (where it needs to be); the wire probed always returns the value as 0. I'm not too sure how to get the data where it needs to go.
Reply With Quote
  #14   Spotlight this post!  
Unread 10-02-2012, 21:03
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: Sending Data from Dashboard to Robot?

If you are talking about a global variable, you can also open the global VI and observe the value there. If you are using something else, please elaborate.

Greg McKaskle
Reply With Quote
  #15   Spotlight this post!  
Unread 11-02-2012, 01:17
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: Sending Data from Dashboard to Robot?

Quote:
Originally Posted by Wildcats1378 View Post
The value going to the variable is indeed correct, but whenever I try to pass the data from Periodic Tasks (where I got it) to Teleop (where it needs to be); the wire probed always returns the value as 0. I'm not too sure how to get the data where it needs to go.
Just in case you're trying to add a wire out of Periodic Tasks and into Teleop: that won't work. Periodic Tasks never terminates, so it will never provide an output value. To communicate between one vi and another you can use a global variable, or you can do fancier stuff with semaphores or notifiers or queues or etc.
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 22:08.

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