View Single Post
  #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() {

	}
};