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

Communication between nodes fails for non small-sized images ros2 topics #570

Open
iqedgarmg opened this issue Nov 14, 2021 · 4 comments
Open
Labels
more-information-needed Further information is required

Comments

@iqedgarmg
Copy link

iqedgarmg commented Nov 14, 2021

Hi everyone!

I make a basic python camera publisher/subscriber using ros2 galatic on a pair of Windows 10 machines located on the same local network. I change the middleware layer on both machines to fast-rtps using this tutorial:

https://fast-dds.docs.eprosima.com/en/latest/fastdds/ros2/discovery_server/ros2_discovery_server.html

and this .xml file:

<?xml version="1.0" encoding="UTF-8" ?>
<dds>
    <profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
        <participant profile_name="super_client_profile" is_default_profile="true">
            <rtps>
                <builtin>
                    <discovery_config>
                        <discoveryProtocol>SUPER_CLIENT</discoveryProtocol>
                        <discoveryServersList>
                            <RemoteServer prefix="44.53.00.5f.45.50.52.4f.53.49.4d.41">
                                <metatrafficUnicastLocatorList>
                                    <locator>
                                        <udpv4>
                                            <address>127.0.0.1</address>
                                            <port>11811</port>
                                        </udpv4>
                                    </locator>
                                </metatrafficUnicastLocatorList>
                            </RemoteServer>
                        </discoveryServersList>
                    </discovery_config>
                </builtin>
            </rtps>
        </participant>

	<!-- Publisher profile  -->
        <publisher profile_name="/usb_camera/camera/rgb">
            <qos>
                <publishMode>
                    <kind>SYNCHRONOUS</kind>
                </publishMode>
            </qos>
            <historyMemoryPolicy>PREALLOCATED_WITH_REALLOC</historyMemoryPolicy>
        </publisher>	

        <!-- Subscriber profile -->
        <subscriber profile_name="/usb_camera/camera/rgb">
            <historyMemoryPolicy>PREALLOCATED_WITH_REALLOC</historyMemoryPolicy>
        </subscriber>

    </profiles>
</dds>

Once configured, I can publish/subscribe topics between both machines using small-size data topics. Nevertheless, when I try to subscribe to the camera topic generated by my node, the callback did not work on the subscriber node.

Curiously, if I resize the published image to a small resolution (100x100 pixels) everything works fine. So, I think that this is a problem related to the topic data size.    

I tried with some of the solutions mentioned in this issue:

#460

Nevertheless still at the moment I can't subscribe to the camera topic if the image is greater than 100x100 pixels.

Thanks in advance for your help!

Bug report

Required Info:

  • Operating System:
    • Windows 10
  • Installation type:
    • Binaries
  • DDS implementation:
    • Fastrtps
  • Client library (if applicable):
    • rclpy

Steps to reproduce issue

Expected behavior

  • Machine with the subscriber node is able to read the image topic from the publisher node using any image resolution.

Actual behavior

  • Communication works only if a small-sized image is employed (100x100 pixels).
  • For images greater than 140 pixels, the communication did not work.

Additional information

  • Communication works fine for small-sized topics (strings, vectors etc.)
  • I use the standard sensor_msgs::Image ros topic for the publisher and subscriber.

@iqedgarmg iqedgarmg changed the title Communication between nodes fail for non-small image ros2 topics Communication between nodes fails for non small-sized images ros2 topics Nov 14, 2021
@MiguelCompany
Copy link
Collaborator

@iqedgarmg In order to reproduce your issue, it would be nice to have a minimal reproducer with the code you are running, as long as the QoS settings.

@iqedgarmg
Copy link
Author

iqedgarmg commented Nov 16, 2021

Hi @MiguelCompany, thanks a lot for your quick response!.

In this drive, you can download the publisher/subscriber node that I developed using OpenCV:

https://drive.google.com/drive/folders/1p4GziL_vGGfIfFkao0-Z-lpc-YTRcodE?usp=sharing

This package has two nodes:

a) Publisher
ros2 run usb_camera usb_camera

Publisher generates two topics:

