Skip to content

how to create a publisher for a dynamic object #694

@aristow1

Description

@aristow1

Hello, im trying to create a publisher for the dynamic_data_nested_struct.c example.
i have taken the simple xml file that is generated when using the code generator of rti connext and included the the path to my rti license. i added in the .c file of the example code to include domainparticipant, publisher and a topic but im not sure that i have done it correctly. im still a beginner so i was wondering if i could get any help on how to correctly implement a publisher and correctly adjust my xml file.

this is my current xml file that was generated when i ran a simpler idl file through the code generator which i then added into the build folder of this example

<qos_library name="SmartHome_Library">

        <!-- QoS profile used to configure reliable communication between the DataWriter 
             and DataReader created in the example code.

             A QoS profile groups a set of related QoS.
        -->
        <qos_profile name="SmartHome_Profile" base_name="BuiltinQosLib::Generic.StrictReliable" is_default_qos="true">
            <!-- QoS used to configure the data writer created in the example code -->                
            <datawriter_qos>
                <publication_name>
                    <name>SmartHomeDataWriter</name>
                </publication_name>
            </datawriter_qos>

            <!-- QoS used to configure the data reader created in the example code -->                
            <datareader_qos>
                <subscription_name>
                    <name>SmartHomeDataReader</name>
                </subscription_name>
            </datareader_qos>
            <domain_participant_qos>
                <!--
                The participant name, if it is set, will be displayed in the
                RTI tools, making it easier for you to tell one
                application from another when you're debugging.
                -->
                <participant_name>
                    <name>SmartHomeParticipant</name>
                    <role_name>SmartHomeParticipantRole</role_name>
                </participant_name>
                <property>
                    <value>
                        <element>
                            <name>dds.license.license_file</name>
                            <value>path to license</value>
                     </element>
                    </value>
                </property>

            </domain_participant_qos>
        </qos_profile>

    </qos_library>
</dds>

and this is the added publisher, domainparticipant and topic to the .c file :

participant = DDS_DomainParticipantFactory_create_participant(
        DDS_DomainParticipantFactory_get_instance(), 
        0, 
        &DDS_PARTICIPANT_QOS_DEFAULT, 
        NULL, 
        DDS_STATUS_MASK_NONE);
    if (participant == NULL) {
        fprintf(stderr, "! Unable to create DDS domain participant\n");
        goto fail;
    }

    topic = DDS_DomainParticipant_create_topic(
        participant, 
        "Example OuterStruct", 
        "TopicExample", 
        &DDS_TOPIC_QOS_DEFAULT, 
        NULL, 
        DDS_STATUS_MASK_NONE);
    if (topic == NULL) {
        fprintf(stderr, "! Unable to create DDS topic\n");
        goto fail;
    }

    writer = DDS_Publisher_create_datawriter(
        publisher, 
        topic, 
        &DDS_DATAWRITER_QOS_DEFAULT, 
        NULL, 
        DDS_STATUS_MASK_NONE);
    if (writer == NULL) {
        fprintf(stderr, "! Unable to create DDS datawriter\n");
        goto fail;
    }

and this is the error i get when trying to start the example :


{N=SmartHomeParticipant,D=0}|CREATE To WITH TOPIC Example OuterStruct] DDS_Topic_createI:!type registered
! Unable to create DDS topic

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions