Go to Post Baker, Skierkeiwicz, one more word out of you two and I'll have to pull out the Clipboard of Doom :p - Jessica Boucher [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 16-01-2012, 20:54
rp181 rp181 is offline
Registered User
FRC #0662
 
Join Date: Jan 2011
Location: US
Posts: 5
rp181 is an unknown quantity at this point
Sending data to cRIO

Is it possible to send data to the cRIO from a Java program through a socket or the like? I would like to outsource some heavy operations to a more powerful computer. If possible, is there examples of both the host and cRIO code?
  #2   Spotlight this post!  
Unread 19-01-2012, 11:54
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

Yes

See javax.microedition.io

http://k.thekks.net/frcdoc/javax/mic...e-summary.html

You can even have your server on a laptop written in a completely differnet language (I'm doing python)
  #3   Spotlight this post!  
Unread 20-01-2012, 17:24
rp181 rp181 is offline
Registered User
FRC #0662
 
Join Date: Jan 2011
Location: US
Posts: 5
rp181 is an unknown quantity at this point
Re: Sending data to cRIO

Will a SocketConnection be sufficient? For the host, which IP do you put? I tried a quick example, and i get a connection refused exception.
  #4   Spotlight this post!  
Unread 20-01-2012, 22: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
To simplify development and comply with standards, I think ill setup a restful server on the onboard computer instead of handling raw sockets. My experiences with raw sockets are all really bad.

I would recommend the same thing for you. This way you only need to use the httpconnection class
  #5   Spotlight this post!  
Unread 20-01-2012, 23:18
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

You mention onboard computer so I assume you are putting a separate computer on the robot. Have you thought about using a null-modem cable and a serial connection? The cRIO appears to have raw serial support and the serial port is generally quite simple to use - lots less machinery than even a restful server and HTTP. Most good serial apis (and I know there is at least a few good Java ones) let you send and receive a variety of data types. Worst case scenario would be to use strings. I know the cRIO can send bytes as well as use things like printf with the serial port.

-Mike
  #6   Spotlight this post!  
Unread 21-01-2012, 09: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
I still think restful will be the simplest. I don't when need to write any connection software (like 10 lines)
  #7   Spotlight this post!  
Unread 22-01-2012, 14:25
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

For my own understanding then would you run a web server on the computer and make HTTP calls from the cRIO? And if so, what is the code on the cRIO to do that? I see minimal WPI documentation on socket and nothing on HTTP. Even a link to the right documentation would be enough to get me started. Thanks!

-Mike
  #8   Spotlight this post!  
Unread 22-01-2012, 14:37
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
For my own understanding then would you run a web server on the computer and make HTTP calls from the cRIO? And if so, what is the code on the cRIO to do that? I see minimal WPI documentation on socket and nothing on HTTP. Even a link to the right documentation would be enough to get me started. Thanks!

-Mike
Java Doc: http://k.thekks.net/frcdoc/javax/mic...onnection.html

Yeah, you're right. I initially planned to use a purely standard compliant restful server. However, I think I might just go with flask as it will be super easy to program for and I already have a LOT of experience with it.

On top of flask, I'll probably have code to pull off the camera image from its HTTP stream, and use OpenCV to process them. Those results returned by the processor will be added to a queue (by POSTing to the flask server), which then the cRIO could pull off from a GET request to a specific address. Since flask's dev server is not the ideal choice for high traffic concurrent application (not exactly it, but it'll be more than 20 req per second.. for sure), I'll probably setup a gevent wsgi server to wrap that around the flask app, which I already have code for that I've written for other applications.

The only non-problem I have with this is the overhead of message delivery.. but those are really nothing since everything is either local or over an ethernet cable.. transferring some simple JSON data, and gevent is fully equipped to handle those.

I feel like someone is going to call this setup too complicated.. but it's fool proof, there will be little to no errors in the server/client code as the only ones that has a chance of occurring is some sort of connection error (or a bug in the library.. but i doubt that).. which will occur with socket anyway.

If someone is going for the same approach, I'll be happy to share my client and server code.

Last edited by shuhao : 22-01-2012 at 14:43.
  #9   Spotlight this post!  
Unread 22-01-2012, 14:47
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

Gah, I totally lost track of the fact you are using Java. We are using C++ and I have no idea how the students are going to get C++ to talk to anything effectively. Serial was a crap shoot and still is. I REALLY wish we were using something else.

-Mike
  #10   Spotlight this post!  
Unread 22-01-2012, 14:49
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: Sending data to cRIO

If you're sending data between the cRio and a laptop on the robot (connected to the bridge or 2nd cRio ethernet port), it would seem that UDP datagrams are the simplest solution, as they are easy to implement (a UDP listener does not require more than one thread, and a UDP sender is a synchronous call requiring no state at all)
__________________
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
  #11   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
  #12   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.
  #13   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
  #14   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,748
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
  #15   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
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 09:19.

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