* /usb_camera/rgb: sensor_msgs::Image topic with the camera image.
* /usb_camera/sub: std_msgs::Int8 topic for testing.

b) Subscriber
ros2 run usb_camera camera_subs

If everything works fine, you should visualize an OpenCV window with the received image topic.

This is the configuration that I run on both machines to achieve ros2 connection:

1.- Change ROS middleware to fastrtps

set RMW_IMPLEMENTATION=rmw_fastrtps_cpp

2.- Call a discovery server (machine that has the publisher)

python C:\dev\ros2-windows\tools\fastdds\fastdds.py discovery -i 0

3.- Setup a global discovery server (IP of the machine that has the publisher)

set ROS_DISCOVERY_SERVER=127.0.0.1:11811

4.- Set FastRTPS profile

set FASTRTPS_DEFAULT_PROFILES_FILE=C:\ros_projects\ros_ws\super_client_configuration_file.xml

with this configuration file:

<?xml version="1.0" encoding="UTF-8" ?>
<dds>
    <profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
        <participant profile_name="super_client_profile" is_default_profile="true">
            <rtps>
                <builtin>
                    <discovery_config>
                        <discoveryProtocol>SUPER_CLIENT</discoveryProtocol>
                        <discoveryServersList>
                            <RemoteServer prefix="44.53.00.5f.45.50.52.4f.53.49.4d.41">
                                <metatrafficUnicastLocatorList>
                                    <locator>
                                        <udpv4>
                                            <address>127.0.0.1</address>
                                            <port>11811</port>
                                        </udpv4>
                                    </locator>
                                </metatrafficUnicastLocatorList>
                            </RemoteServer>
                        </discoveryServersList>
                    </discovery_config>
                </builtin>
            </rtps>
        </participant>

	<!-- Publisher profile  -->
        <publisher profile_name="/usb_camera/rgb">
            <qos>
                <publishMode>
                    <kind>SYNCHRONOUS</kind>
                </publishMode>
            </qos>
            <historyMemoryPolicy>PREALLOCATED_WITH_REALLOC</historyMemoryPolicy>
        </publisher>	

        <!-- Subscriber profile -->
        <subscriber profile_name="/usb_camera/rgb">
            <historyMemoryPolicy>PREALLOCATED_WITH_REALLOC</historyMemoryPolicy>
        </subscriber>

    </profiles>
</dds>

In my case, the subscriber works fine if the image resolution is less than 100x100 pixels (as well as for any topic of small size), but didn't work for larger image resolutions (publisher continues working, but subscriber callback not work).

Please let me know if you require further information. Thanks again for your help!

@iqedgarmg
Copy link
Author

iqedgarmg commented Nov 19, 2021

Hi @MiguelCompany, I finally found the way to make the subscriber working. I write the solution if this is useful for someone:

1.- Set QoS on Python publisher
I forgot to define the proper QoS configuration on the publisher and subscriber nodes. In Python, this can be made as follows:

#Import QoS Profile for sensor data
from rclpy.qos import qos_profile_sensor_data  

#Add QoS configuration to publisher (host computer node)
self.cam_pub = self.create_publisher(Image, '/usb_camera/rgb', qos_profile=qos_profile_sensor_data)

#Add QoS configuration to subscriber (subscriber node on remote pc)
s]elf.camera_subscription = self.create_subscription(Image, '/usb_camera/rgb', self.camera_callback, qos_profile=qos_profile_sensor_data)

2.- Setup SYNCHRONOUS mode
I was running the nodes in asynchronous mode, by changing it to synchronous the topic speed improves considerably.

set RMW_FASTRTPS_PUBLICATION_MODE=SYNCHRONOUS

By developing the previous modifications (and following the instructions described in my previous response), now the publisher and subscriber are working using the original image size at 12 Hz.

@hidmic
Copy link
Contributor

hidmic commented Dec 7, 2021

@audrow I take that #571 is somehow related to this.

@clalancette clalancette added the more-information-needed Further information is required label Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more-information-needed Further information is required
Projects
None yet
Development

No branches or pull requests

4 participants