FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
12-07-2023 10:51 AM - edited 12-07-2023 10:54 AM
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?
Solved! Go to Solution.
12-08-2023 03:30 PM
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:
I attached also the full project here, so you can test it yourself.
Best regards,
Nick
12-13-2023 10:18 AM
Thank you for the reply :). I have successfully implemented it in my version, howerver I was stuck for a long time figuring out why my nodes didn't have any values. It seems like the folder in /types has to have the same name as the fbs file.