Ask Your Question
4

ROS2 Talker cannot communicate with Listener

asked 2018-08-12 08:13:49 -0500

takijo gravatar image

updated 2018-09-08 23:42:48 -0500

Hi,

I want to use ROS2.

I finished to setup ROS2,but talker cannot communicate with listener.

My setup is below.

$ sudo apt update && sudo apt install curl 
$ curl http://repo.ros2.org/repos.key | sudo apt-key add -
$ sudo sh -c 'echo "deb [arch=amd64,arm64] http://repo.ros2.org/ubuntu/main xenial main" > /etc/apt/sources.list.d/ros2-latest.list'
$ sudo apt update
$ sudo apt install `apt list "ros-ardent-*" 2> /dev/null | grep "/" | awk -F/ '{print $1}' | grep -v -e ros-ardent-ros1-bridge -e ros-ardent-turtlebot2- | tr "\n" " "`

So, the terminal 1 is

$ source /opt/ros/ardent/setup.bash
$ ros2 run demo_nodes_cpp talker

and, the terminal 2 is

$ source /opt/ros/ardent/setup.bash
$ ros2 run demo_nodes_cpp listener

terminal 1 display

$ ros2 run demo_nodes_cpp talker
[INFO] [talker]: Publishing: 'Hello World: 1'
[INFO] [talker]: Publishing: 'Hello World: 2'
[INFO] [talker]: Publishing: 'Hello World: 3'
[INFO] [talker]: Publishing: 'Hello World: 4'
[INFO] [talker]: Publishing: 'Hello World: 5'

but ,terminal 2 no response.

What am I wrong?

(I use Ubuntu16.04LTS)

edit retag flag offensive close merge delete

Comments

How long have you left the listener running for to wait for a response? Discovery can take some time, although on a local machine I would expect it to success fairly quickly.

Geoff gravatar image Geoff  ( 2018-09-10 01:38:31 -0500 )edit

I waited for about ten seconds,but not try it more. After a change of my ufw, I could success quickly.

takijo gravatar image takijo  ( 2018-09-10 17:47:05 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2018-08-12 20:59:48 -0500

Geoff gravatar image

Make sure that you are allowing multicast traffic in the firewall. By default, the ufw firewall included in 16.04 blocks multicast traffic, even for loopback (i.e. on the same system). Here's an example of allowing multicast in ufw.

edit flag offensive delete link more

Comments

I can communicate with listener by the the way of above site.

I allow udp multicast in ufw.

sudo ufw allow in proto udp to 224.0.0.0/4
sudo ufw allow in proto udp from 224.0.0.0/4

Thank you for your help!

takijo gravatar image takijo  ( 2018-08-13 08:31:39 -0500 )edit

If you run into a similar problem you can try the new multicast verb to test if simple multicast functionality is working for you: https://github.com/ros2/ros2cli/pull/145

Dirk Thomas gravatar image Dirk Thomas  ( 2018-09-10 17:54:09 -0500 )edit

Also note, the same symptoms (i.e. ROS2 Talker cannot communicate with Listener) occur if the computer has no network configured. To test, try this: ros2 multicast receive in one terminal and ros2 multicast send in another terminal. If there are errors like load_entry_point … then plug your computer into a network and try again.

Tav_PG gravatar image Tav_PG  ( 2019-09-25 22:16:15 -0500 )edit

Is there someone else with ros2 multicast working, other nodes are not able to see each other? Even ros2 topic pub /chatter std_msgs/String "data: ping" in one terminal isn't noticed by ros2 topic list in an another terminal. Of cause both have ros2 galactic sourced.

codierknecht gravatar image codierknecht  ( 2021-08-23 15:23:18 -0500 )edit

@codierknecht, I also have that issue, what version are you running? did you ever find a fix?

twaddell gravatar image twaddell  ( 2021-09-27 23:38:40 -0500 )edit

@twaddell I did mange to solve the problem for running nodes on the same machine by exporting ROS_LOCALHOST_ONLY=1. However I currently don't have a second machine due to cross-compilation problems for a raspberry pi model 2b.

codierknecht gravatar image codierknecht  ( 2021-10-01 07:14:07 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2018-08-12 08:13:49 -0500

Seen: 1,779 times

Last updated: Sep 08 '18