Go to Post Admiring the new chassis: "Oooo, nerd bling!" - Rick TYler [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

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 22-01-2012, 14:50
mikegrundvig mikegrundvig is offline
Registered User
FRC #2410 (Metal Mustangs)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: United States
Posts: 100
mikegrundvig is an unknown quantity at this point
Re: Sending data to cRIO

The problem is getting students that barely know C++ far enough along to actually put that together. With Java at least I could point to hundreds of cut-and-pastable examples. I think we will probably stick with the original serial idea just for it's general simplicity.

-Mike
  #2   Spotlight this post!  
Unread 22-01-2012, 15:02
shuhao shuhao is offline
Registered User
FRC #4069 (Lo-Ellen Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Sudbury
Posts: 138
shuhao is an unknown quantity at this point
Re: Sending data to cRIO

Quote:
Originally Posted by mikegrundvig View Post
The problem is getting students that barely know C++ far enough along to actually put that together. With Java at least I could point to hundreds of cut-and-pastable examples. I think we will probably stick with the original serial idea just for it's general simplicity.

-Mike
Is there no member of the team that could just pick up another language by reading references? C++ is a terrible language to learn how to program, as it has way too many concepts enrolled into 1 (really 2 languages into 1, if you think about it). On top of that, the C++ already code is not portable to the cRIO.. so you're getting even less support with that...

For me though, I don't think Copy-Pasta is the best idea in terms of programming the robot.. the students will neither learn, nor will the robot be well programmed...


Edit: Just took a look at the C++ references (stupid chm files.. gotta find a viewer lol) and it seems your options is fairly limited.. existing C++ code probably won't work for you either.

Also, are you a mentor on the team?

Last edited by shuhao : 22-01-2012 at 15:06.
  #3   Spotlight this post!  
Unread 22-01-2012, 15:20
mikegrundvig mikegrundvig is offline
Registered User
FRC #2410 (Metal Mustangs)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: United States
Posts: 100
mikegrundvig is an unknown quantity at this point
Re: Sending data to cRIO

C++ was the language the students wanted as they picked it last year and it worked for em. There are two differences to last year though - they had one student on the team who was OK at C++ and the robot code was vastly simpler. They have no C++ mentors that have shown up regularly and while I'm actually a good programmer, I don't know C++ goop well enough to help significantly.

Quote:
Is there no member of the team that could just pick up another language by reading references? C++ is a terrible language to learn how to program, as it has way too many concepts enrolled into 1 (really 2 languages into 1, if you think about it). On top of that, the C++ already code is not portable to the cRIO.. so you're getting even less support with that...
I agree, I think learning C++ by the seat of their pants is a nasty problem. I'm going to appear one last time to get things working in Java. Porting the robot code they've done thus far to Java would be a trivial exercise we could complete in under an hour. Add to it how many advantages we'd get with all the built-in libraries and available online examples, it seems like a no-brainer solution.

Quote:
Just took a look at the C++ references (stupid chm files.. gotta find a viewer lol) and it seems your options is fairly limited.. existing C++ code probably won't work for you either.
Yeah, not too much is there? All of that appears readily available in Java as well. Then we also get micro-edition abilities to boot. I've had a lot of trouble getting details on what the OS itself of the cRIO gives us for c/c++ options. This makes porting code from say an Apache library over to the cRIO very scary.

Quote:
Also, are you a mentor on the team?
Yup, so beyond suggestions and some guidance, it's their decision. Thanks!

-Mike
  #4   Spotlight this post!  
Unread 22-01-2012, 15:20
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,751
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 to cRIO

Learning to use UDP can be an opportunity to look at Java or LV examples and let the kids translate it to C++, or at least try to. I agree that C++ copy and pasting code is not a great learning environment, especially if there isn't a mentor there to help debug and help fix things.

Greg McKaskle
  #5   Spotlight this post!  
Unread 22-01-2012, 22:31
shuhao shuhao is offline
Registered User
FRC #4069 (Lo-Ellen Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Sudbury
Posts: 138
shuhao is an unknown quantity at this point
Re: Sending data to cRIO

For those people who are interested, I just took about 30 minutes to write up the server code for messaging:

https://github.com/FRCTeam4069/Mediator
  #6   Spotlight this post!  
Unread 23-01-2012, 17:32
shuhao shuhao is offline
Registered User
FRC #4069 (Lo-Ellen Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Sudbury
Posts: 138
shuhao is an unknown quantity at this point
Re: Sending data to cRIO

Just wrote the client code for both python and J2ME

J2ME code:
https://github.com/FRCTeam4069/Robot...ils/networking

Python code and improved server is the same link as above if anyone wants those
  #7   Spotlight this post!  
Unread 23-01-2012, 18:24
Hjelstrom's Avatar
Hjelstrom Hjelstrom is offline
Mentor
FRC #0987 (High Rollers)
Team Role: Mentor
 
Join Date: Mar 2008
Rookie Year: 2005
Location: Las Vegas
Posts: 146
Hjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond reputeHjelstrom has a reputation beyond repute
Re: Sending data to cRIO

Quote:
Originally Posted by shuhao View Post
Just wrote the client code for both python and J2ME

J2ME code:
https://github.com/FRCTeam4069/Robot...ils/networking

Python code and improved server is the same link as above if anyone wants those
In your scheme, where is the web server running that you're talking to? Is "flask" a python based web server that you're running on the cRio? Or is the web server running on your driver station?

This year is full of opportunities for ambitious programming!
  #8   Spotlight this post!  
Unread 23-01-2012, 19:29
shuhao shuhao is offline
Registered User
FRC #4069 (Lo-Ellen Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Sudbury
Posts: 138
shuhao is an unknown quantity at this point
Re: Sending data to cRIO

Best case scenario is an onboard, ethernet connected, laptop.

Worst case scenario is the DS laptop. Then certain ports need to be changed.

This thing has the potential to control the robot without the DS station (You would still need to "Enable" the robot via the DS station, though.)

My main goal is to do image processing on the laptop.. Gotta have an efficient way to communicate.

Last edited by shuhao : 23-01-2012 at 19:34.
  #9   Spotlight this post!  
Unread 24-01-2012, 00:13
Lalaland1125 Lalaland1125 is offline
Registered User
AKA: Ethan Steinberg
FRC #2429
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2011
Location: La Canada
Posts: 29
Lalaland1125 is an unknown quantity at this point
Re: Sending data to cRIO

After seeing all those posts suggesting UDP, I still think using UDP for the robot is a very bad idea.

UDP is fundamentally unreliable, you don't know the order or if a package will get to its destination.

While it is possible to code around that unreliability, you are going to end up duplicating much of TCP's utilities and probably end up being both slower and buggier than TCP.

TCP(and stuff based on TCP such as http, json, xml, etc) would be a much better choice as a base for robot communications.

And, if you really need the extra space and speed savings that you would get from UDP, encode in a binary format(such as google protobufs). I am sure the speed and space savings from a binary format outweigh the savings from switching from TCP to UDP.

Last edited by Lalaland1125 : 24-01-2012 at 00:24.
  #10   Spotlight this post!  
Unread 24-01-2012, 01:29
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 to cRIO

Quote:
Originally Posted by Lalaland1125 View Post
UDP is fundamentally unreliable, you don't know the order or if a package will get to its destination.
For a real-time application such as robot control, the lack of a guaranteed delivery is usually a worthwhile tradeoff against the potentially long delivery day of a TCP packet. The kind of data we're talking about is basically "current status" information. If you lose a packet or two, it shouldn't be that big a deal; you'll get updated when the next one comes in.

Using TCP adds error detection and retransmission, but it has to use buffering in order to do it. If the CPU gets busy and can't react quickly, you can end up with significant lag in getting the data where it needs to go.

If you care more about getting every last bit of data, TCP is obviously the way to go. If you care more about getting data with minimum delay, choose UDP.
  #11   Spotlight this post!  
Unread 24-01-2012, 08:29
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,751
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 to cRIO

TCP is much preferred if your data will not fit in a datagram. But small amounts of periodically retransmitted data are why UDP was included in the ISO networking model.

As an example, the joystick data from the DS is sent to the robot using ... UDP. The voltage and other robot data are sent back to the DS using ... UDP.
The field sends state data to the DS using ... UDP.

The only field control data not using UDP is the cameras, where the data is 6KB up to 40KB, and would require many datagrams, all arriving, and all reordered before it would be possible to rebuild the JPG image. But that is a perfect example of when to switch to TCP. There are other considerations, but UDP is a great protocol, and so is TCP.

By the way, the Charts tab on the DS now shows how many packets were lost each second and the latency from the DS to the robot and back. The lost packet indicates that either the control or status didn't make it, therefore the round trip failed.

Greg McKaskle
  #12   Spotlight this post!  
Unread 24-01-2012, 20:42
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,567
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: Sending data to cRIO

Another note is that a LAN is not typically a high latency or lossy network, so many of the things TCP works around do not apply to the robot network.
  #13   Spotlight this post!  
Unread 30-01-2012, 13:45
shuhao shuhao is offline
Registered User
FRC #4069 (Lo-Ellen Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Sudbury
Posts: 138
shuhao is an unknown quantity at this point
Re: Sending data to cRIO

Quote:
Originally Posted by Hjelstrom View Post
In your scheme, where is the web server running that you're talking to? Is "flask" a python based web server that you're running on the cRio? Or is the web server running on your driver station?

This year is full of opportunities for ambitious programming!
Here's my new dashboard, purely webbased

[IMG=624x300]http://i.imgur.com/oe8qP.png[/IMG]

Last edited by shuhao : 30-01-2012 at 13:49.
Closed Thread


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 23:27.

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