ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

ROS2 prioritize Wifi over Ethernet by default? (Whitelist Interface)

asked 2021-08-08 04:12:51 -0600

Benjamin-Tan gravatar image

updated 2021-08-14 01:10:25 -0600

  • 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.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2021-08-14 00:57:21 -0600

Benjamin-Tan gravatar image

updated 2021-08-14 01:03:38 -0600

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.)

edit flag offensive delete link more
1

answered 2021-08-09 19:14:10 -0600

404RobotNotFound gravatar image

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.

edit flag offensive delete link more

Comments

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
Benjamin-Tan gravatar image Benjamin-Tan  ( 2021-08-09 20:08:55 -0600 )edit

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
404RobotNotFound gravatar image 404RobotNotFound  ( 2021-08-10 19:22:32 -0600 )edit

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

Benjamin-Tan gravatar image Benjamin-Tan  ( 2021-08-14 00:43:05 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2021-08-08 04:12:51 -0600

Seen: 1,950 times

Last updated: Aug 14 '21