rticommunity / rticommunity/rticonnextdds-examples

how to create a publisher for a dynamic object

Open
#694 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
148
Forks
153
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the dynamic_data_nested_struct.c example and the generated XML shown in the issue, then run the example to reproduce the DDS_Topic_createI error. Trace how the example obtains its type support and creates the publisher, participant, and topic; done means the example starts successfully with the configured XML and creates the requested publisher without the type-registration error.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
distributed-systems
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.