create_type_from_tuple

7 posts / 0 new
Last post
isa Özyıldırım's picture
Offline
Last seen: 2 months 3 weeks ago
Joined: 04/19/2024
Posts: 6
create_type_from_tuple

this is my first entry and try :)

- i have installed trial rti_connext_dds-7.3.0 version on windows : x64Win64VS2017

- i created dummy project from rti tools, and linkage in visual studio is so:  $(NDDSHOME)\lib\x64Win64VS2017

- i want so create dynamic data for publishing. 

#include <iostream>
#include <stdio.h>
#include <stdlib.h>

#include <dds/core/ddscore.hpp>
#include <dds/pub/ddspub.hpp>
#include <dds/sub/ddssub.hpp>
#include <rti/core/xtypes/DynamicDataTuples.hpp>

using namespace dds::core::xtypes;
using namespace rti::core::xtypes;
using namespace std; // for cout and endl

int main(int argc, char *argv[])
{

using namespace dds::core::xtypes;

dds::core::xtypes::StructType mytype = rti::core::xtypes::create_type_from_tuple< int32_t, double, std::string>("MyOtherType");

rti::core::xtypes::print_idl(mytype);

return 0;

}

 

but i get following build error:   error LNK2019: unresolved external symbol "public: static void __cdecl rti::core::DynamicTypeNativeAdapter::finalize(struct DDS_TypeCode &)" (?finalize@DynamicTypeNativeAdapter@core@rti@@SAXAEAUDDS_TypeCode@@@Z) referenced in function "protected: __cdecl rti::core::NativeValueType<class rti::core::xtypes::DynamicTypeImpl,struct DDS_TypeCode,class rti::core::DynamicTypeNativeAdapter>::~NativeValueType<class rti::core::xtypes::DynamicTypeImpl,struct DDS_TypeCode,class rti::core::DynamicTypeNativeAdapter>(void)" (??1?$NativeValueType@VDynamicTypeImpl@xtypes@core@rti@@UDDS_TypeCode@@VDynamicTypeNativeAdapter@34@@core@rti@@IEAA@XZ)

can i not so build dynamic data creation with trial version ? 

 

Organization:
Howard's picture
Offline
Last seen: 7 hours 24 min ago
Joined: 11/29/2012
Posts: 605

The trial version of RTI Connext is exactly the same as the paid version with only 1 difference...the trial version requires a valid license file to run.

I'm not sure how you created your "dummy" project with RTI tools, but your project isn't setup correctly and seems to be missing a library that needs to be linked.  I'm guessing that you're missing

nddscpp2.lib

