Go to Post Did you inform McMaster Carr that up to 3000 FRC teams would all be attempting to acquire a very specific spring ASAP all on the same weekend? - cgmv123 [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 27-12-2013, 01:28
charr charr is offline
Registered User
FRC #3504
 
Join Date: Aug 2013
Location: Pittsburgh
Posts: 20
charr is an unknown quantity at this point
Running Smartdashboard without cRIO/robot?

Can this be done? If so, are there instructions or notes? All the WPI "getting started" samples have code which interfaces with the physical robot. Not sure I'm even looking at the right code samples since I want to experiment with Smartdashboard and not the robot.
Reply With Quote
  #2   Spotlight this post!  
Unread 27-12-2013, 14:36
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 434
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Running Smartdashboard without cRIO/robot?

I've never tried myself, but you should be able to pull out the SmartDashboard and NetworkTable classes from wpilib.

The source code is included in the sunspotfrcsdk folder if you have installed the FRC java plugins from 2013. Sources are zipped here on a windows machine:
Code:
%HOMEPATH%\sunspotfrcsdk\lib\wpilibj.src.zip
They should be located at the following locations respectively:
edu/wpi/first/wpilibj/smartdashboard
edu/wpi/first/wpilibj/networktables/

Alternatively, you could just include the whole wpilib jar file in your java desktop application. The following should get you everything you need:
Code:
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
You should be able to make calls to the SmartDashboard class in the same manner you would in your robot code. See http://wpilib.screenstepslive.com/s/...manual-id=7932
__________________
http://team2168.org
Reply With Quote
  #3   Spotlight this post!  
Unread 27-12-2013, 15:24
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,590
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: Running Smartdashboard without cRIO/robot?

There is a completely new version of SmartDashboard coming out this year, based on JavaFX. Everything below is based on the old SmartDashboard, but probably also applies to SmartDashboard 2.0 (or SmartDashboardFX, not sure what the correct name is).

You can start up Smartdashboard and have it connect to a different ip address by specifying it on the command line. For example: java -jar smartdashboard.jar 127.0.0.1

The robot normally functions as a Network Tables server, so you need a replacement server. Network Tables is the network library that SmartDashboard uses. You should be able to use the files in sunspotfrcsdk\desktop-lib to make a java program that runs a network tables server, although I've never done it. There are instructions for making a client program here: http://wpilib.screenstepslive.com/s/...client-pc-side You would have to extend them to make a server.

If you have LabVIEW, it's really easy to make a Network Tables server, just drop the NT Server Vi on a new VI, and run.

The 2014 beta java software contains a tool called Outline Viewer. It can operate as either a client or a server and lets you view and manipulate Network Tables variables.

Quote:
Originally Posted by otherguy View Post
I've never tried myself, but you should be able to pull out the SmartDashboard and NetworkTable classes from wpilib.

The source code is included in the sunspotfrcsdk folder if you have installed the FRC java plugins from 2013. Sources are zipped here on a windows machine:
Code:
%HOMEPATH%\sunspotfrcsdk\lib\wpilibj.src.zip
They should be located at the following locations respectively:
edu/wpi/first/wpilibj/smartdashboard
edu/wpi/first/wpilibj/networktables/

Alternatively, you could just include the whole wpilib jar file in your java desktop application. The following should get you everything you need:
Code:
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
This uses Java ME networking, you need to use the desktop version I posted above.

Last edited by Joe Ross : 27-12-2013 at 15:27.
Reply With Quote
  #4   Spotlight this post!  
Unread 27-12-2013, 21:21
krieck's Avatar
krieck krieck is online now
Registered User
AKA: Keith
FRC #2846 (Firebears)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Minnesota
Posts: 49
krieck is an unknown quantity at this point
Re: Running Smartdashboard without cRIO/robot?

Creating a NetworkTables server is very easy. Having a stand-alone server will let you develop SmartDashboard and sensor processing apps without the cRIO:

Code:
import edu.wpi.first.wpilibj.networktables.NetworkTable;

/**
 * Server for running Network tables.
 * You must add the networktables-desktop.jar file to your classpath.
 */
public class NetworkTableServer {

    public static void main(String[] args) throws Exception {
        NetworkTable.setServerMode();
        NetworkTable.getTable("");

        Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
        while (true) {
            Thread.sleep(100L);
        }
    }

}
Reply With Quote
  #5   Spotlight this post!  
Unread 29-12-2013, 21:57
charr charr is offline
Registered User
FRC #3504
 
Join Date: Aug 2013
Location: Pittsburgh
Posts: 20
charr is an unknown quantity at this point
Re: Running Smartdashboard without cRIO/robot?

Thanks Joe. If I run smartdashboard.jar without an IP address, what does it connect to?

Where can I get the 2014 beta?

Thanks,
Chris

Quote:
Originally Posted by Joe Ross View Post
There is a completely new version of SmartDashboard coming out this year, based on JavaFX. Everything below is based on the old SmartDashboard, but probably also applies to SmartDashboard 2.0 (or SmartDashboardFX, not sure what the correct name is).

You can start up Smartdashboard and have it connect to a different ip address by specifying it on the command line. For example: java -jar smartdashboard.jar 127.0.0.1

The robot normally functions as a Network Tables server, so you need a replacement server. Network Tables is the network library that SmartDashboard uses. You should be able to use the files in sunspotfrcsdk\desktop-lib to make a java program that runs a network tables server, although I've never done it. There are instructions for making a client program here: http://wpilib.screenstepslive.com/s/...client-pc-side You would have to extend them to make a server.

If you have LabVIEW, it's really easy to make a Network Tables server, just drop the NT Server Vi on a new VI, and run.

The 2014 beta java software contains a tool called Outline Viewer. It can operate as either a client or a server and lets you view and manipulate Network Tables variables.



This uses Java ME networking, you need to use the desktop version I posted above.
Reply With Quote
  #6   Spotlight this post!  
Unread 29-12-2013, 22:01
charr charr is offline
Registered User
FRC #3504
 
Join Date: Aug 2013
Location: Pittsburgh
Posts: 20
charr is an unknown quantity at this point
Re: Running Smartdashboard without cRIO/robot?

Thanks Krieck,
Do you know of any online resources/articles which explain the code you posted? I'm as interested in understanding it as I am in getting it to work.
Thanks,
Chris


Quote:
Originally Posted by krieck View Post
Creating a NetworkTables server is very easy. Having a stand-alone server will let you develop SmartDashboard and sensor processing apps without the cRIO:

Code:
import edu.wpi.first.wpilibj.networktables.NetworkTable;

/**
 * Server for running Network tables.
 * You must add the networktables-desktop.jar file to your classpath.
 */
public class NetworkTableServer {

    public static void main(String[] args) throws Exception {
        NetworkTable.setServerMode();
        NetworkTable.getTable("");

        Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
        while (true) {
            Thread.sleep(100L);
        }
    }

}
Reply With Quote
  #7   Spotlight this post!  
Unread 29-12-2013, 23:02
krieck's Avatar
krieck krieck is online now
Registered User
AKA: Keith
FRC #2846 (Firebears)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Minnesota
Posts: 49
krieck is an unknown quantity at this point
Re: Running Smartdashboard without cRIO/robot?

The first two lines of the server code do all the work. I found these lines by reading through the WPILib code. The remaining lines just put the main thread to sleep while the NetworkTable handles communications in another thread.

I highly recommend reading through the WPILib source code. It should be installed in your home directory under sunspotfrcsdk/lib/wpilibj.src.zip

The only documentation I know of is at: http://wpilib.screenstepslive.com/s/...client-pc-side
Reply With Quote
  #8   Spotlight this post!  
Unread 30-12-2013, 12:21
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,590
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: Running Smartdashboard without cRIO/robot?

Quote:
Originally Posted by charr View Post
Thanks Joe. If I run smartdashboard.jar without an IP address, what does it connect to?
The robot. IP address 10.te.am.2, where te.am is the team number defined in the smart dashboard configuration.

Quote:
Originally Posted by charr View Post
Where can I get the 2014 beta?
In 5 days
Reply With Quote
  #9   Spotlight this post!  
Unread 30-12-2013, 17:50
krieck's Avatar
krieck krieck is online now
Registered User
AKA: Keith
FRC #2846 (Firebears)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Minnesota
Posts: 49
krieck is an unknown quantity at this point
Re: Running Smartdashboard without cRIO/robot?

> Where can I get the 2014 beta?

For anyone who is impatient, you might run through the installation procedure and set up the latest Java, NetBeans, and the NetBeans plugins: http://wpilib.screenstepslive.com/s/...elopment-tools

The "Release" versions of the WPI plugins have had some updates in the past week, so these may be pretty close to the latest code.
Reply With Quote
  #10   Spotlight this post!  
Unread 30-12-2013, 20:13
HeatherEmc2's Avatar
HeatherEmc2 HeatherEmc2 is offline
Registered User
FRC #3504
Team Role: Programmer
 
Join Date: Dec 2013
Rookie Year: 2011
Location: Pittsburgh
Posts: 5
HeatherEmc2 is an unknown quantity at this point
Re: Running Smartdashboard without cRIO/robot?

Joe, Krieck,
The code to set up a NetworkTables server was very helpful, but how do I get SmartDashboard to use it? I ran it from the command line and tried to specify the ip as 127.0.0.1 but it still looks like it's looking for the crio.
When I try to run my code I get exceptions like
Code:
Caused by: java.lang.RuntimeException: NetworkTable could not be initialized: java.net.BindException: Address already in use: JVM_Bind: Address already in use: JVM_Bind
	at edu.wpi.first.wpilibj.networktables.NetworkTable.getTable(Unknown Source)
	at edu.wpi.first.wpilibj.smartdashboard.SmartDashboard.<clinit>(SmartDashboard.java:31)
any advice?

Last edited by HeatherEmc2 : 30-12-2013 at 20:20.
Reply With Quote
  #11   Spotlight this post!  
Unread 30-12-2013, 20:34
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,590
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: Running Smartdashboard without cRIO/robot?

Quote:
Originally Posted by Joe Ross View Post
You can start up Smartdashboard and have it connect to a different ip address by specifying it on the command line. For example: java -jar smartdashboard.jar 127.0.0.1
Sorry, the command line should be java -jar smartdashboard.jar -ip 127.0.0.1
Reply With Quote
  #12   Spotlight this post!  
Unread 31-12-2013, 00:56
HeatherEmc2's Avatar
HeatherEmc2 HeatherEmc2 is offline
Registered User
FRC #3504
Team Role: Programmer
 
Join Date: Dec 2013
Rookie Year: 2011
Location: Pittsburgh
Posts: 5
HeatherEmc2 is an unknown quantity at this point
Re: Running Smartdashboard without cRIO/robot?

Thanks Joe,
That worked.
I'm still getting that exception when I run my code though. Here's what the code looks like:
Code:
import edu.wpi.first.wpilibj.networktables.NetworkTable;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class NetworkingOne {

    public static void main(String[] args) {
        SmartDashboard.putNumber("set value", 0);
        double num = SmartDashboard.getNumber("set value");
        NetworkTable.getTable("share").putNumber("share value", num);
    }
}
I know SmartDashboard.putNumber is really putting a number to a NetworkTable called SmartDashboard so could it be that thats using the crio ip and not the NetworkTable server that's running?
Reply With Quote
  #13   Spotlight this post!  
Unread 01-01-2014, 12:24
krieck's Avatar
krieck krieck is online now
Registered User
AKA: Keith
FRC #2846 (Firebears)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Minnesota
Posts: 49
krieck is an unknown quantity at this point
Re: Running Smartdashboard without cRIO/robot?

In your client code you should specify the IP address and also set up for client mode. Try this:
  1. Start the NetworkTableServer
  2. Start up SmartDashboard with -ip 127.0.0.1
  3. Run the client code below


Code:
import edu.wpi.first.wpilibj.networktables.NetworkTable;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class NetworkingOne {

    public static void main(String[] args) {
        NetworkTable.setClientMode();
        NetworkTable.setIPAddress("127.0.0.1");
        SmartDashboard.putNumber("set value", 0);
        double num = SmartDashboard.getNumber("set value");
        NetworkTable.getTable("SmartDashboard").putNumber("share value", num);
    }
}
Reply With Quote
  #14   Spotlight this post!  
Unread 06-01-2014, 19:20
aaronjeline aaronjeline is offline
Aaron
FRC #1719 (Umbrella Corporation)
Team Role: Programmer
 
Join Date: Nov 2013
Rookie Year: 2013
Location: Baltimore
Posts: 18
aaronjeline is an unknown quantity at this point
Re: Running Smartdashboard without cRIO/robot?

Quote:
Originally Posted by krieck View Post
In your client code you should specify the IP address and also set up for client mode. Try this:
  1. Start the NetworkTableServer
  2. Start up SmartDashboard with -ip 127.0.0.1
  3. Run the client code below


Code:
import edu.wpi.first.wpilibj.networktables.NetworkTable;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class NetworkingOne {

    public static void main(String[] args) {
        NetworkTable.setClientMode();
        NetworkTable.setIPAddress("127.0.0.1");
        SmartDashboard.putNumber("set value", 0);
        double num = SmartDashboard.getNumber("set value");
        NetworkTable.getTable("SmartDashboard").putNumber("share value", num);
    }
}
That's still not working for me. Just trying to pass one int to the smartdashboard. Any ideas?
Reply With Quote
  #15   Spotlight this post!  
Unread 06-01-2014, 20:51
charr charr is offline
Registered User
FRC #3504
 
Join Date: Aug 2013
Location: Pittsburgh
Posts: 20
charr is an unknown quantity at this point
Re: Running Smartdashboard without cRIO/robot?

Quote:
Originally Posted by aaronjeline View Post
That's still not working for me. Just trying to pass one int to the smartdashboard. Any ideas?
It did work for me. Also worked between two different computers. Did you start the network tables server?
Reply With Quote
Reply


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 13:02.

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