ros2: simple talker listener example using static discovery

asked 2020-11-09 02:40:52 -0500

Lidor Shimoni gravatar image

updated 2020-11-23 00:24:46 -0500

I'm using ros2 foxy in a low bandwidth communication environment. so in order to prevent nodes from using too much bandwidth (especially during the discovery phase) I want to implement it with fast DDS static discovery but I couldn't even get the simple talker listener example to work properly...

I couldn't find any static discovery documentation or examples that are relevant to ros2.

my config file:

<?xml version="1.0" encoding="UTF-8"?>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


    <participant profile_name="participant_nvidia" is_default_profile="true">
        <rtps>
            <builtin>
                <discovery_config>
                   <EDP>STATIC</EDP>
                    <staticEndpointXMLFilename>/home/nx/static_publisher.xml</staticEndpointXMLFilename>
                </discovery_config>
           </builtin>

        </rtps>
    </participant>

    <data_writer profile_name="chatter_writer" is_default_profile="true">
      <userDefinedID>500</userDefinedID>
      <entityID>2</entityID>
    </data_writer>

    <data_reader profile_name="chatter_reader" is_default_profile="true">
      <userDefinedID>3</userDefinedID>
      <entityID>4</entityID>
    </data_reader>

</profiles>

the static discovery config file:

<staticdiscovery>

     <participant>
        <name>HelloWorldPublisher</name>
        <writer>
            <userId>500</userId>
            <entityID>2</entityID>
            <topicName>rt/chatter</topicName>
            <topicDataType>std_msgs::msg::dds_::String_</topicDataType>
            <reliabilityQos>RELIABLE_RELIABILITY_QOS</reliabilityQos>
        </writer>
    </participant>

    <participant>
        <name>HelloWorldListener</name>
        <reader>
            <userId>3</userId>
            <entityID>4</entityID>
            <topicName>rt/chatter</topicName>
            <topicDataType>std_msgs::msg::dds_::String_</topicDataType>
            <reliabilityQos>RELIABLE_RELIABILITY_QOS</reliabilityQos>
        </reader>
    </participant>

</staticdiscovery>

if you can post a working example it will be awesome! any help would be very appreciated! !

edit retag flag offensive close merge delete

Comments

Have you found the solution, if yes, could you please kindly share the solution?

Ugesh gravatar image Ugesh  ( 2021-06-08 09:43:10 -0500 )edit