Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to create a publisher for a dynamic object #694

Open
aristow1 opened this issue Jul 8, 2024 · 0 comments
Open

how to create a publisher for a dynamic object #694

aristow1 opened this issue Jul 8, 2024 · 0 comments

Comments

@aristow1
Copy link

aristow1 commented Jul 8, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant