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.
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?
Is that possible to do with SmartDashboard? I’d really love to get those bars for joysticks and the Gyro thing as well!
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?
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.
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?
http://firstforge.wpi.edu/sf/wiki/do/viewPage/projects.smartdashboard/wiki/Extensions
Great set of tutorials on how to write a widget.
The SmartDashboard itself can be downloaded from the same project, under File Releases.
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.
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.
Could you possibly share this code because of the lack of examples?
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…
Here’s one quick example:
// connect to “echo” server:
SocketConnection sc = (SocketConnection) Connector.open("socket://host.com:79");
InputStream is = sc.openInputStream();
OutputStream os = sc.openOutputStream();
os.write("Hello
".getBytes());
int ch = 0;
while(ch != -1) {
ch = is.read();
}
sc.close();
More examples here:
http://developers.sun.com/mobility/midp/articles/midp2network/
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
[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)
That stack trace suggests that the variable “you” is null at line 40. But it looks like that would only happen if acceptAndOpen() throw an exception, and no exception was printed in the output you showed.
An aside about NullPointerExceptions - for how common these are, they can really only be created by:
- Trying to get or set a field using an object reference that is null:
thisIsNull.field = 1; - Trying to get or set an array element using an object reference that is null:
thisIsNull[0] = 1; - Trying to get the array length using an object reference that is null:
thisIsNull.length; - Trying to call a non-static method on an object reference that is null:
thisIsNull.toString(); - Trying to synchronize an object reference that is null:
synchronize(thisIsNull) … - Throwing a NullPointerException! This is not too common, but some likely cases are:
System.arraycopy(), Hashtable.contains().
In Java SE (not on robot), native methods may throw a NullPointerException. It depends on the method.
For now I suggest adding code that explicitly checks for “you” being null or not.
I hope this helps track down the bug.
Ok i did figure it out and i can recive data but i see a bunch of exceptions being thrown even know i can send and recive data. any idea why?