Go to Post Robots will consume you if you are not careful. - JohnBoucher [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 12-02-2012, 01:22
slibert slibert is offline
Software Mentor
AKA: Scott Libert
FRC #2465 (Kauaibots)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2005
Location: Kauai, Hawaii
Posts: 347
slibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud ofslibert has much to be proud of
NetworkTable : Tables, SubTables

We are developing cRio software in C++, and using SmartDashboard with a custom Java extension we are developing. Our goal is to have the C++ cRio code detect targets, and display information within a custom WPICameraExtension on the smart dashboard.

On the robot, we create a "Camera" table via NetworkTable::GetTable("Camera"). So far, so good.

Our next step: creating a "SubTable" for each detected Target (via NetworkTable::GetSubTable("Target<TargetNum>").

Some questions are coming up:

1) Within the C++ code, it's not clear how to *create* a SubTable. Do we "new" a NetworkTable and then use PutSubTable()? Or do we invoke NetworkTable::GetTable(subtablename) and then PutSubTable() w/the table that is returned?

2) On the SmartDashboard side, we are retrieving the "Camera" Table via Robot.getTable().getTable("Camera"). Is that correct? The hierarchy does not seem parallel between the Java and C++ code (e.g., the Java API seems to imply a "top-level, unnamed" table, whereas the C++ API seems to imply a set of named tables at the top-level.

3) If we wanted to retrieve a sub-table on the SmartDashboard side, would we retrieve it via:

Robot.getTable().getTable("Camera").getSubTable("T arget<targetnum>")

Or

Robot.getTable().getTable("Target<targetnum>")

I would prefer to use sub-tables, as it seems a more clear way of expressing the "sub-tables" for detected targets. But I'm unclear as to the appropriate method for creating sub-tables before calling "putSubTable()".

Perhaps some diagram showing the hierarchy of "top-level-table", "named table" and "named sub-table" would be helpful.... Or perhaps a code sample?
Reply With Quote
  #2   Spotlight this post!  
Unread 19-02-2012, 20:33
patrickviolette patrickviolette is offline
Registered User
FRC #1318
 
Join Date: Jan 2012
Location: Issaquah, WA
Posts: 8
patrickviolette is an unknown quantity at this point
Re: NetworkTable : Tables, SubTables

It seems like--in Java, at least--the tables are simply hash tables with buckets. Each bucket can contain any type of data..eg double, boolean, or even another NetworkTable. So adding a subtable in Java looks like:

NetworkTable add = new NetworkTable();
NetworkTable.getTable("main").putSubTable("aSubTab le", add);

We have gotten errors if we try to access a subtable that we have not created yet.

NetworkTable.getTable("main").getSubTable("camera" ).putDouble("x", 40);
//does not work, unless you have put the "camera" subtable into the main table previously

Again, we are using Java, so it may be implemented somewhat differently in C++. Hope that helps, though.
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 17:37.

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