Can't display vector of structs with flatbuffers in datalayer browser

Hello, I have a problem when displaying vectors of structs in the datalayer browser, see screenshot. I get the error Incorrect type. Expected "object". (json undefined) [1:1-1:5].

 

auto snapDir = snapPath();
    std::filesystem::path dir = "compiled"; // Build environment: Compiled files are stored into that sub directory
    if (snapDir != nullptr)
    {
        dir = snapDir; // Snap environment: Compiled files are stored into the $SNAP directory
    }

    std::filesystem::path fileBfbs1 = dir / "PointClusters.bfbs";

    result = provider->registerType("types/vectorData/PointClusters", fileBfbs1);
    if (STATUS_FAILED(result))
    {
        std::cout << "WARN Register type 'types/vectorData/PointClusters' " << fileBfbs1 << " failed with: " << result.toString() << std::endl;
    }

    std::filesystem::path fileMddb = dir / "metadata.mddb";
    result = provider->registerType("datalayer", fileMddb);
    if (STATUS_FAILED(result))
    {
        std::cout << "WARN Register " << fileBfbs1 << " failed with: " << result.toString() << std::endl;
    }

    result = provider->registerNode("/flatbuffers/meinPointCluster", m_locatorProviderNode);
    
    flatbuffers::FlatBufferBuilder builder1;
    
    auto flatbuffersPointClusters1 = binaryVectors::CreatePointClusters(builder1, 43.0, 4.0, 555.0, 4, 10);
    auto flatbuffersPointClusters2 = binaryVectors::CreatePointClusters(builder1, 44.0, 4.0, 555.0, 4, 10);
    auto flatbuffersPointClusters3 = binaryVectors::CreatePointClusters(builder1, 45.0, 4.0, 555.0, 4, 10);
    
    std::vector<flatbuffers::Offset<binaryVectors::PointClusters>> PointClusterVector;
    PointClusterVector.push_back(flatbuffersPointClusters1);
    PointClusterVector.push_back(flatbuffersPointClusters2);
    PointClusterVector.push_back(flatbuffersPointClusters3);
    
    auto pointClusterFinished = builder1.CreateVector(PointClusterVector);
    std::vector<flatbuffers::Offset<binaryVectors::Pose2D>> Pose2DVector;
    
    builder1.Finish(pointClusterFinished);
    
    meinPointCluster.shareFlatbuffers(builder1);

 

 Is displaying vectors of structs supported in the datalayer browser web ui?

Best reply by nickH

Hi CodeRat 

I made some changes to the C++ sample datalayer.register.node and tested the FlatBuffer schema you sent in your post. 

I managed to provide the FlatBuffer in the Data Layer with these lines:

// Register a node as flatbuffer value
  flatbuffers::FlatBufferBuilder builder;
  std::vector<flatbuffers::Offset<vectorPointClusters::PointClusters>> vecPointClusters;
  auto actPointClusters = vectorPointClusters::CreatePointClusters(builder, 43.0, 4.0, 555.0, 4, 10);
  vecPointClusters.push_back(actPointClusters);
  auto actPointClusters2 = vectorPointClusters::CreatePointClusters(builder, 2.0, 6.0, 222.0, 6, 7);
  vecPointClusters.push_back(actPointClusters2);
  auto pointClusterVec = builder.CreateVector(vecPointClusters);
  vectorPointClusters::PointClusterVecBuilder vecClusters(builder);
  vecClusters.add_pointcluster_vec(pointClusterVec);
  auto flattbufferFinished = vecClusters.Finish();
  builder.Finish(flattbufferFinished);
  
  comm::datalayer::Variant myFlatbuffer;
  myFlatbuffer.shareFlatbuffers(builder);
  std::cout << "INFO Register node 'sdk-cpp-registernode/myFlatbuffer'  " << std::endl;
  result = provider->registerNode("sdk-cpp-registernode/myFlatbuffer", new MyProviderNode(myFlatbuffer));

Thats what it looks like in the Data Layer: 

FlatBuffer in Data Layer

 

I attached also the full project here, so you can test it yourself. 

Best regards, 

Nick

datalayer.register.node.coderat.zip
207.02KB
View original
Screenshot from 2023-12-07 10-44-04.png
124.18KB
PointClusters.fbs.txt
216B
metadata.csv
740B
1
2 replies