|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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? |
|
#3
|
||||
|
||||
|
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!
|
|
#4
|
||||
|
||||
|
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?
|
|
#5
|
||||
|
||||
|
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. Last edited by Patrickwhite : 19-01-2012 at 21:21. |
|
#6
|
||||
|
||||
|
Re: We got Sockets working
Quote:
How do you make the widgets, though? Last edited by neal : 19-01-2012 at 21:24. |
|
#7
|
||||
|
||||
|
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. |
|
#8
|
|||
|
|||
|
Re: We got Sockets working
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.
|
|
#9
|
|||
|
|||
|
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
![]() |
|
#10
|
|||
|
|||
|
Re: We got Sockets working
Quote:
|
|
#11
|
|||
|
|||
|
Re: We got Sockets working
Quote:
|
|
#12
|
|||
|
|||
|
Re: We got Sockets working
Quote:
|
|
#13
|
||||
|
||||
|
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();
|
|
#14
|
||||
|
||||
|
Re: We got Sockets working
|
|
#15
|
|||
|
|||
|
Re: We got Sockets working
This is more for derek but when i send data to my robot using this code http://pastebin.com/x2KZepNR that i made i get a thread error and null pointer any ideas?
here is error Code:
[cRIO] Default disabled() method running, consider providing your own [cRIO] Uncaught exception in Thread.run(): [cRIO] on thread Thread-6 [cRIO] java.lang.NullPointerException [cRIO] at edu.wpi.first.wpilibj.templates.Socket.run(Socket.java:40) [cRIO] in virtual method #47 of com.sun.squawk.VMThread(bci=42) [cRIO] in static method #3 of com.sun.squawk.VM(bci=6) Last edited by ProgrammerMatt : 02-02-2012 at 17:46. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|