Go to Post Dean may have asked that every high school in America be involved with FIRST, but he never said [teams] all had to have separate high schools. - Amanda Morrison [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-01-2013, 11:51
Itamar's Avatar
Itamar Itamar is offline
Registered User
FRC #1943 (NeatTeam) & FRC #4590 (GreenBlitz)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Israel
Posts: 83
Itamar is an unknown quantity at this point
Problems forming NetworkTable between Robot and SmartDashboard

Hello!

We are currently trying to form a connection between the robot and the Smart Dashboard. Here is part of the extension code we have written in Java:

Code:
if (table== null)
{  
            NetworkTable.setTeam(1943);
            NetworkTable.setServerMode();
            try {
                NetworkTable.initialize();
            } catch (IOException ex) {
                Logger.getLogger(TutorialLabel.class.getName()).log(Level.SEVERE, null, ex);
            }
            
            table = NetworkTable.getTable("RoboRealm");
}
And here is the robot code we have written in C++:

Code:
NetworkTable::SetTeam(1943);
NetworkTable::SetIPAddress("10.19.43.5");
NetworkTable::Initialize();
		
roborealmNetTable = NetworkTable::GetTable("RoboRealm");
The Java code runs okay, but the C++ doesn't. When debugging it, we noticed that the code freezes after we call the "NetworkTable::Initialize()" function. What can cause this problem? Can you spot anything wrong with our code?

Thanks!
  #2   Spotlight this post!  
Unread 15-01-2013, 11:55
cjlane1138 cjlane1138 is offline
Team 1138
FRC #1138 (Eagle Engineering)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Los Angeles
Posts: 88
cjlane1138 is an unknown quantity at this point
Re: Problems forming NetworkTable between Robot and SmartDashboard

How are you initializing NetworkTable in C++? Is it a static declaration? Could you post the entire class?
__________________
Eagle Engineering 1138
  #3   Spotlight this post!  
Unread 15-01-2013, 11:57
Itamar's Avatar
Itamar Itamar is offline
Registered User
FRC #1943 (NeatTeam) & FRC #4590 (GreenBlitz)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Israel
Posts: 83
Itamar is an unknown quantity at this point
Re: Problems forming NetworkTable between Robot and SmartDashboard

Quote:
Originally Posted by cjlane1138 View Post
How are you initializing NetworkTable in C++? Is it a static declaration? Could you post the entire class?
Here is the complete robot code:

Code:
#include "WPILib.h"


class RobotDemo : public SimpleRobot
{
	Joystick stick; 
	Jaguar jaguar;
	
	NetworkTable* roborealmNetTable;
public:
	RobotDemo(void):
		stick(1),
		jaguar(2),
		roborealmNetTable(NULL)
	{
		NetworkTable::SetTeam(1943);
		NetworkTable::SetIPAddress("10.19.43.5");
		NetworkTable::Initialize();
		
		roborealmNetTable = NetworkTable::GetTable("RoboRealm");
	}

	void Autonomous(void)
	{

	}

	void OperatorControl(void)
	{
		while (IsOperatorControl())
		{
			
			if (stick.GetRawButton(1))
			{
				jaguar.Set(stick.GetY());
			}
			else
			{
				double d = roborealmNetTable->GetNumber("InputValue");
				jaguar.Set(d);
			}
			
			if (stick.GetRawButton(2))
			{
				roborealmNetTable->PutNumber("InputValue", 0);
			}
			
			Wait(0.005);				// wait for a motor update time
		}
	}	
	/**
	 * Runs during test mode
	 */
	void Test() {

	}
};
  #4   Spotlight this post!  
Unread 15-01-2013, 12:08
cjlane1138 cjlane1138 is offline
Team 1138
FRC #1138 (Eagle Engineering)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Los Angeles
Posts: 88
cjlane1138 is an unknown quantity at this point
Re: Problems forming NetworkTable between Robot and SmartDashboard

The issue is probably how you are initializing the NetworkTable. You are setting it to null, where it probably should be initialized. I have not yet worked with NetworkTable's, but you can try looking at the WPILib Cookbook. Also, since you have declared a variable, you can use it as a pointer, so instead of this:
Code:
RobotDemo(void):
		stick(1),
		jaguar(2),
		roborealmNetTable(NULL)
	{
		NetworkTable::SetTeam(1943);
		NetworkTable::SetIPAddress("10.19.43.5");
		NetworkTable::Initialize();
		
		roborealmNetTable = NetworkTable::GetTable("RoboRealm");
	}
You could try this:
Code:
RobotDemo(void):
		stick(1),
		jaguar(2)
	{
                roborealmNetTable = new NetworkTable("RoboRealm");
		roborealmNetTable->SetTeam(1943);
		roborealmNetTable->SetIPAddress("10.19.43.5");
		roborealm->Initialize();
		
	}
I'm sorry if this is incorrect. This just seems to be the most likely solution to the problem. I will work on NetworkTables later this week. Try this and let me know how it works out!
__________________
Eagle Engineering 1138
Closed Thread


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

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