Go to Post How about instead of using the flag we just all wrap out robots in color saran wrap. there! problem sovled! - John Gutmann [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 29-01-2014, 22:41
charr charr is offline
Registered User
FRC #3504
 
Join Date: Aug 2013
Location: Pittsburgh
Posts: 20
charr is an unknown quantity at this point
looking for sample - simple smartdashboard plugin which writes to networktable

This is really a unit test. I want to create a plugin which, when the smartdashboard starts, will start writing values to the network tables - perhaps a continuous sine wave.
Reply With Quote
  #2   Spotlight this post!  
Unread 05-02-2014, 13:10
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: looking for sample - simple smartdashboard plugin which writes to networktable

There is now a tutorial here: http://wpilib.screenstepslive.com/s/...rol-using-java
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #3   Spotlight this post!  
Unread 05-02-2014, 13:23
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: looking for sample - simple smartdashboard plugin which writes to networktable

Thanks, that is helpful. But actually I was looking for an example for the old smartdashboard.

Quote:
Originally Posted by byteit101 View Post
Reply With Quote
  #4   Spotlight this post!  
Unread 09-02-2014, 10:48
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 330
fovea1959 will become famous soon enough
Re: looking for sample - simple smartdashboard plugin which writes to networktable

there was an example **buried** in last year's documentation... <rummage rummage>

I went through this over the summer: it worked well for the 2013 swing based dashboard, hope to see the same in 2014?

http://firstforge.wpi.edu/sf/wiki/do...reateExtension
Reply With Quote
  #5   Spotlight this post!  
Unread 09-02-2014, 16:11
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 330
fovea1959 will become famous soon enough
Re: looking for sample - simple smartdashboard plugin which writes to networktable

If it's not essential that the sine-wave generator is part of the dashboard (where does that requirement come from?), then you can just write and run a separate program to stuff the data into the network tables (this is what robo realm does). Integration with the dashboard is not necessary to access the network tables.

The PC desktop version of the network tables library in in sunspotfrcsdk\desktop-lib, along with Javadocs.
Reply With Quote
  #6   Spotlight this post!  
Unread 09-02-2014, 16:38
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: looking for sample - simple smartdashboard plugin which writes to networktable

As I had said in my original posting, this is about unit testing and not about any "requirement". Or to say another way, the requirement is for the following unit test: a smartdashboard which sends data to the network tables. I've still not found such an example.
Thanks,
Chris
Quote:
Originally Posted by fovea1959 View Post
If it's not essential that the sine-wave generator is part of the dashboard (where does that requirement come from?), then you can just write and run a separate program to stuff the data into the network tables (this is what robo realm does). Integration with the dashboard is not necessary to access the network tables.

The PC desktop version of the network tables library in in sunspotfrcsdk\desktop-lib, along with Javadocs.
Reply With Quote
  #7   Spotlight this post!  
Unread 09-02-2014, 20:38
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 330
fovea1959 will become famous soon enough
Re: looking for sample - simple smartdashboard plugin which writes to networktable

again, does it need to specifically be a smartdashboard, or just a Java program (it sounds like the latter)? In that case, the shorter route may be a standalone program to stuff the network tables.

Code:
package org.usfirst.frc3620.desktop.networktables;

import edu.wpi.first.wpilibj.networktables2.client.NetworkTableClient;
import edu.wpi.first.wpilibj.networktables2.stream.IOStreamFactory;
import edu.wpi.first.wpilibj.networktables2.stream.SocketStreams;
import java.io.IOException;

public class TableStuffer {

    public static void main(String args[]) {
        Throwable boom = null;
        try {
            String host = "10.36.20.2";
            if (args.length > 0) {
                host = args[0];
            }
            int port = 1735;
            TableStuffer tableStuffer = new TableStuffer(host, port);
            tableStuffer.go();
        } catch (IOException ex) {
            boom = ex;
        } catch (RuntimeException ex) {
            boom = ex;
        }
        if (boom != null) {
            boom.printStackTrace();
        }
    }

    NetworkTableClient client = null;

    TableStuffer(String h, int p) throws IOException {
        IOStreamFactory streamFactory = SocketStreams.newStreamFactory(h, p);
        client = new NetworkTableClient(streamFactory);
    }

    void go() {
        double degrees = 0;

        while (true) {
            if (!client.isConnected()) {
                client.reconnect();
                // fresh connection, restart the since wave
                degrees = 0;
            } else {
                double s = Math.sin(degrees * Math.PI / 180.0);
                System.out.println (degrees + " -> " + s);
                client.putDouble("degrees", degrees);
                client.putDouble("sin", s);
                degrees ++;
            }
            try {
                Thread.sleep(50);
            } catch (InterruptedException ex) {
            }
        }
    }

}
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 22:32.

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