1
$\begingroup$

Rosanswers logo

  • Ubuntu 20.04, ROS2 Foxy
  • Binary installation, FastRTPS (Default)

I was setting up multiple machines using ROS2 Foxy.

PC 1 and PC 2:

  • Ethernet with static IP address
  • Wifi with DHCP

PC 1 and PC 2 are able to ping each other via Wifi DHCP and the static Ethernet IP address.

When running a publisher in PC 1, subscriber in PC 2, by default, it was observed that it uses the Wifi interface which results in a very high latency in receiving the message.

How can I make the default to prioritize the Ethernet over Wifi network interface?

Expected behavior Communicate via Ethernet interface (lower latency)

Actual behavior Communicate via Wifi interface (very high latency)

My current workaround is to disconnect the Wifi on PC 2, which would force it to use the Ethernet to communicate. However this is not desirable in a long run.


Originally posted by Benjamin-Tan on ROS Answers with karma: 56 on 2021-08-08

Post score: 2

$\endgroup$

2 Answers 2

1
$\begingroup$

Rosanswers logo

The critical parameters that are missing from the official website are

  • is_default_profile="true"
  • <useBuiltinTransports>false</useBuiltinTransports>

The following is an example to whitelist specific IP address using ROS2 Foxy FastDDS. FASTRTPS_DEFAULT_PROFILES_FILE=./whitelist.xml ros2 run demo_nodes_cpp talker

whitelist.xml

<?xml version="1.0" encoding="UTF-8" ?>
<dds xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
    <profiles>
        <transport_descriptors>
            <transport_descriptor>
                <transport_id>CustomUdpTransport</transport_id>
                <type>UDPv4</type>
                <interfaceWhiteList>
                    <address>192.168.1.77</address>
                    <address>192.168.1.75</address>
                </interfaceWhiteList>
            </transport_descriptor>
        </transport_descriptors>
        
        <participant profile_name="CustomTcpTransportParticipant" is_default_profile="true">
            <rtps>
                <userTransports>
                    <transport_id>CustomUdpTransport</transport_id>
                </userTransports>
                <useBuiltinTransports>false</useBuiltinTransports>
            </rtps>
        </participant>
    </profiles>
</dds>

*Note1: I'm not able to set wildcard to the address (e.g. 192.168.1.*), have to explicitly states the address.

*Note2: Do not set RMW_FASTRTPS_USE_QOS_FROM_XML=1 if you simply want to keep everything else as default (i.e. history memory policy, publication mode, subscriber, publisher profile.)


Originally posted by Benjamin-Tan with karma: 56 on 2021-08-14

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

From some initial searching, I found this similar / related question about setting to use only a certain interface.

It looks like there is some configuration you can do in FastDDS where you whitelist specific interfaces.

Another link in the docs for configuration with ROS 2.

Obvious downside to this is that if the ethernet interface goes down then it will not by default try the wifi network.


Originally posted by 404RobotNotFound with karma: 331 on 2021-08-09

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by Benjamin-Tan on 2021-08-09:
I followed this to create a custom xml file.

My command:

FASTRTPS_DEFAULT_PROFILES_FILE=./whitelist.xml RMW_FASTRTPS_USE_QOS_FROM_XML=1 ros2 run demo_nodes_cpp talker

and face the following error

terminate called after throwing an instance of 'eprosima::fastcdr::exception::NotEnoughMemoryException'  what():  Not enough memory in the buffer stream

Comment by 404RobotNotFound on 2021-08-10:
Might be something similar to this question about action clients (sorta).

Might be worthwhile seeing if you can either

  • build a different FastDDS to use differently / locally? Or, technically it comes from FastCDR (which I really don't know much about)
  • see if you can configure something in cyclone dds as well? It seems that might not have the same issue based on the comments on the question I linked at the top

Comment by Benjamin-Tan on 2021-08-14:
I don't think by building a custom FastDDS locally will be a feasible solution. And this should be focusing at FastDDS (ROS2 Foxy Default Middleware) rather than CycloneDDS.

Nevertheless, I have figured this out at last.

RMW_FAST_USE_QOS_FROM_XML=1, will require your custom.xml to include the history memory policy. This configuration is causing the "Not enough memory in the buffer stream"

The default history memory policy of:

  • RMW ROS2: PREALLOCATED_WITH_REALLOC
  • FastDDS: PREALLOCATED_MEMORY_MODE

An example of the custom.xml that is working can be found here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.