However, when I change “-turret-feedback” to “pathTable” such that I am accessing a subtable rather than a double, there is no get method for turret to read its value.
Also, when I do:
turret.getKeys().toString();
it prints the turret feedback and offset, but not pathTables.
It’s like it doesn’t recognize the subtable as part of Smartdashboard.
Fundamentally NetworkTables is a flat namespace. Subtables are completely notional things and not actually stored as such, but rather just prefix the entry key with the subtable with “/” separators. For example, SmartDashboard → pathTable → -turret-feedback is actually stored as a single string “/SmartDashboard/pathTable/-turret-feedback”. This means you can’t actually “access” a subtable. You can only access the individual entries within it. All of the functions like getSubTables() work by seeing what keys start with that prefix.
The SmartDashboard class also prefixes all entries it creates with “/SmartDashboard/”. So SmartDashboard.getEntry(“blah”) is really accessing the key “/SmartDashboard/blah”. The raw NetworkTables functions don’t do this. That’s why your third bit of code doesn’t work… it is accessing “/pathTable” not “/SmartDashboard/pathTable”.
Now, if they would document the Network Tables entry on the official document as such, it would make a lot of newer folks lives a lot better.
I usually just tell the kids that it’s a virtual spreadsheet and it’s just a 2 column rows of cells with name on one side and values on the other side. Any structure are not real and just flat key->value only.
Actually NetworkTables has a flat namespace for the keys. Having tables and subtables is an abstraction to make it easier to organize your data. So for a table called “SmartDashboard” and a key named “xValue”, it is really a single key called “/SmartDashboard/xValue”. The hierarchy is not actually represented in the distributed data, only keys with prefixes that are the contained table.