Hi David,
I made a little test and succeded.
To create a flatbuffer data type you need to use the genearted-header files, which got created out of the FlatBuffer-schema (.fbs).
You can check, I think depending on the SDK Version you are using the _generated.h files of the motion-app data types are allready in the SDK (under the path /include). If they are not there then you can also generate them out of the .fbs files with the help of the flatc (flatbuffer compiler).
Here is how I have done it for the two flatbuffers I need for the pos-abs command:
If you include these headers in your .cpp you can use the "Create..."-functions like this:
// Synchronous create of a ctrlX Data Layer of the motion app to command the Axis "Axis_1" -----------------------------------------------------------
auto DataLayerAddress = "motion/axs/Axis_1/cmd/pos-abs";
comm::datalayer::Variant myCmdPositionData;
//create the flatbuffer data type with the help of the generated header
flatbuffers::FlatBufferBuilder builder;
auto limits = motion::core::fbtypes::CreateDynamicLimits(builder,1.0,1.0,1.0,0.0,0.0);
auto cmdData = motion::core::fbtypes::CreateAxsCmdPosData(builder,10.0,true,limits,motion::core::fbtypes::CmdPosAbsDir_SHORTEST_WAY);
builder.Finish(cmdData);
myCmdPositionData.shareFlatbuffers(builder);
std::cout << "INFO create " << DataLayerAddress << " synchronously..." << std::endl;
auto result = dataLayerClient->createSync(DataLayerAddress, &myCmdPositionData);
if (result != DL_OK)
{
std::cout << "WARN create " << DataLayerAddress << " failed with: " << result.toString() << std::endl;
}
else
{
std::cout << "Create to " << DataLayerAddress << " succeded: "<< result.toString()<< std::endl;
}
Best regards,
Nick
... View more