BehaviorTree.CPP icon indicating copy to clipboard operation
BehaviorTree.CPP copied to clipboard

zmq publisher can't use parallelly

Open HansRobo opened this issue 4 years ago • 5 comments

zmq publisher can't use parallelly, because tcp port is fixed as below. https://github.com/BehaviorTree/BehaviorTree.CPP/blob/2a859e68f40f0b86c910e2f76053a3e9b5a09469/src/loggers/bt_zmq_publisher.cpp#L43-L44

If you try to use zmq publishers in parallel, you will get an error on the second and subsequent publishers.

terminate called after throwing an instance of 'zmq::error_t'
  what():  Address already in use

This problem makes me inconvenient when debugging multi-robots for example, RoboCup Soccer SSL.

Are there any plans to expand it to allow flexible port specification?

HansRobo avatar Dec 17 '19 16:12 HansRobo

Fixed, at least on this library side. I need to address this in Groot now.

Thanks for reporting!

facontidavide avatar Mar 19 '20 20:03 facontidavide

Thank you for the update! I have a problem. I can't create multiple instances of PublisherZMQ with different server and publisher port configuration even on different threads in the same program. This works perfectly if they are on separate executables or instances of application with configured ports. What is the workaround to publish status of multiple trees from the same program?

Sarath18 avatar Apr 16 '20 18:04 Sarath18

I've done this in Nav2 via making the ZMQ publisher a static variable shared across all instances, so far the only workable solution I've found other than making it an input reference.

SteveMacenski avatar Mar 24 '21 22:03 SteveMacenski

I am currently also facing this issue, but I don't know how to fix it (the information from this issue didn't help me).

My system is running on Ubuntu 20.04 with ROS2 Galactic. I'm trying to run a behavior tree next to a Gazebo simulation with RTAB-Map and Nav2. For this, I first execute the following 4 commands consecutively in seperate terminals: ros2 launch turtlebot3_gazebo turtlebot3_house.launch.py ros2 launch rtabmap_ros turtlebot3_scan.launch.py ros2 launch nav2_bringup navigation_launch.py use_sim_time:=True ros2 launch nav2_bringup rviz_launch.py

This all works fine. Then I try to launch/execute the behavior tree with the following command: /build/BehaviorTreeDemo ${PWD}/CustomBehaviorTree.xml

Which results in the following error: terminate called after throwing an instance of 'zmq::error_t' what(): Address already in use Aborted (core dumped)

If I don't launch the first 4 terminal commands related to ROS, then I can execute the behavior tree without a problem.

What can I do to fix this problem and run both ROS and the behavior tree at the same time?

Edited to fix the command formatting.

ghost avatar Apr 05 '22 12:04 ghost

Okay I fixed the problem.

I edited the following file: ~/colcon_ws/src/navigation2/nav2_bringup/bringup/params/nav2_params.yaml

On line 59 and 60 I changed the ports from 1666 and 1667 to 1866 and 1867 respectively: groot_zmq_publisher_port: 1866 groot_zmq_server_port: 1867

After running the colcon build --symlink-install command from the colcon workspace root, and then running the command source ~/.bashrc, I was able to launch the 4 ROS commands and the seperate behavior tree command from my previous post.

Hope this helps others out.

ghost avatar Apr 05 '22 14:04 ghost