I am working with Simulation Open Framework Architecture SOFA (C++ language) and my goal is setup some communication type between some sofa origin native data to other external application. With this order I am using ZeroMQ to transport the sofa data to a python external application.
In SOFA (C++) I have the following instrumentData structure
#include <sofa/core/behavior/BaseController.h>
#include <sofa/defaulttype/VecTypes.h>
// To Quat datatype
#include <sofa/defaulttype/Quat.h>
using sofa::defaulttype::Quat;
using std::string;
namespace sofa
{
namespace component
{
namespace controller
{
struct instrumentData
{
typedef sofa::defaulttype::Vec3d Vec3d;
Vec3d pos;
Quat quat;
int btnState;
float openInst;
bool blnDataReady;
};
}
}
}
I am trying a data communication of these below data member instrumentData structure via zmq, and to serialize / unserialize these data I am using Google Protocol Buffer with the order of my python destiny data application understand and interpret it the content of the instrumentData data members structure. Currently this data members structure arrive to your destiny but in binary format/content.
Google Protocol Buffer require describe a protocol in a format build inside .proto file extension, in which is necessary
you'll need to start with a .proto file. The definitions in a .proto file are simple: you add a message for each data structure you want to serialize, then specify a name and a type for each field in the message.
How to can I represent in my instrumentdata.proto file, the following fields: pos, quat, bool ... ?
typedef sofa::defaulttype::Vec3d Vec3d;
Vec3d pos;
using sofa::defaulttype::Quat;
Quat quat;
bool blnDataReady;
Currently, in the documentation is not clear about of how to should I define the fields in relation to Vectors and other data types like Quat (quaternions) which are SOFA native.
Vec3d and Quat is composed of some elements such as follow:
void ZMQServerComponent::instrumentDataSend(instrumentData a)
{
a.pos = sofa::defaulttype::Vec3d(1.0f, 1.0f, 1.0f);
a.quat = defaulttype::Quat(1.0f, 1.0f, 4.0f, 1.0f);
}
Is possible define as enumerators?
UPDATE
For the moment my tentative instumentdata.proto file which I am building according to the documentation is:
sintax = "proto3";
message InstrumentData {
// enum Pos {}
// enum Quat {}
int32 btnState;
float openInst;
bool blnDataReady
}
Although I have some doubts in relation to this single protocol definition
.protofiles (message descriptions) to describeVec3DandQuattypes. Can you show your attempts for the.protofiles please? Anyways a mapping layer to your native structures will be necessary, you can't represent those native structures in a direct manner. And of course it's possible to define enumerations in the protocol buffer language. Did you even bother to read their documentation?Vec3dandQuatdata types struct. I really really sorry if my question degrade the stackoverflow philosophy and I take your comments and suggest of a better way :) And of course. I will have that really research a lot about of my question specifically. Best Regardsmessagedefinitions. Good you provided your.protolanguage attempts now though..protofile thisSOFAdata types struct which are not include insideC++stack