(if you're compiling with Release/DLL linkage).

The full list of required libraries can be found in Table 9.2 (which will be different depending on Release vs Debug, Static vs DLL as well as which language is being used):

https://community.rti.com/static/documentation/connext-dds/7.3.0/doc/manuals/connext_dds_professional/platform_notes/platform_notes/Windows_Platforms.htm#9.1_Building_Applications_for_Windows_Platforms

 

isa Özyıldırım's picture
Offline
Last seen: 2 months 3 weeks ago
Joined: 04/19/2024
Posts: 6

Hi Howard,

i added so linkage files as a in picture, but i get so same problem:(  

isa Özyıldırım's picture
Offline
Last seen: 2 months 3 weeks ago
Joined: 04/19/2024
Posts: 6

Hi,

Actually i need so create dynamic data publishing.  Dynamic data is needed to create in a runtime not so sttaic as a idl file. i have found so this function for this case:  " rti::core::xtypes::create_type_from_tuple(...)". 

Howard's picture
Offline
Last seen: 7 hours 24 min ago
Joined: 11/29/2012
Posts: 605

So, I'm not sure you understand our platform notes.  First there are 4 different sets of libraries that you need to use depending on if you are compiling

Debug (static linkage)

Release (static linkage)

Debug DLL (dynamic linkage)

Release DLL (dynamic linkage)

From your picture it looks like you are compiling Debug (static linkage), in which case, Table 9.2 shows that you need just these 3 libraries for that configuration.

nddscorezd.lib

nddsczd.lib

nddscpp2zd.lib

And you should put it in that order since nddscpp2 depends on nddsc which depends on nddscore.

 

Attached is a working example project (about which I did ask how you generated the Visual Studio project that you are using...you wrote that you used RTI tools...I assume you mean rtiddsgen, but how did you do that?  what was the command line argument?  rtiddsgen will generate the project specifically to support the programming language for which you have asked for an example, and if you are using Modern C++, you should be using "-language C++11" as a command line argument.

 

 

File Attachments: 
isa Özyıldırım's picture
Offline
Last seen: 2 months 3 weeks ago
Joined: 04/19/2024
Posts: 6

Hello Howard,

Thank you very much for your answers.

My project Code generator of RTI launcher 7.3.0. I did it with but it was a small experiment, we can forget about it :)

Yes, you are right, I do not fully master the platform yet.
I ran your project and saw the output.

But as far as I understand, the type of data sent is written to the idl file in advance.
For example, in the project you sent, it is registered as foo long in the idl file before build.
But in my scenario, I do not know which data types or data names to send at run time. quite variable :)

for example :
- I can send fooInt (Int) + fooString(String) to the same topic as data during a runtime
- When I run the app again, I can send fooInt (Int) + fooChar(Char) to the same topic.
- When I run the app again, I can send fooInt (Int) + fooChar(Char) + fooString(String) to the same topic.

I need a continuously variable structure as data.

In this case, how is the idl file usage situation? Or have I seen the DynamicType class?

Normally (apache kafka etc.) in such cases I can send all the data with json string. The subscriber side converts it from string to json again :)

Howard's picture
Offline
Last seen: 7 hours 24 min ago
Joined: 11/29/2012
Posts: 605

In the example that I sent, rtiddsgen needed an IDL file as an input to create the example Visual Studio project.  I only did that as a convenient way to generate example Visual Studio project that has been properly configured with all of the settings needed to build an application that uses RTI Connext DDS with the Modern C++ language binding.

Yes, the IDL file defines a data type for which rtiddsgen also generated type support code.  But that is not related to your original use case in which you wanted to define a data type via the DynamicData API.  It is not needed to make calls to a DynamicData API.  You can modify the code to remove all of the references to the data type defined in the IDL as well as the supporting source code file, and the code that calls the Dynamic Data API will still work.

When using the DynamicData API, you can define data types at runtime for Topics and not have any of the definition compiled/built into the binary.

However, once a data type is defined/created, the definition of that data type cannot be changed for the lifetime of the objects (Topics, DataWriters, DataReaders) that use that data type.  If you do want it to change, you must destroy the Topics/DataWriters/DataReaders as well as the data type, and then recreated the data type (via the DynamicData API) and all objects that use that data type.

DDS is data-centric.  Which means that Topics are strongly typed and do not change their type definition while running. 

As with programming languages, once a variable is defined to be a certain type, you cannot change the type of that variable.  So, there is no such thing as a "continuously variable structure"...the structure of a variable must always be well defined.

What you CAN have is a data type that can hold a blob of data, and the data itself can be anything at anytime (as long as it doesn't exceed the maximum size of the blob).

A simple example is if you want to use a JSON-formated string to send your data, you can define a datatype such as

struct JsonData {

   string<MAX_LENGTH> data;

};

And then you can send any JSON-formated string that you want in the datatype.  And the content of the string can change as you want.  If you don't want to set a MAX_LENGTH, then you have to define the string as Unbounded...which is a parameter that you have to pass into the DynamicData API (if you are using that to define the data structure, or a command line argument to rtiddsgen in the case that you use IDL).

Of course, a string in any format is highly inefficient to send data.  A binary representation of the information in a string will be much more compact and take less resources to send/receive.

If you haven't yet, I recommend going through RTI Academy, https://www.rtiacademy.com.  I think you will find many of the modules in RTI Academy useful to understand the basics of DDS and RTI Connext.

If you want, I can put you in touch with some RTI folks local to where you are so that they can help you do what you're trying to so.  This forum is not as efficient for answering questions/solving issues for customers who have paid licenses and support..  If you're interested, just send a private message to my email, howard@rti.com.