Closed fovea1959 closed 1 year ago
Ran into this recently also
Replacing the CreateTopicMenuItem function in the file glass/src/libnt/native/cpp/NetworkTables.cpp (approximately line 1040) with the following code, fixes most of the problems. This works for both glass and outlineviewer.
Entering float arrays does not work in either (double array do). Adding of types with the exception of double and float work. If you have glass as a client and outlineviewer as a server, the entries get added on both. The value appears in the app it was created in, but does not appear on the other app. Once the value is changed in the app it was created in, the value propagates to the other app. Notice for float and double topics the line of code is different than the other types. The line that is commented out always crashes either program. The line of code that is not commented out may cause the app to crash.
static void CreateTopicMenuItem(NetworkTablesModel model,
std::string_view path, NT_Type type,
const char typeStr, bool enabled) {
if (ImGui::MenuItem(typeStr, nullptr, false, enabled)) {
NT_Topic ntTopic(nt::GetTopic(model->GetInstance().GetHandle(), path));
auto entry = model->AddEntry(ntTopic);
if (entry->publisher == 0) {
entry->publisher = nt::Publish(entry->info.topic, type, typeStr);
entry->persistent = path.starts_with("/Preferences/");
nt::Topic(ntTopic).SetPersistent(entry->persistent);
switch (type) {
case NT_BOOLEAN:
model->GetInstance().GetBooleanTopic(path).Publish().Set(false);
break;
case NT_INTEGER:
model->GetInstance().GetIntegerTopic(path).Publish().Set(0);
break;
case NT_FLOAT:
nt::Topic(ntTopic).GenericPublish(typeStr).SetFloat(0.0f); // May crash program
//model->GetInstance().GetFloatTopic(path).Publish().Set(0.0f); // CRASHES Program
break;
case NT_DOUBLE:
nt::Topic(ntTopic).GenericPublish(typeStr).SetDouble(0.0); // May crash program
//model->GetInstance().GetDoubleTopic(path).Publish().Set(0.0); // CRASHES Program
break;
case NT_STRING:
model->GetInstance().GetStringTopic(path).Publish().Set("");
break;
case NT_BOOLEAN_ARRAY:
model->GetInstance().GetBooleanArrayTopic(path).Publish().Set(std::vector
Fixed in #5109.
Describe the bug 2023 Outline Viewer does not correctly add new values to network tables.
To Reproduce Steps to reproduce the behavior:
SmartDashboard.putBoolean("fovea1959", false);
Expected behavior I expect the network table entry to be added with a type and the ability to change it's value.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context Add any other context about the problem here.