Go to Post I don't care if my team wins. I care if they try their hardest to win. - pfreivald [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 03-02-2013, 20:07
IDKnow IDKnow is offline
Registered User
FRC #1671
 
Join Date: Feb 2013
Location: California
Posts: 8
IDKnow is an unknown quantity at this point
C++ Network Tables

I am attempting to use the network tables class to pass values from my SmartDashboard extensions to the robot.

This thread describes the process using Java
http://www.chiefdelphi.com/forums/sh...d.php?t=103352
but it seems to imply near the end that the same process will not work for C++

In my code and in the windows API I could find equivalent commands though- for everything other than begin and end transaction.

Without these, the robot crashes as soon an i try TableName->GetNumber("",0);

Am I missing something?

Code:
//declarations:
NetworkTable *Vision;
float d;
//initialization
Vision->GetTable("VisionTable");//should create table if does not exist
//control loop (where it crashes)
if (Vision->IsConnected())
{
     //Vision->beginTransaction();
     d = Vision->GetNumber("d",0);//where 0 is default if "d" does not exist
     //Vision->endTransaction();
}
Reply With Quote
  #2   Spotlight this post!  
Unread 04-02-2013, 08:49
nightpool's Avatar
nightpool nightpool is offline
robotRectifier
AKA: Evan
no team (formerly of CORE 2062)
Team Role: Alumni
 
Join Date: Oct 2011
Rookie Year: 2011
Location: Waukesha, WI
Posts: 81
nightpool is on a distinguished road
Re: C++ Network Tables

Hmm... Normally when interacting with the SmartDashboard one uses the static functions from the SmartDashboard class. Like SmartDashboard::GetNumber("d"), for your example.

As far as I know, the smart dashboard class does not support defaults, because you should initialize variables before you try retrieving them.
__________________
Proud alum of CORE 2062.
www.core2062.com
Reply With Quote
  #3   Spotlight this post!  
Unread 04-02-2013, 11:07
virtuald's Avatar
virtuald virtuald is online now
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,067
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: C++ Network Tables

If you examine the source code for NetworkTables, you will notice that it throws an exception when you do a GetNumber() without first doing a PutNumber() (only the first PutNumber() is required).

They got rid of Begin/End transaction in this year's implementation of NetworkTables, thus why you can't find it.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #4   Spotlight this post!  
Unread 04-02-2013, 21:22
IDKnow IDKnow is offline
Registered User
FRC #1671
 
Join Date: Feb 2013
Location: California
Posts: 8
IDKnow is an unknown quantity at this point
Re: C++ Network Tables

Thanks guys! You're advice and a little trial and error provided me with the fix:

Putting this before the GetTable command keeps the code from crashing.
I haven't tested getting values yet though because I'm having issues with the SmartDashboard. Also, the put function causes a crash but this is progress! : )

Code:
		NetworkTable::SetIPAddress("10.16.71.20");//driverstation IP
		NetworkTable::SetClientMode();
		NetworkTable::SetTeam(1671);
		NetworkTable::Initialize();
Reply With Quote
  #5   Spotlight this post!  
Unread 05-02-2013, 00:01
virtuald's Avatar
virtuald virtuald is online now
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,067
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: C++ Network Tables

Keep in mind that the 'client' is the driver station, and the 'server' is the robot. Also, you should only call SetIPAddress or SetTeam, not both. SetTeam is used to determine the IP address of the robot when in client mode. Read the code.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #6   Spotlight this post!  
Unread 06-02-2013, 00:49
IDKnow IDKnow is offline
Registered User
FRC #1671
 
Join Date: Feb 2013
Location: California
Posts: 8
IDKnow is an unknown quantity at this point
Re: C++ Network Tables

http://wpilib.screenstepslive.com/s/...client-pc-side

That's helpful. Still having trouble with the client side but I need to make it work a little differently and I'll get to fixing that tomorrow. Thanks again guys!
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 14:40.

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