Go to Post As long as this is a competition teams will push the limits. Those that succeed are those who can push the envelope and still stay within the lines. - Steve W [more]
Home
Go Back   Chief Delphi > Technical > Programming
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 16-01-2017, 20:41
Henry Loh Henry Loh is offline
Registered User
FRC #5104
 
Join Date: Jan 2017
Location: Pacific Grove, Ca.
Posts: 7
Henry Loh is an unknown quantity at this point
Basic Network Table Test Fails

Hello,
So my team is planning on using Vision Processing this year to help with the shooter, and a precursory step to this is manipulating Network Tables. Today I was working on a basic example between the RoboRIO (C++) and a Java Client on a Mac (Java). The basic scenario is that the roboRio creates a network table (Net) and posts to it the variable Test with the value of 10. The client program then connects to the RoboRIO, and attempts to read the Net/Test value from the RoboRIO. However, the client fails to read the value from the network table and I am not sure why as both programs have repeatedly been dumbed down until there is hardly anything left. Any advice/suggestions would be much appreciated.

Thanks a bunch,
Henry

Here are the logistics:

Setup:
- C++ Iterative Robot Code
- Java Client Program on Mac
- Links to the jar discussed in the screensteps tutorial


Result:
- Server (RoboRIO Code) seems to run fine. The Network Table (Net) and it's value for Test are displayed in the variables tab of the SmartDashboard.
- Client (Java - Mac) does not run as hoped. The code cannot find the Net/Test value and thus returns -1. Meanwhile, the SmartDashboard Console is spammed with NT: server: client CONNECTED: 10.51.4.198 port 5**** with ever-increasing port numbers.
- On the Client Side, the lines of "Test: -1" are split up by alternate outputs of...
edu.wpi.first.wpilibj.networktables2.client.Client ConnectionAdapter@b4c966a entered connection state: DISCONNECTED_FROM_SERVER

and

edu.wpi.first.wpilibj.networktables2.client.Client ConnectionAdapter@b4c966a entered connection state: CONNECTED_TO_SERVER


- Disabling the robot continues these console outputs until the client program is terminated.

Below, I have stripped the programs down to the basics, eliminating extraneous print statements and empty functions. As there is so little code, I can't imagine what is going wrong?

--------------------------------------------------------------------------------------------------------------------------

Server Code: (The Relevant Stuff)

#include "WPILib.h"
#include "NetworkTables/NetworkTable.h"


class Robot: public IterativeRobot {

public:
// Network Table Test
std::shared_ptr<NetworkTable> table;

Robot():
{
table = NetworkTable::GetTable("Net");
}

private:

void TeleopPeriodic(){
table->PutNumber("Test",10);
}

};

START_ROBOT_CLASS(Robot)


Client Code: (The Relevant Stuff)

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

public class Client {

public static void main(String[] arg){

NetworkTable.setClientMode();
NetworkTable.setIPAddress("10.51.4.105");

NetworkTable table = NetworkTable.getTable("Net");

while (true){

double test = table.getNumber("Test", -1);

System.out.printf("Test: %f\n",test);

}
}
}
Reply With Quote
  #2   Spotlight this post!  
Unread 16-01-2017, 21:16
Thad House Thad House is offline
Volunteer, WPILib Contributor
no team (Waiting for 2021)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Thousand Oaks, California
Posts: 1,106
Thad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond repute
Re: Basic Network Table Test Fails

That looks like you are using a VERY old version of NetworkTables. What screensteps page did you find that on?

The newest version can be found at http://first.wpi.edu/FRC/roborio/mav....5-desktop.jar. Try using that jar instead, as that has been tested to work with the newest robot version of NetworkTables.

The only thing I'm going to recommend changing is in your Java code, use setTeam(5104) rather then setIPAddress. setTeam has mechanisms built in to help connect easier.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of RobotDotNet, a .NET port of the WPILib.
Reply With Quote
  #3   Spotlight this post!  
Unread 16-01-2017, 22:02
Henry Loh Henry Loh is offline
Registered User
FRC #5104
 
Join Date: Jan 2017
Location: Pacific Grove, Ca.
Posts: 7
Henry Loh is an unknown quantity at this point
Re: Basic Network Table Test Fails

Thanks so much for your quick reply. Now that I look at it, the screensteps page I was working off of was from 2014 (EEK!). I don't know why that came up instead of the more recent pages, but I guess it's my fault for not using an updated tutorial.

Thanks for the updated jar file, it works perfectly. All problems solved.
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 23:52.

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