Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   We got Sockets working (http://www.chiefdelphi.com/forums/showthread.php?t=100675)

sand500 19-01-2012 20:42

We got Sockets working
 
http://www.youtube.com/watch?v=N0xvqxRKCKg

What we have is the computer with the driver station has the PS3 controller connected to it. We then get input from the left stick of the joystick to the CRIO with the regular Joystick Class. Now to send that to the 2nd computer, we use java sockets with the CRIO running the socket server code and the computer running the client socket code. So far, we are just experimenting with sockets with last years robot.

Patrickwhite 19-01-2012 20:51

Re: We got Sockets working
 
Neat!

Your custom dashboard looks a lot like the Smart Dashboard - for what reasons did you decide to make your own, instead of using the Smart Dashboard?

neal 19-01-2012 21:10

Re: We got Sockets working
 
Is that possible to do with SmartDashboard? I'd really love to get those bars for joysticks and the Gyro thing as well!

theNerd 19-01-2012 21:17

Re: We got Sockets working
 
Wow. I've been trying to lean how to do that in LabView. Since I switched over to java I still wonder how to do that. Could you explain in detail how you got the comms to work?

Patrickwhite 19-01-2012 21:17

Re: We got Sockets working
 
Absolutely that's possible with the SmartDashboard.

The SmartDashboard package is edu.wpi.first.wpilibj.smartdashboard.

Data sent has a name and a value. The name is used to tie a set of values to a certain widget - if you send "Heading" as 90, then set up a widget to listen to that key, then subsequent sendings of "Heading" will go straight to that widget.

You can send booleans, ints, doubles, and Strings, as well as any class that implements SmartDashboardData. You can even make your own SmartDashboardData-implementing class, though doing so is a bit complicated.

You can make your own widget to display data received any way you like.

neal 19-01-2012 21:22

Re: We got Sockets working
 
Quote:

Originally Posted by Patrickwhite (Post 1109386)
Absolutely that's possible with the SmartDashboard.

The SmartDashboard package is edu.wpi.first.wpilibj.smartdashboard.

Data sent has a name and a value. The name is used to tie a set of values to a certain widget - if you send "Heading" as 90, then set up a widget to listen to that key, then subsequent sendings of "Heading" will go straight to that widget.

You can send booleans, ints, doubles, and Strings, as well as any class that implements SmartDashboardData. You can even make your own SmartDashboardData-implementing class, though doing so is a bit complicated.

Oh, cool! I was wondering what putint() and other methods did. But I won't have access to the robot until Saturday. Glad you explained!

How do you make the widgets, though?

Patrickwhite 19-01-2012 22:27

Re: We got Sockets working
 
http://firstforge.wpi.edu/sf/wiki/do...iki/Extensions

Great set of tutorials on how to write a widget.

The SmartDashboard itself can be downloaded from the same project, under File Releases.

sand500 20-01-2012 09:50

Re: We got Sockets working
 
Quote:

Originally Posted by Patrickwhite (Post 1109363)
Neat!

Your custom dashboard looks a lot like the Smart Dashboard - for what reasons did you decide to make your own, instead of using the Smart Dashboard?

Well we are still messing around at this point, but based on how our bot turns out, we will make our Dashboard to fit the bot.

ProgrammerMatt 28-01-2012 19:25

Re: We got Sockets working
 
Mind sharing how to use sockets im trying to send my vision tracking data to our robot with no luck :(

Sunstroke 28-01-2012 20:43

Re: We got Sockets working
 
Quote:

Originally Posted by ProgrammerMatt (Post 1115455)
Mind sharing how to use sockets im trying to send my vision tracking data to our robot with no luck :(

Might I suggest looking at this thread? It takes away all the little obnoxious parts of sockets and does it for you.

ProgrammerMatt 28-01-2012 23:44

Re: We got Sockets working
 
Quote:

Originally Posted by sand500 (Post 1109353)
http://www.youtube.com/watch?v=N0xvqxRKCKg

What we have is the computer with the driver station has the PS3 controller connected to it. We then get input from the left stick of the joystick to the CRIO with the regular Joystick Class. Now to send that to the 2nd computer, we use java sockets with the CRIO running the socket server code and the computer running the client socket code. So far, we are just experimenting with sockets with last years robot.

Could you possibly share this code because of the lack of examples?

Sunstroke 29-01-2012 00:10

Re: We got Sockets working
 
Quote:

Originally Posted by ProgrammerMatt (Post 1115455)
Mind sharing how to use sockets im trying to send my vision tracking data to our robot with no luck :(

I would consider using the code provided by WPI.

ProgrammerMatt 31-01-2012 15:32

Re: We got Sockets working
 
Quote:

Originally Posted by Sunstroke (Post 1115679)
I would consider using the code provided by WPI.

The problem with that is i have a program for vision tracking and it sends out TCP data on its own...

derekwhite 01-02-2012 08:35

Re: We got Sockets working
 
Here's one quick example:

Code:

// connect to “echo” server:
SocketConnection sc = (SocketConnection) Connector.open("socket://host.com:79");
InputStream is = sc.openInputStream();
OutputStream os = sc.openOutputStream();

os.write("Hello\r\n".getBytes());
int ch = 0;
while(ch != -1) {
  ch = is.read();
}
sc.close();


derekwhite 01-02-2012 08:36

Re: We got Sockets working
 
More examples here:

http://developers.sun.com/mobility/m.../midp2network/


All times are GMT -5. The time now is 13:16.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi